-
Notifications
You must be signed in to change notification settings - Fork 6
/
set-env.bat
215 lines (176 loc) · 5.61 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
@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
@REM if /i "%1" == "msvc10" goto :msvc10
@REM if /i "%1" == "msvc12" goto :msvc12
@REM if /i "%1" == "msvc14" goto :msvc14
@REM 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= x86
set CMAKE_ARCH_OPTIONS=-A Win32
shift
goto :loop
:amd64
set TARGET_CPU=amd64
set CMAKE_GENERATOR_SUFFIX=
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
shift
goto :loop
:msvc17
set TOOLCHAIN=msvc17
set MSVC_TOOLSET_VERSION=143
set CMAKE_GENERATOR=Visual Studio 17 2022
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_CMAKE_CONFIGURE_EXTRA_FLAGS=
set RUNTIME_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_CMAKE_CONFIGURE_EXTRA_FLAGS=-DLLVM_BUILD_TOOLS=OFF -DLLVM_ENABLE_ASSERTIONS=ON
set RUNTIME_CMAKE_CONFIGURE_EXTRA_FLAGS=
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%
if "%TARGET_CPU%" == "" goto :amd64
if "%TOOLCHAIN%" == "" goto :msvc17
if "%CRT%" == "" goto :libcmt
if "%CONFIGURATION%" == "" goto :release
set TAR_SUFFIX=
set BASE_DOWNLOAD_URL=https://github.com/llvm/llvm-project/releases/download/llvmorg-%LLVM_VERSION%
set LLVM_MASTER_URL=https://github.com/llvm/llvm-project
set LLVM_DOWNLOAD_FILE=llvm-project-%LLVM_VERSION%.src.tar.xz
set LLVM_DOWNLOAD_URL=%BASE_DOWNLOAD_URL%/%LLVM_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/c3lang/win-llvm/releases/download/%LLVM_RELEASE_TAG%/%LLVM_RELEASE_FILE%
set LLVM_CMAKE_CONFIGURE_FLAGS= ^
-G "%CMAKE_GENERATOR%%CMAKE_GENERATOR_SUFFIX%" ^
-Thost=x64 ^
-DCMAKE_INSTALL_PREFIX=%LLVM_RELEASE_DIR% ^
-DCMAKE_DISABLE_FIND_PACKAGE_LibXml2=TRUE ^
-DCMAKE_MSVC_RUNTIME_LIBRARY=%CMAKE_CRT% ^
-DCMAKE_MT=mt ^
-DLLVM_ENABLE_TERMINFO=OFF ^
-DLLVM_ENABLE_ZLIB=OFF ^
-DLLVM_INCLUDE_BENCHMARKS=OFF ^
-DLLVM_INCLUDE_DOCS=OFF ^
-DLLVM_ENABLE_PROJECTS=lld ^
-DLLVM_INCLUDE_EXAMPLES=OFF ^
-DLLVM_INCLUDE_RUNTIMES=OFF ^
-DLLVM_INCLUDE_TESTS=OFF ^
-DLLVM_INCLUDE_UTILS=OFF ^
%LLVM_CMAKE_CONFIGURE_EXTRA_FLAGS%
set RUNTIMES_CMAKE_CONFIGURE_FLAGS= ^
-G "%CMAKE_GENERATOR%%CMAKE_GENERATOR_SUFFIX%" ^
-Thost=x64 ^
-DCMAKE_INSTALL_PREFIX=%LLVM_RELEASE_DIR%/lib/clang/%LLVM_MAJOR_VERSION% ^
-DCMAKE_MSVC_RUNTIME_LIBRARY=%CMAKE_CRT% ^
-DCMAKE_MT=mt ^
-DCMAKE_C_COMPILER_TARGET="x86_64-pc-windows-msvc" ^
-DLLVM_ENABLE_RUNTIMES=compiler-rt ^
-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON ^
-DCOMPILER_RT_BUILD_BUILTINS=OFF ^
%RUNTIME_CMAKE_CONFIGURE_EXTRA_FLAGS%
set CMAKE_BUILD_FLAGS= ^
--config %CONFIGURATION% ^
-- ^
/nologo ^
/verbosity:minimal ^
/maxcpucount ^
/consoleloggerparameters:Summary
set DEPLOY_FILE=%LLVM_RELEASE_FILE%
echo ---------------------------------------------------------------------------
echo LLVM_VERSION: %LLVM_VERSION%
echo LLVM_MAJOR_VERSION: %LLVM_MAJOR_VERSION%
echo LLVM_MASTER_URL: %LLVM_MASTER_URL%
echo LLVM_DOWNLOAD_URL: %LLVM_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 RUNTIMES_CMAKE_CONFIGURE_FLAGS: %RUNTIMES_CMAKE_CONFIGURE_FLAGS%
echo ---------------------------------------------------------------------------
echo DEPLOY_FILE: %DEPLOY_FILE%
echo ---------------------------------------------------------------------------