-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathmake.bat
210 lines (181 loc) · 5.07 KB
/
make.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
::
:: This file is a part of Tiny-Shading-Language or TSL, an open-source cross
:: platform programming shading language.
::
:: Copyright (c) 2020-2020 by Jiayin Cao - All rights reserved.
::
:: TSL is a free software written for educational purpose. Anyone can distribute
:: or modify it under the the terms of the GNU General Public License Version 3 as
:: published by the Free Software Foundation. However, there is NO warranty that
:: all components are functional in a perfect manner. Without even the implied
:: warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
:: General Public License for more details.
::
:: You should have received a copy of the GNU General Public License along with
:: this program. If not, see <http://www.gnu.org/licenses/gpl-3.0.html>.
::
@echo off
set TSL_DIR=%~dp0
rem reset all variables first
set CLEAN=
set BUILD_RELEASE=
set BUILD_DEBUG=
set GENERATE_PROJ=
set UPDATE_DEP=
set FORCE_UPDATE_DEP=
set CLEAN_DEP=
set UPDATE=
set GENERATE_SRC=
set UNIT_TEST=
set FULL=
set INSTALL=
set VERIFY_BUILDS=
set RESOLVED_INSTALL_PATH="./tsl"
rem parse arguments
:argv_loop
if NOT "%1" == "" (
if "%1" == "clean" (
set CLEAN=1
goto EOF
)else if "%1" == "update" (
set UPDATE=1
goto EOF
)else if "%1" == "clean_dep" (
set CLEAN_DEP=1
goto EOF
)else if "%1" == "update_dep" (
set UPDATE_DEP=1
goto EOF
)else if "%1" == "force_update_dep" (
set FORCE_UPDATE_DEP=1
goto EOF
)else if "%1" == "generate_src" (
set GENERATE_SRC=1
goto EOF
)else if "%1" == "generate_proj" (
set GENERATE_PROJ=1
goto EOF
)else if "%1" == "release" (
set BUILD_RELEASE=1
goto EOF
)else if "%1" == "debug" (
set BUILD_DEBUG=1
goto EOF
)else if "%1" == "test" (
set UNIT_TEST=1
goto EOF
)else if "%1" == "full" (
set FULL=1
goto EOF
)else if "%1" == "install" (
set INSTALL=1
if "%2" == "INSTALL_PATH" (
set RESOLVED_INSTALL_PATH=%3
)
goto EOF
)else if "%1" == "verify_builds" (
set VERIFY_BUILDS=1
goto EOF
)else (
echo Unrecognized Command
goto EOF
)
)else if "%1" == "" (
set BUILD_RELEASE=1
goto EOF
)
:EOF
if "%CLEAN%" == "1" (
echo [33mCleaning all temporary file[0m
powershell Remove-Item -path ./bin -recurse -ErrorAction Ignore
powershell Remove-Item -path ./generated_src -recurse -ErrorAction Ignore
powershell Remove-Item -path ./proj_release -recurse -ErrorAction Ignore
powershell Remove-Item -path ./proj_debug -recurse -ErrorAction Ignore
powershell Remove-Item -path ./_out -recurse -ErrorAction Ignore
goto EOF
)
if "%CLEAN_DEP%" == "1" (
echo [33mCleaning all dependencies file[0m
powershell Remove-Item -path ./dependencies -recurse -ErrorAction Ignore
goto EOF
)
if "%UPDATE_DEP%" == "1" (
echo [33mDownloading dependencies[0m
py .\scripts\get_dependencies.py
goto EOF
)
if "%FORCE_UPDATE_DEP%" == "1" (
echo [33mDownloading dependencies[0m
py .\scripts\get_dependencies.py TRUE
goto EOF
)
if "%UPDATE%" == "1" (
echo [33mSycning latest code[0m
git pull
goto EOF
)
if "%BUILD_RELEASE%" == "1" (
echo [33mBuilding release[0m
py .\scripts\get_dependencies.py
powershell New-Item -Force -ItemType directory -Path proj_release
cd proj_release
cmake -A x64 ..
msbuild /p:Configuration=Release TSL.sln
:: catch msbuild error
if ERRORLEVEL 1 (
goto BUILD_ERR
)
cd ..
)
if "%BUILD_DEBUG%" == "1" (
echo [33mBuilding debug[0m
py .\scripts\get_dependencies.py
powershell New-Item -Force -ItemType directory -Path proj_debug
cd proj_debug
cmake -A x64 ..
msbuild /p:Configuration=Debug TSL.sln
:: catch msbuild error
if ERRORLEVEL 1 (
goto BUILD_ERR
)
cd ..
)
if "%GENERATE_PROJ%" == "1" (
echo [33mGenerating Visual Studio Project[0m
powershell New-Item -Force -ItemType directory -Path _out
cd _out
cmake -A x64 ..
cd ..
)
if "%GENERATE_SRC%" == "1" (
echo [33mGenerating flex and bison source code[0m
powershell Remove-Item -path ./generated_src -recurse -ErrorAction Ignore
mkdir generated_src
.\dependencies\flex_bison\win_bison.exe -d .\src\tsl_lib\compiler\grammar.y -o .\generated_src\compiled_grammar.cpp
.\dependencies\flex_bison\win_flex.exe .\src\tsl_lib\compiler\lex.l
)
if "%UNIT_TEST%" == "1" (
echo [33mRunning unit tests[0m
.\bin\tsl_test_r.exe
.\bin\llvm_test_r.exe
)
if "%FULL%" == "1" (
make update
make clean
make
make test
)
if "%INSTALL%" == "1" (
echo [33mBuild and install TSL[0m
echo Install Path: %RESOLVED_INSTALL_PATH%
make
cmake -DCMAKE_INSTALL_PREFIX=%RESOLVED_INSTALL_PATH% -P ./proj_release/cmake_install.cmake
)
if "%VERIFY_BUILDS%" == "1" (
echo [33mVerifying builds[0m
py .\scripts\verify_builds.py
)
:EOF
exit /b 0
:BUILD_ERR
exit /b 1