aboutsummaryrefslogtreecommitdiff
path: root/build.bat
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2025-08-13 15:10:37 +0100
committerSebastiano Tronto <sebastiano@tronto.net>2025-08-13 15:10:37 +0100
commitc368c0f4aa0a810f5102cb8958e57410e572afa8 (patch)
treefb78228de7ee0b7883c19848e522fec58f673043 /build.bat
parent1562c2e8ef10e25973317c790c2779e9d595e5f1 (diff)
downloadnissy-core-c368c0f4aa0a810f5102cb8958e57410e572afa8.tar.gz
nissy-core-c368c0f4aa0a810f5102cb8958e57410e572afa8.zip
Improvements to build.bat (unit tests on Windows)
Diffstat (limited to 'build.bat')
-rw-r--r--build.bat149
1 files changed, 139 insertions, 10 deletions
diff --git a/build.bat b/build.bat
index ae1c037..6a3133e 100644
--- a/build.bat
+++ b/build.bat
@@ -1,21 +1,150 @@
1SET COMPILER=clang 1@echo off
2
3if [%1]==[/d] (
4 SET DEBUG=1
5 shift
6) else (
7 SET DEBUG=0
8)
9
10SET CC=clang
11SET ARCH=PORTABLE
12SET THREADS=1
13SET SANITIZE=
14
15:: TODO depends on ARCH variable
16SET ARCHOPTS=
17:: TODO depends on SANITIZE variable
18SET DFLAGS=-g3 -DDEBUG
2 19
3SET ARCH=
4SET WARNINGS=-Wno-deprecated-declarations 20SET WARNINGS=-Wno-deprecated-declarations
5SET VARIABLES=-DTHREADS=1 -DPORTABLE 21SET VARIABLES=-DTHREADS=%THREADS% -D%ARCH%
6SET OFLAGS=-O3 22SET OFLAGS=-O3
7SET DFLAGS=-g -fsanitize=address 23
8SET CFLAGS=-std=c11 %OFLAGS% %ARCH% %WARNINGS% %VARIABLES% 24SET CFLAGS=-std=c11 %ARCHOPTS% %WARNINGS% %VARIABLES%
9 25
10SET STACKSIZE=-Wl,-stack:16777216 26SET STACKSIZE=-Wl,-stack:16777216
11SET LFLAGS=%STACKSIZE% 27SET LFLAGS=%STACKSIZE%
12 28
13%COMPILER% %CFLAGS% -c src\nissy.c || exit /b 29:: Python libraries - change to match your local installation
14%COMPILER% %CFLAGS% %LFLAGS% nissy.o shell\shell.c -o run.exe || exit /b
15
16:: Python libraries - change to mathc your local installation
17SET PYPATH=%userprofile%\AppData\Local\Programs\Python\Python313 30SET PYPATH=%userprofile%\AppData\Local\Programs\Python\Python313
18SET PYINCLUDE=%PYPATH%\include 31SET PYINCLUDE=%PYPATH%\include
19SET PYLIBS=%PYPATH%\libs 32SET PYLIBS=%PYPATH%\libs
20 33
21%COMPILER% %CFLAGS% -I%PYINCLUDE% -L%PYLIBS% -shared -lpython3 python/nissy_module.c nissy.o -o nissy.pyd \ No newline at end of file 34SET TARGET=%1
35if not defined TARGET SET TARGET=nissy
36SET EXPR=%2
37for %%a in (nissy python shell test config help) do (
38 if %TARGET%==%%a (
39 call:build_%TARGET%
40 exit /b
41 )
42)
43
44echo Target '%TARGET%' unavailable, run 'build help' for info
45exit /b 1
46
47:build_help
48 echo *** Warning: support for building nissy on Windows is incomplete ***
49 echo.
50 echo Build system for nissy. Usage:
51 echo.
52 echo build [/d] [TARGET]
53 echo.
54 echo Possible values for TARGET (defaults to 'nissy' if unspecified):
55 echo.
56 echo nissy Build the nissy.o object file.
57 echo python Build the Python module for nissy.
58 echo shell Build the basic nissy shell (./run).
59 echo help Show this help message.
60 echo config Show build configuration and exit.
61 echo test [EXPR] Build and run unit tests. If EXPR is provided, only the
62 echo tests whose name contains EXPR are run. The /d option is
63 echo is always implied.
64 echo.
65 echo The /d option activates debug mode (slower, used for testing).
66 echo Tests are automatically built in debug mode even without /d.
67 echo For more on build configurations, see the comments in build.bat.
68exit /b
69
70:build_config
71 echo Compiler: %CC%
72 echo Architecture: %ARCH%
73 echo Max threads: %THREADS%
74 echo Optimization flags: %OFLAGS%
75 echo Debug flags: %DFLAGS%
76exit /b
77
78:build_nissy
79 call:odflags
80 @echo on
81 %CC% %CFLAGS% %ODFLAGS% -c src\nissy.c || exit /b 1
82 @echo off
83exit /b
84
85:build_shell
86 call:build_nissy || exit /b 1
87 call:odflags
88 @echo on
89 %CC% %CFLAGS% %ODFLAGS% %LFLAGS% nissy.o shell\shell.c -o run.exe ^
90 || exit /b 1
91 @echo off
92exit /b
93
94:build_python
95 call:build_nissy || exit /b 1
96 call:odflags
97 @echo on
98 %CC% %CFLAGS% %LFLAGS% -I%PYINCLUDE% -L%PYLIBS% -shared -lpython3 ^
99 python\nissy_module.c nissy.o -o python\nissy.pyd || exit /b 1
100 @echo off
101exit /b
102
103:build_test
104 SET DEBUG=1
105 call:build_nissy || exit /b 1
106 if not defined EXPR (
107 SET WILDCARD=*
108 ) else (
109 SET WILDCARD=*%EXPR%*
110 )
111 for /d %%d in ( test\%WILDCARD% ) do (
112 if exist %%d\* (
113 call:build_single_test %%d || exit /b 1
114 )
115 )
116exit /b
117
118:build_single_test
119 call:odflags
120 %CC% %CFLAGS% %ODFLAGS% %LFLAGS% nissy.o %1\*.c -o runtest.exe || exit /b 1
121 set error=0
122 for %%c in ( %1\*.in ) do (
123 if %error%==1 exit /b 1
124 @echo | set /p v="%1\%%~nc: "
125 runtest < %%c > test\last.out 2> test\last.err
126 FC /a %1\%%~nc.out test\last.out > test\last.fc.out
127 if ERRORLEVEL 1 (
128 @echo Test failed! Different output:
129 type test\last.fc.out
130 @echo stderr:
131 type test\last.err
132 goto :error
133 ) else (
134 @echo ok
135 )
136 )
137 if %error%==1 exit /b 1
138 del runtest.*
139exit /b
140
141:odflags
142 if %DEBUG%==1 (
143 SET ODFLAGS=%DFLAGS%
144 ) else (
145 SET ODFLAGS=%OFLAGS%
146 )
147exit /b
148
149:error
150 exit /b 1 \ No newline at end of file

Generated with cgit - Back to sebastiano.tronto.net