aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2025-08-13 16:38:21 +0100
committerSebastiano Tronto <sebastiano@tronto.net>2025-08-13 16:38:21 +0100
commit9b94c7d039341afb8609075da0ce52a7a7aa705a (patch)
treeddfc26411eed421a03870e163e62e24d6ff2961a
parentc368c0f4aa0a810f5102cb8958e57410e572afa8 (diff)
downloadnissy-core-9b94c7d039341afb8609075da0ce52a7a7aa705a.tar.gz
nissy-core-9b94c7d039341afb8609075da0ce52a7a7aa705a.zip
More build.bat options
Diffstat (limited to '')
-rw-r--r--.gitignore1
-rw-r--r--build.bat75
-rw-r--r--tools/tool.h36
3 files changed, 108 insertions, 4 deletions
diff --git a/.gitignore b/.gitignore
index 322ebb5..de7c8b6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -39,6 +39,7 @@ tools/results
39*.pyd 39*.pyd
40*.dll 40*.dll
41*.exp 41*.exp
42*.exe
42*.lib 43*.lib
43*.pdb 44*.pdb
44*.ilk 45*.ilk
diff --git a/build.bat b/build.bat
index 6a3133e..d86c8b5 100644
--- a/build.bat
+++ b/build.bat
@@ -8,6 +8,7 @@ if [%1]==[/d] (
8) 8)
9 9
10SET CC=clang 10SET CC=clang
11SET CXX=clang++
11SET ARCH=PORTABLE 12SET ARCH=PORTABLE
12SET THREADS=1 13SET THREADS=1
13SET SANITIZE= 14SET SANITIZE=
@@ -34,9 +35,9 @@ SET PYLIBS=%PYPATH%\libs
34SET TARGET=%1 35SET TARGET=%1
35if not defined TARGET SET TARGET=nissy 36if not defined TARGET SET TARGET=nissy
36SET EXPR=%2 37SET EXPR=%2
37for %%a in (nissy python shell test config help) do ( 38for %%a in (nissy python shell test config help clean tool cpp solvetest) do (
38 if %TARGET%==%%a ( 39 if %TARGET%==%%a (
39 call:build_%TARGET% 40 call:build_%TARGET% %*
40 exit /b 41 exit /b
41 ) 42 )
42) 43)
@@ -56,11 +57,16 @@ exit /b 1
56 echo nissy Build the nissy.o object file. 57 echo nissy Build the nissy.o object file.
57 echo python Build the Python module for nissy. 58 echo python Build the Python module for nissy.
58 echo shell Build the basic nissy shell (./run). 59 echo shell Build the basic nissy shell (./run).
59 echo help Show this help message. 60 echo cpp FILE Build and run the given C++ FILE.
60 echo config Show build configuration and exit.
61 echo test [EXPR] Build and run unit tests. If EXPR is provided, only the 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 62 echo tests whose name contains EXPR are run. The /d option is
63 echo is always implied. 63 echo is always implied.
64 echo tool EXPR Run the 'tool' matching the given EXPR.
65 echo solvetest Build nissy and run a collection of tools for testing"
66 echo various solvers.
67 echo help Show this help message.
68 echo config Show build configuration and exit.
69 echo clean Remove all build files.
64 echo. 70 echo.
65 echo The /d option activates debug mode (slower, used for testing). 71 echo The /d option activates debug mode (slower, used for testing).
66 echo Tests are automatically built in debug mode even without /d. 72 echo Tests are automatically built in debug mode even without /d.
@@ -115,6 +121,57 @@ exit /b
115 ) 121 )
116exit /b 122exit /b
117 123
124:build_clean
125 @echo on
126 del *.o *.so *.a *.ilk *.pdb *.exe
127 @echo off
128exit /b
129
130:build_tool
131 if not defined EXPR (
132 @echo Please provide a valid EXPR to select a tool
133 exit /b 1
134 )
135
136 set toolname=
137 for /d %%d in ( tools\*%EXPR%* ) do (
138 set toolname=%%~nd
139 )
140
141 if [%toolname%]==[] (
142 @echo Expression '%EXPR%' does not match any tool
143 exit /b 1
144 )
145
146 call:build_nissy || exit /b 1
147 call:build_single_tool %*
148exit /b
149
150:build_cpp
151 if not defined EXPR (
152 @echo Please provide a valid C++ source file.
153 exit /b 1
154 )
155 if not exist %EXPR% (
156 @echo File %EXPR% does not exist.
157 exit /b 1
158 )
159 call:build_nissy || exit /b 1
160 @echo on
161 %CXX% %ODFLAGS% -std=c++20 -o runcpp.exe cpp\nissy.cpp nissy.o %EXPR% ^
162 || exit /b 1
163 runcpp
164 @echo off
165exit /b
166
167:build_solvetest
168 call:build_nissy || exit /b 1
169 for /d %%d in ( tools\*solvetest* ) do (
170 set toolname=%%~nd
171 call:build_single_tool
172 )
173exit /b
174
118:build_single_test 175:build_single_test
119 call:odflags 176 call:odflags
120 %CC% %CFLAGS% %ODFLAGS% %LFLAGS% nissy.o %1\*.c -o runtest.exe || exit /b 1 177 %CC% %CFLAGS% %ODFLAGS% %LFLAGS% nissy.o %1\*.c -o runtest.exe || exit /b 1
@@ -138,6 +195,16 @@ exit /b
138 del runtest.* 195 del runtest.*
139exit /b 196exit /b
140 197
198:build_single_tool
199 @echo on
200 %CC% %CFLAGS% %ODFLAGS% %LFLAGS% nissy.o tools\%toolname%\*.c ^
201 -o runtool.exe || exit /b 1
202 @echo off
203 runtool %3 %4 %5 %6 %7 %8 %9 || exit /b 1
204 @echo.
205 @echo (On Windows, the output of a tool is not saved to any file.)
206exit /b
207
141:odflags 208:odflags
142 if %DEBUG%==1 ( 209 if %DEBUG%==1 (
143 SET ODFLAGS=%DFLAGS% 210 SET ODFLAGS=%DFLAGS%
diff --git a/tools/tool.h b/tools/tool.h
index 47155c2..c6fafbc 100644
--- a/tools/tool.h
+++ b/tools/tool.h
@@ -22,6 +22,40 @@ log_stderr(const char *str, void *unused)
22 fprintf(stderr, "%s", str); 22 fprintf(stderr, "%s", str);
23} 23}
24 24
25#ifdef _WIN32
26
27#include <windows.h>
28
29static double
30timerun(void (*run)(void))
31{
32 LARGE_INTEGER freq, start, end;
33 double tdiff;
34
35 fflush(stdout);
36
37 if (run == NULL) {
38 printf("nothing to run!\n");
39 fflush(stdout);
40 return -1.0;
41 }
42
43 QueryPerformanceFrequency(&freq);
44 QueryPerformanceCounter(&start);
45 run();
46 QueryPerformanceCounter(&end);
47
48 tdiff = (double)(end.QuadPart - start.QuadPart) / freq.QuadPart;
49
50 printf("---------\n");
51 printf("\nTotal time: %.4fs\n", tdiff);
52 fflush(stdout);
53
54 return tdiff;
55}
56
57#else
58
25static double 59static double
26timerun(void (*run)(void)) 60timerun(void (*run)(void))
27{ 61{
@@ -51,6 +85,8 @@ timerun(void (*run)(void))
51 return tdiff; 85 return tdiff;
52} 86}
53 87
88#endif
89
54static void 90static void
55writetable(const unsigned char *buf, int64_t size, const char *filename) 91writetable(const unsigned char *buf, int64_t size, const char *filename)
56{ 92{

Generated with cgit - Back to sebastiano.tronto.net