diff options
Diffstat (limited to '')
| -rw-r--r-- | build.bat | 75 |
1 files changed, 71 insertions, 4 deletions
| @@ -8,6 +8,7 @@ if [%1]==[/d] ( | |||
| 8 | ) | 8 | ) |
| 9 | 9 | ||
| 10 | SET CC=clang | 10 | SET CC=clang |
| 11 | SET CXX=clang++ | ||
| 11 | SET ARCH=PORTABLE | 12 | SET ARCH=PORTABLE |
| 12 | SET THREADS=1 | 13 | SET THREADS=1 |
| 13 | SET SANITIZE= | 14 | SET SANITIZE= |
| @@ -34,9 +35,9 @@ SET PYLIBS=%PYPATH%\libs | |||
| 34 | SET TARGET=%1 | 35 | SET TARGET=%1 |
| 35 | if not defined TARGET SET TARGET=nissy | 36 | if not defined TARGET SET TARGET=nissy |
| 36 | SET EXPR=%2 | 37 | SET EXPR=%2 |
| 37 | for %%a in (nissy python shell test config help) do ( | 38 | for %%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 | ) |
| 116 | exit /b | 122 | exit /b |
| 117 | 123 | ||
| 124 | :build_clean | ||
| 125 | @echo on | ||
| 126 | del *.o *.so *.a *.ilk *.pdb *.exe | ||
| 127 | @echo off | ||
| 128 | exit /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 %* | ||
| 148 | exit /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 | ||
| 165 | exit /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 | ) | ||
| 173 | exit /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.* |
| 139 | exit /b | 196 | exit /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.) | ||
| 206 | exit /b | ||
| 207 | |||
| 141 | :odflags | 208 | :odflags |
| 142 | if %DEBUG%==1 ( | 209 | if %DEBUG%==1 ( |
| 143 | SET ODFLAGS=%DFLAGS% | 210 | SET ODFLAGS=%DFLAGS% |
