aboutsummaryrefslogtreecommitdiff
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
parent1562c2e8ef10e25973317c790c2779e9d595e5f1 (diff)
downloadnissy-core-c368c0f4aa0a810f5102cb8958e57410e572afa8.tar.gz
nissy-core-c368c0f4aa0a810f5102cb8958e57410e572afa8.zip
Improvements to build.bat (unit tests on Windows)
Diffstat (limited to '')
-rw-r--r--.gitignore6
-rw-r--r--README.md24
-rw-r--r--build.bat149
-rw-r--r--test/test.h1
4 files changed, 160 insertions, 20 deletions
diff --git a/.gitignore b/.gitignore
index 38d22f8..322ebb5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,8 +11,6 @@ perf.data.old
11run 11run
12run.exe 12run.exe
13debugrun 13debugrun
14shell/lasttest.out
15shell/lasttest.err
16tables/* 14tables/*
17test/*/runtest 15test/*/runtest
18test/.DS_Store 16test/.DS_Store
@@ -43,3 +41,7 @@ tools/results
43*.exp 41*.exp
44*.lib 42*.lib
45*.pdb 43*.pdb
44*.ilk
45python/*.pyd
46python/*.exp
47python/*.lib
diff --git a/README.md b/README.md
index 3455ccd..7e206a1 100644
--- a/README.md
+++ b/README.md
@@ -48,15 +48,25 @@ the "C++ development" pack, as well as the "clang" and "Windows SDK 11"
48components. It is advised to use "x64 Native Tools Command Prompt for 48components. It is advised to use "x64 Native Tools Command Prompt for
49VS 2022" instead of a regular command prompt to run the build script. 49VS 2022" instead of a regular command prompt to run the build script.
50 50
51The `build.bat` script is going to build: 51The `build.bat` script has the same syntax as the `build.sh` script,
52but not all options are available. For example
52 53
53* The core nissy library 54```
54* The shell `run.exe` (see below) 55> build.bat shell
55* The Python module (see below) 56```
57
58can be used to build the basic shell, while
59
60```
61> build.bat test
62```
63
64Builds and runs the unit tests. See `build.bat help` for a list of
65all available options.
56 66
57All other options are unavailable. Moreover, Windows build will not 67Not: At the moment certain optimizations, such as multithreading and
58enable certain optimizations, such as multithreading and advanced CPU 68advanced CPU instructions, are not supported on Windows.
59instructions. Work is ongoing to improve Windows support. 69Work is ongoing to improve Windows support.
60 70
61## Running tests 71## Running tests
62 72
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
diff --git a/test/test.h b/test/test.h
index 703447b..60e340f 100644
--- a/test/test.h
+++ b/test/test.h
@@ -1,7 +1,6 @@
1#define TEST_H 1#define TEST_H
2 2
3#include <inttypes.h> 3#include <inttypes.h>
4#include <pthread.h>
5#include <stdarg.h> 4#include <stdarg.h>
6#include <stdbool.h> 5#include <stdbool.h>
7#include <stdio.h> 6#include <stdio.h>

Generated with cgit - Back to sebastiano.tronto.net