-
Notifications
You must be signed in to change notification settings - Fork 20
/
set-env.bat
282 lines (231 loc) · 8.5 KB
/
set-env.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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
@echo off
:: Reset and loop over arguments
set TARGET_CPU=
set TOOLCHAIN=
set CRT=
set CONFIGURATION=
:loop
if "%1" == "" goto :finalize
if /i "%1" == "x86" goto :x86
if /i "%1" == "i386" goto :x86
if /i "%1" == "amd64" goto :amd64
if /i "%1" == "x86_64" goto :amd64
if /i "%1" == "x64" goto :amd64
if /i "%1" == "msvc10" goto :msvc10
if /i "%1" == "msvc12" goto :msvc12
if /i "%1" == "msvc14" goto :msvc14
if /i "%1" == "msvc15" goto :msvc15
if /i "%1" == "msvc16" goto :msvc16
if /i "%1" == "msvc17" goto :msvc17
if /i "%1" == "libcmt" goto :libcmt
if /i "%1" == "msvcrt" goto :msvcrt
if /i "%1" == "dbg" goto :dbg
if /i "%1" == "debug" goto :dbg
if /i "%1" == "rel" goto :release
if /i "%1" == "release" goto :release
echo Invalid argument: '%1'
exit -1
:: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
:: Platform
:x86
set TARGET_CPU=x86
set CMAKE_GENERATOR_SUFFIX=
set CMAKE_ARCH_OPTIONS=-A Win32
shift
goto :loop
:amd64
set TARGET_CPU=amd64
set CMAKE_GENERATOR_SUFFIX= Win64
set CMAKE_ARCH_OPTIONS=-A x64
shift
goto :loop
:: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
:: Toolchain
:msvc10
set TOOLCHAIN=msvc10
set CMAKE_GENERATOR=Visual Studio 10 2010
shift
goto :loop
:msvc12
set TOOLCHAIN=msvc12
set CMAKE_GENERATOR=Visual Studio 12 2013
shift
goto :loop
:msvc14
set TOOLCHAIN=msvc14
set CMAKE_GENERATOR=Visual Studio 14 2015
shift
goto :loop
:msvc15
set TOOLCHAIN=msvc15
set CMAKE_GENERATOR=Visual Studio 15 2017
shift
goto :loop
:msvc16
set TOOLCHAIN=msvc16
set CMAKE_GENERATOR=Visual Studio 16 2019
set CMAKE_USE_ARCH_OPTIONS=true
shift
goto :loop
:msvc17
set TOOLCHAIN=msvc17
set CMAKE_GENERATOR=Visual Studio 17 2022
set CMAKE_USE_ARCH_OPTIONS=true
shift
goto :loop
:: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
:: CRT
:libcmt
set CRT=libcmt
set LLVM_CRT=MT
set CMAKE_CRT="MultiThreaded$<$<CONFIG:Debug>:Debug>"
shift
goto :loop
:msvcrt
set CRT=msvcrt
set LLVM_CRT=MD
set CMAKE_CRT="MultiThreaded$<$<CONFIG:Debug>:Debug>DLL"
shift
goto :loop
:: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
:: Configuration
:release
set CONFIGURATION=Release
set DEBUG_SUFFIX=
set LLVM_TARGETS=X86;NVPTX;AMDGPU
set LLVM_CMAKE_CONFIGURE_EXTRA_FLAGS=
set CLANG_CMAKE_CONFIGURE_EXTRA_FLAGS=
shift
goto :loop
:: don't try to build Debug tools -- executables will be huge and not really
:: essential (whoever needs tools, can just download a Release build)
:dbg
set CONFIGURATION=Debug
set DEBUG_SUFFIX=-dbg
set LLVM_TARGETS=X86
set LLVM_CMAKE_CONFIGURE_EXTRA_FLAGS=-DLLVM_BUILD_TOOLS=OFF
set CLANG_CMAKE_CONFIGURE_EXTRA_FLAGS=-DCLANG_BUILD_TOOLS=OFF
shift
goto :loop
::..............................................................................
:finalize
set WORKING_DRIVE=%HOMEDRIVE%
set WORKING_DIR=%HOMEDRIVE%%HOMEPATH%
set LLVM_RELEASE_TAG=llvm-%LLVM_VERSION%
set LLVM_CMAKELISTS_URL=https://raw.githubusercontent.com/llvm/llvm-project/main/llvm/CMakeLists.txt
if /i "%BUILD_MASTER%" == "true" (
powershell "Invoke-WebRequest -Uri %LLVM_CMAKELISTS_URL% -OutFile CMakeLists.txt"
for /f %%i in ('perl print-llvm-version.pl CMakeLists.txt') do set LLVM_VERSION=%%i
set LLVM_RELEASE_TAG=llvm-master
)
if "%TARGET_CPU%" == "" goto :amd64
if "%TOOLCHAIN%" == "" goto :msvc14
if "%CRT%" == "" goto :libcmt
if "%CONFIGURATION%" == "" goto :release
if "%CMAKE_USE_ARCH_OPTIONS%" == "" (set CMAKE_GENERATOR=%CMAKE_GENERATOR%%CMAKE_ARCH_SUFFIX%)
if not "%CMAKE_USE_ARCH_OPTIONS%" == "" (set CMAKE_OPTIONS=%CMAKE_OPTIONS%%CMAKE_ARCH_OPTIONS%)
set TAR_SUFFIX=.tar.xz
perl compare-versions.pl %LLVM_VERSION% 3.5.0
if %errorlevel% == -1 set TAR_SUFFIX=.tar.gz
set BASE_DOWNLOAD_URL=https://github.com/llvm/llvm-project/releases/download/llvmorg-%LLVM_VERSION%
set BASE_DOWNLOAD_URL_LEGACY=http://releases.llvm.org/%LLVM_VERSION%
perl compare-versions.pl %LLVM_VERSION% 7.1.0
if %errorlevel% == -1 set BASE_DOWNLOAD_URL=%BASE_DOWNLOAD_URL_LEGACY%
:: exceptions: 8.0.0, 9.0.0 are still hosted on llvm.org
if %LLVM_VERSION% == 8.0.0 set BASE_DOWNLOAD_URL=%BASE_DOWNLOAD_URL_LEGACY%
if %LLVM_VERSION% == 9.0.0 set BASE_DOWNLOAD_URL=%BASE_DOWNLOAD_URL_LEGACY%
set CLANG_DOWNLOAD_FILE_PREFIX=clang-
perl compare-versions.pl %LLVM_VERSION% 9.0.0
if %errorlevel% == -1 set CLANG_DOWNLOAD_FILE_PREFIX=cfe-
set LLVM_MASTER_URL=https://github.com/llvm/llvm-project
set LLVM_DOWNLOAD_FILE=llvm-%LLVM_VERSION%.src%TAR_SUFFIX%
set LLVM_DOWNLOAD_URL=%BASE_DOWNLOAD_URL%/%LLVM_DOWNLOAD_FILE%
set LLVM_CMAKE_DOWNLOAD_FILE=cmake-%LLVM_VERSION%.src%TAR_SUFFIX%
set LLVM_CMAKE_DOWNLOAD_URL=%BASE_DOWNLOAD_URL%/%LLVM_CMAKE_DOWNLOAD_FILE%
set LLVM_RELEASE_NAME=llvm-%LLVM_VERSION%-windows-%TARGET_CPU%-%TOOLCHAIN%-%CRT%%DEBUG_SUFFIX%
set LLVM_RELEASE_FILE=%LLVM_RELEASE_NAME%.7z
set LLVM_RELEASE_DIR=%WORKING_DIR%\%LLVM_RELEASE_NAME%
set LLVM_RELEASE_DIR=%LLVM_RELEASE_DIR:\=/%
set LLVM_RELEASE_URL=https://github.com/vovkos/llvm-package-windows/releases/download/%LLVM_RELEASE_TAG%/%LLVM_RELEASE_FILE%
perl compare-versions.pl %LLVM_VERSION% 15.0.0
if %errorlevel% == -1 set LLVM_CMAKE_DOWNLOAD_URL=
set LLVM_CMAKE_CRT_FLAGS= -DCMAKE_MSVC_RUNTIME_LIBRARY=%CMAKE_CRT%
perl compare-versions.pl %LLVM_VERSION% 17.0.0
if %errorlevel% == -1 set LLVM_CMAKE_CRT_FLAGS= ^
-DLLVM_USE_CRT_DEBUG=%LLVM_CRT%d ^
-DLLVM_USE_CRT_RELEASE=%LLVM_CRT% ^
-DLLVM_USE_CRT_MINSIZEREL=%LLVM_CRT% ^
-DLLVM_USE_CRT_RELWITHDEBINFO=%LLVM_CRT%
set LLVM_CMAKE_CONFIGURE_FLAGS= ^
-G "%CMAKE_GENERATOR%" ^
%CMAKE_OPTIONS% ^
-Thost=x64 ^
-DCMAKE_INSTALL_PREFIX=%LLVM_RELEASE_DIR% ^
-DCMAKE_DISABLE_FIND_PACKAGE_LibXml2=TRUE ^
-DLLVM_TARGETS_TO_BUILD=%LLVM_TARGETS% ^
-DLLVM_ENABLE_TERMINFO=OFF ^
-DLLVM_ENABLE_ZLIB=OFF ^
-DLLVM_INCLUDE_BENCHMARKS=OFF ^
-DLLVM_INCLUDE_DOCS=OFF ^
-DLLVM_INCLUDE_EXAMPLES=OFF ^
-DLLVM_INCLUDE_GO_TESTS=OFF ^
-DLLVM_INCLUDE_RUNTIMES=OFF ^
-DLLVM_INCLUDE_TESTS=OFF ^
-DLLVM_INCLUDE_UTILS=OFF ^
-DLLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN=ON ^
%LLVM_CMAKE_CRT_FLAGS% ^
%LLVM_CMAKE_CONFIGURE_EXTRA_FLAGS%
:: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
set CLANG_MASTER_URL=https://github.com/llvm-mirror/clang
set CLANG_DOWNLOAD_FILE=%CLANG_DOWNLOAD_FILE_PREFIX%%LLVM_VERSION%.src%TAR_SUFFIX%
set CLANG_DOWNLOAD_URL=%BASE_DOWNLOAD_URL%/%CLANG_DOWNLOAD_FILE%
set CLANG_RELEASE_NAME=clang-%LLVM_VERSION%-windows-%TARGET_CPU%-%TOOLCHAIN%-%CRT%%DEBUG_SUFFIX%
set CLANG_RELEASE_FILE=%CLANG_RELEASE_NAME%.7z
set CLANG_RELEASE_DIR=%WORKING_DIR%\%CLANG_RELEASE_NAME%
set CLANG_RELEASE_DIR=%CLANG_RELEASE_DIR:\=/%
set CLANG_CMAKE_CONFIGURE_FLAGS= ^
-G "%CMAKE_GENERATOR%" ^
%CMAKE_OPTIONS% ^
-DCMAKE_INSTALL_PREFIX=%CLANG_RELEASE_DIR% ^
-DCMAKE_DISABLE_FIND_PACKAGE_LibXml2=TRUE ^
-DLLVM_INCLUDE_TESTS=OFF ^
-DLLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN=ON ^
-DCLANG_INCLUDE_DOCS=OFF ^
-DCLANG_INCLUDE_TESTS=OFF ^
-DLLVM_DIR=%LLVM_RELEASE_DIR%/lib/cmake/llvm ^
%LLVM_CMAKE_CRT_FLAGS% ^
%CLANG_CMAKE_CONFIGURE_EXTRA_FLAGS%
:: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
perl compare-versions.pl %LLVM_VERSION% 8.0.0
if %errorlevel% == -1 set CLANG_CMAKE_CONFIGURE_FLAGS= ^
%CLANG_CMAKE_CONFIGURE_FLAGS% ^
-DCLANG_PATH_TO_LLVM_BUILD=%LLVM_RELEASE_DIR% ^
-DLLVM_MAIN_SRC_DIR=%LLVM_RELEASE_DIR%
perl compare-versions.pl %LLVM_VERSION% 3.5.0
if %errorlevel% == -1 set CLANG_CMAKE_CONFIGURE_FLAGS= ^
%CLANG_CMAKE_CONFIGURE_FLAGS% ^
-DLLVM_CONFIG=%LLVM_RELEASE_DIR%/bin/llvm-config
set CMAKE_BUILD_FLAGS= ^
--config %CONFIGURATION% ^
-- ^
/nologo ^
/verbosity:minimal ^
/maxcpucount ^
/consoleloggerparameters:Summary
if /i "%BUILD_PROJECT%" == "llvm" set DEPLOY_FILE=%LLVM_RELEASE_FILE%
if /i "%BUILD_PROJECT%" == "clang" set DEPLOY_FILE=%CLANG_RELEASE_FILE%
echo ---------------------------------------------------------------------------
echo LLVM_VERSION: %LLVM_VERSION%
echo LLVM_MASTER_URL: %LLVM_MASTER_URL%
echo LLVM_DOWNLOAD_URL: %LLVM_DOWNLOAD_URL%
echo LLVM_CMAKE_DOWNLOAD_URL: %LLVM_CMAKE_DOWNLOAD_URL%
echo LLVM_RELEASE_FILE: %LLVM_RELEASE_FILE%
echo LLVM_RELEASE_URL: %LLVM_RELEASE_URL%
echo LLVM_CMAKE_CONFIGURE_FLAGS: %LLVM_CMAKE_CONFIGURE_FLAGS%
echo ---------------------------------------------------------------------------
echo CLANG_DOWNLOAD_URL: %CLANG_DOWNLOAD_URL%
echo CLANG_RELEASE_FILE: %CLANG_RELEASE_FILE%
echo CLANG_CMAKE_CONFIGURE_FLAGS: %CLANG_CMAKE_CONFIGURE_FLAGS%
echo ---------------------------------------------------------------------------
echo DEPLOY_FILE: %DEPLOY_FILE%
echo ---------------------------------------------------------------------------