-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathbuild_windows.bat
71 lines (63 loc) · 1.61 KB
/
build_windows.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
@echo off
setlocal enabledelayedexpansion
set CLEAN_BUILD=NO
set BUILD_TEST=false
set EXAMPLE_NAME=
REM Parse command line args as a single string
for /f "delims=" %%a in ("%*") do (
set "params=%%a"
)
echo !params!
REM Split string by spaces manually
for %%a in (!params!) do (
set "para=%%a"
if "%%a"=="--clean" (
set CLEAN_BUILD=YES
) else if "%%a"=="--test" (
set BUILD_TEST=true
) else if "!para:~0,9!"=="--example" (
REM Assuming that the next parameter is the example name
set nextIsExampleName=true
) else (
if defined nextIsExampleName (
set EXAMPLE_NAME=%%a
set nextIsExampleName=
) else (
echo Unknown option %%a
exit /b 1
)
)
)
if "%CLEAN_BUILD%"=="YES" (
rmdir /S /Q build
echo Removed build directory
exit /b 0
)
if not exist build mkdir build
cd build
cmake .. -DBUILD_TEST=%BUILD_TEST% -DEXAMPLE_NAME=%EXAMPLE_NAME% -DPLATFORM_NAME="windows"
cmake --build . --config Release -j 7
REM Define the source and target directories
set TARGET_DIR=./Release
REM Check if *.dll exists in the target directory
if not exist "%TARGET_DIR%/taichi_c_api.dll" (
copy "..\dependencies\taichi_c_api\bin\Windows\x86_64_vc22\taichi_c_api.dll" "%TARGET_DIR%"
)
if not exist "%TARGET_DIR%/soft2d.dll" (
copy "..\soft2d\bin\Windows\x86_64_vc22\soft2d.dll" "%TARGET_DIR%"
)
if "%errorlevel%"=="0" (
if "%BUILD_TEST%"=="true" (
echo Running tests
.\Release\tests
) else (
if "%EXAMPLE_NAME%"=="" (
set EXAMPLE_NAME="body_minimal"
)
echo .\Release\!EXAMPLE_NAME!
.\Release\!EXAMPLE_NAME!
)
) else (
echo Building failed!
exit /b 1
)