blob: 223c3639117781fe6a4eb3bfdf261b894e6ee8df (
plain)
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
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
|
@echo off
rem file : build-msvc.bat
rem copyright : Copyright (c) 2014-2019 Code Synthesis Ltd
rem license : MIT; see accompanying LICENSE file
setlocal EnableDelayedExpansion
goto start
:usage
echo.
echo Usage: %0 [/?] [^<options^>] [^<cl-compiler^>]
echo Options:
echo --install-dir ^<dir^> Alternative installation directory.
echo --repo ^<loc^> Alternative package repository location.
echo --trust ^<fp^> Repository certificate fingerprint to trust.
echo --timeout ^<sec^> Network operations timeout in seconds.
echo --verbose ^<level^> Diagnostics verbosity level between 0 and 6.
echo.
echo By default the batch file will use cl.exe as the C++ compiler and install
echo into C:\build2. It also expects to find the base utilities in the bin\
echo subdirectory of the installation directory ^(C:\build2\bin\ by default^).
echo.
echo The --trust option recognizes two special values: 'yes' ^(trust everything^)
echo and 'no' (trust nothing).
echo.
echo See the BOOTSTRAP-MSVC file for details.
echo.
goto end
:start
set "owd=%CD%"
rem Package repository URL (or path).
rem
if "_%BUILD2_REPO%_" == "__" (
set "BUILD2_REPO=https://stage.build2.org/1"
rem set "BUILD2_REPO=https://pkg.cppget.org/1/queue/alpha"
rem set "BUILD2_REPO=https://pkg.cppget.org/1/alpha"
)
rem The bpkg configuration directory.
rem
set "cver=0.11-a.0"
set "cdir=build2-toolchain-%cver%"
rem Parse options.
rem
set "idir=C:\build2"
set "trust="
set "timeout="
set "verbose="
:options
if "_%~1_" == "_/?_" goto usage
if "_%~1_" == "_-h_" goto usage
if "_%~1_" == "_--help_" goto usage
if "_%~1_" == "_--install-dir_" (
if "_%~2_" == "__" (
echo error: installation directory expected after --install-dir
goto error
)
set "idir=%~2"
shift
shift
goto options
)
if "_%~1_" == "_--trust_" (
if "_%~2_" == "__" (
echo error: certificate fingerprint expected after --trust
goto error
)
set "trust=%~2"
shift
shift
goto options
)
if "_%~1_" == "_--repo_" (
if "_%~2_" == "__" (
echo error: repository location expected after --repo
goto error
)
set "BUILD2_REPO=%~2"
shift
shift
goto options
)
if "_%~1_" == "_--timeout_" (
if "_%~2_" == "__" (
echo error: value in seconds expected after --timeout
goto error
)
set "timeout=%~2"
shift
shift
goto options
)
if "_%~1_" == "_--verbose_" (
if "_%~2_" == "__" (
echo error: diagnostics level between 0 and 6 expected after --verbose
goto error
)
set "verbose=%~2"
shift
shift
goto options
)
if "_%~1_" == "_--_" shift
rem Validate options and arguments.
rem
rem @@ Temporarily retained for backwards compatibility.
rem
if not "_%1_" == "__" (
set "idir=%1"
)
if not "_%2_" == "__" (
set "trust=%2"
)
rem Compiler.
rem
rem if "_%1_" == "__" (
set "cxx=cl"
rem ) else (
rem set "cxx=%1"
rem )
rem Certificate to trust.
rem
if not "_%trust%_" == "__" (
if "_%trust%_" == "_yes_" (
set "trust=--trust-yes"
) else (
if "_%trust%_" == "_no_" (
set "trust=--trust-no"
) else (
set "trust=--trust %trust%"
)
)
)
rem Network timeout.
rem
if not "_%timeout%_" == "__" (
set "timeout=--fetch-timeout %timeout%"
)
rem Diagnostics verbosity.
rem
if not "_%verbose%_" == "__" (
set "verbose=--verbose %verbose%"
)
if not exist %idir%\bin\ (
echo error: %idir%\bin\ does not exist
goto error
)
if exist build\config.build (
echo error: current directory already configured, start with clean source
goto error
)
if exist ..\%cdir%\ (
echo error: ..\%cdir%\ bpkg configuration directory already exists, remove it
goto error
)
set "sdir=%idir%\stage"
set "PATH=%idir%\bin;%PATH%"
rem Show the steps we are performing.
rem
@echo on
@rem Verify the compiler works.
@rem
%cxx%
@if errorlevel 1 goto error
@rem Bootstrap.
@rem
cd build2
@rem Execute in a separate cmd.exe to preserve the echo mode.
@rem
cmd /C bootstrap-msvc.bat %cxx%
@if errorlevel 1 goto error
build2\b-boot --version
@if errorlevel 1 goto error
build2\b-boot %verbose% config.cxx=%cxx% config.bin.lib=static build2\exe{b}
@if errorlevel 1 goto error
move /y build2\b.exe build2\b-boot.exe
@if errorlevel 1 goto error
build2\b-boot --version
@if errorlevel 1 goto error
@rem Build and stage the build system and the package manager.
@rem
cd ..
build2\build2\b-boot %verbose% configure^
config.cxx=%cxx%^
config.bin.suffix=-stage^
config.install.root=%idir%^
config.install.data_root=root\stage
@if errorlevel 1 goto error
build2\build2\b-boot %verbose% install: build2\ bpkg\
@if errorlevel 1 goto error
where b-stage
@if errorlevel 1 goto error
where bpkg-stage
@if errorlevel 1 goto error
b-stage --version
@if errorlevel 1 goto error
bpkg-stage --version
@if errorlevel 1 goto error
@rem Build the entire toolchain from packages.
@rem
cd ..
md %cdir%
@if errorlevel 1 goto error
cd %cdir%
@rem Save full path for later.
@rem
@set "cdir=%CD%"
bpkg-stage %verbose% create^
cc^
config.cxx=%cxx%^
config.cc.coptions=/O2^
config.install.root=%idir%
@if errorlevel 1 goto error
bpkg-stage %verbose% add %BUILD2_REPO%
@if errorlevel 1 goto error
bpkg-stage %verbose% %timeout% %trust% fetch
@if errorlevel 1 goto error
bpkg-stage %verbose% %timeout% build --for install --yes --plan= build2 bpkg bdep
@if errorlevel 1 goto error
bpkg-stage %verbose% install build2 bpkg bdep
@if errorlevel 1 goto error
where b
@if errorlevel 1 goto error
where bpkg
@if errorlevel 1 goto error
where bdep
@if errorlevel 1 goto error
b --version
@if errorlevel 1 goto error
bpkg --version
@if errorlevel 1 goto error
bdep --version
@if errorlevel 1 goto error
@rem Clean up stage.
@rem
cd %owd%
b %verbose% uninstall: build2/ bpkg/
@if errorlevel 1 goto error
@echo off
echo.
echo Toolchain installation: %idir%\bin
echo Upgrade configuration: %cdir%
echo.
goto end
:error
@echo off
cd %owd%
endlocal
exit /b 1
:end
endlocal
|