Add script for removing <CR> on windows.

This caused bad stuff to be generated on windows, specifically
the amalg file. We cause totally strip <CR> from files on windows
using this script.
This commit is contained in:
Calvin Rose 2019-09-12 23:18:52 -05:00
parent 0e99d8d80f
commit e6306ea188
3 changed files with 12 additions and 1 deletions

View File

@ -98,6 +98,7 @@ for %%f in (src\core\*.c) do (
set "amalg_files=!amalg_files! %%f"
)
janet.exe tools\amalg.janet src\core\util.h src\core\state.h src\core\gc.h src\core\vector.h src\core\fiber.h src\core\regalloc.h src\core\compile.h src\core\emit.h src\core\symcache.h %amalg_files% build\core_image.c > build\janet.c
janet.exe tools\removecr.janet build\janet.c
echo === Successfully built janet.exe for Windows ===
echo === Run 'build_win test' to run tests. ==
@ -137,6 +138,7 @@ exit /b 0
:DIST
mkdir dist
janet.exe tools\gendoc.janet > dist\doc.html
janet.exe tools\removecr.janet dist\doc.html
copy build\janet.c dist\janet.c
copy janet.exe dist\janet.exe

View File

@ -9,4 +9,4 @@
# Body
(each path (tuple/slice (dyn :args) 1)
(print (slurp path)))
(print (slurp path :r)))

9
tools/removecr.janet Normal file
View File

@ -0,0 +1,9 @@
# Remove carriage returns from file. Since piping things on
# windows may add bad line endings, we can just force removal
# with this script.
(def fname ((dyn :args) 1))
(with [f (file/open fname :rb+)]
(def source (:read f :all))
(def new-source (string/replace-all "\r" "" source))
(:seek f :set 0)
(:write f new-source))