• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1@ECHO OFF
2
3REM ~ Copyright 2002-2007 Rene Rivera.
4REM ~ Distributed under the Boost Software License, Version 1.0.
5REM ~ (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
6
7setlocal
8goto Start
9
10
11:Set_Error
12color 00
13goto :eof
14
15
16:Clear_Error
17ver >nul
18goto :eof
19
20
21:Error_Print
22REM Output an error message and set the errorlevel to indicate failure.
23setlocal
24ECHO ###
25ECHO ### %1
26ECHO ###
27ECHO ### You can specify the toolset as the argument, i.e.:
28ECHO ###     .\build.bat msvc
29ECHO ###
30ECHO ### Toolsets supported by this script are: borland, como, gcc,
31ECHO ###     gcc-nocygwin, intel-win32, metrowerks, mingw,
32ECHO ###     vc12, vc14, vc141, vc142
33ECHO ###
34ECHO ### If you have Visual Studio 2017 installed you will need to either update
35ECHO ### the Visual Studio 2017 installer or run from VS 2017 Command Prompt
36ECHO ### as we where unable to detect your toolset installation.
37ECHO ###
38call :Set_Error
39endlocal
40goto :eof
41
42
43:Test_Option
44REM Tests whether the given string is in the form of an option: "--*"
45call :Clear_Error
46setlocal
47set test=%1
48if not defined test (
49    call :Set_Error
50    goto Test_Option_End
51)
52set test=###%test%###
53set test=%test:"###=%
54set test=%test:###"=%
55set test=%test:###=%
56if not "-" == "%test:~1,1%" call :Set_Error
57:Test_Option_End
58endlocal
59goto :eof
60
61
62:Test_Empty
63REM Tests whether the given string is not empty
64call :Clear_Error
65setlocal
66set test=%1
67if not defined test (
68    call :Clear_Error
69    goto Test_Empty_End
70)
71set test=###%test%###
72set test=%test:"###=%
73set test=%test:###"=%
74set test=%test:###=%
75if not "" == "%test%" call :Set_Error
76:Test_Empty_End
77endlocal
78goto :eof
79
80
81:Guess_Toolset
82set local
83REM Try and guess the toolset to bootstrap the build with...
84REM Sets B2_TOOLSET to the first found toolset.
85REM May also set B2_TOOLSET_ROOT to the
86REM location of the found toolset.
87
88call :Clear_Error
89call :Test_Empty "%ProgramFiles%"
90if not errorlevel 1 set "ProgramFiles=C:\Program Files"
91
92REM Visual Studio is by default installed to %ProgramFiles% on 32-bit machines and
93REM %ProgramFiles(x86)% on 64-bit machines. Making a common variable for both.
94call :Clear_Error
95call :Test_Empty "%ProgramFiles(x86)%"
96if errorlevel 1 (
97    set "VS_ProgramFiles=%ProgramFiles(x86)%"
98) else (
99    set "VS_ProgramFiles=%ProgramFiles%"
100)
101
102call guess_toolset.bat
103if errorlevel 1 (
104    call :Error_Print "Could not find a suitable toolset.")
105goto :eof
106
107endlocal
108goto :eof
109
110
111:Start
112set B2_TOOLSET=
113set B2_BUILD_ARGS=
114
115REM If no arguments guess the toolset;
116REM or if first argument is an option guess the toolset;
117REM otherwise the argument is the toolset to use.
118call :Clear_Error
119call :Test_Empty %1
120if not errorlevel 1 (
121    call :Guess_Toolset
122    if not errorlevel 1 ( goto Setup_Toolset ) else ( goto Finish )
123)
124
125call :Clear_Error
126call :Test_Option %1
127if not errorlevel 1 (
128    call :Guess_Toolset
129    if not errorlevel 1 ( goto Setup_Toolset ) else ( goto Finish )
130)
131
132call :Clear_Error
133set B2_TOOLSET=%1
134shift
135goto Setup_Toolset
136
137
138:Setup_Toolset
139REM Setup the toolset command and options. This bit of code
140REM needs to be flexible enough to handle both when
141REM the toolset was guessed at and found, or when the toolset
142REM was indicated in the command arguments.
143REM NOTE: The strange multiple "if ?? == _toolset_" tests are that way
144REM because in BAT variables are subsituted only once during a single
145REM command. A complete "if ... else ..."
146REM is a single command, even though it's in multiple lines here.
147:Setup_Args
148call :Clear_Error
149call :Test_Empty %1
150if not errorlevel 1 goto Config_Toolset
151call :Clear_Error
152call :Test_Option %1
153if errorlevel 1 (
154    set B2_BUILD_ARGS=%B2_BUILD_ARGS% %1
155    shift
156    goto Setup_Args
157)
158:Config_Toolset
159call config_toolset.bat
160if "_%_known_%_" == "__" (
161    call :Error_Print "Unknown toolset: %B2_TOOLSET%"
162)
163if errorlevel 1 goto Finish
164
165echo ###
166echo ### Using '%B2_TOOLSET%' toolset.
167echo ###
168
169set B2_SOURCES=
170set B2_SOURCES=%B2_SOURCES% builtins.cpp class.cpp
171set B2_SOURCES=%B2_SOURCES% command.cpp compile.cpp constants.cpp cwd.cpp
172set B2_SOURCES=%B2_SOURCES% debug.cpp debugger.cpp
173set B2_SOURCES=%B2_SOURCES% execcmd.cpp execnt.cpp filent.cpp filesys.cpp frames.cpp function.cpp
174set B2_SOURCES=%B2_SOURCES% glob.cpp hash.cpp hcache.cpp hdrmacro.cpp headers.cpp jam.cpp
175set B2_SOURCES=%B2_SOURCES% jamgram.cpp lists.cpp make.cpp make1.cpp md5.cpp mem.cpp modules.cpp
176set B2_SOURCES=%B2_SOURCES% native.cpp object.cpp option.cpp output.cpp parse.cpp pathnt.cpp
177set B2_SOURCES=%B2_SOURCES% pathsys.cpp regexp.cpp rules.cpp scan.cpp search.cpp jam_strings.cpp
178set B2_SOURCES=%B2_SOURCES% startup.cpp subst.cpp sysinfo.cpp
179set B2_SOURCES=%B2_SOURCES% timestamp.cpp variable.cpp w32_getreg.cpp
180set B2_SOURCES=%B2_SOURCES% modules/order.cpp
181set B2_SOURCES=%B2_SOURCES% modules/path.cpp
182set B2_SOURCES=%B2_SOURCES% modules/property-set.cpp
183set B2_SOURCES=%B2_SOURCES% modules/regex.cpp
184set B2_SOURCES=%B2_SOURCES% modules/sequence.cpp
185set B2_SOURCES=%B2_SOURCES% modules/set.cpp
186
187set B2_CXXFLAGS=%B2_CXXFLAGS% -DNDEBUG
188
189@echo ON
190%B2_CXX% %CXXFLAGS% %B2_CXXFLAGS% %B2_SOURCES% %B2_CXX_LINK%
191dir *.exe
192copy /b .\b2.exe .\bjam.exe
193
194:Finish
195@exit /b %ERRORLEVEL%
196