aboutsummaryrefslogtreecommitdiff
path: root/BOOTSTRAP-MINGW.cli
blob: 764c66b1c67f6ebb167c3dcdd372c2e831973963 (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
// file      : BOOTSTRAP-MINGW.cli
// copyright : Copyright (c) 2014-2016 Code Synthesis Ltd
// license   : MIT; see accompanying LICENSE file

"
Continuing from \l{#BOOTSTRAP-WINDOWS Bootstrapping on Windows}, if you are
using your own MinGW distribution, then the resulting \c{build2} binaries will
most likely require a number of DLLs in order to run. It is therefore
recommended that you copy the following files from your MinGW \c{bin\\}
subdirectory to \c{C:\\build2\\bin\\} (\c{*} in the last name will normally be
\c{dw2-1}, \c{seh-1}, or \c{sjlj-1}):

\
libwinpthread-1.dll
libstdc++-6.dll
libgcc_s_*.dll
\

To build with MinGW you can either perform the following steps manually or, if
after reviewing the steps, you are happy with using the defaults, run the
\c{build-mingw.bat} batch file. It performs (and echoes) the same set of steps
as outlined below but only allows you to customize the compiler and
installation directory (run \c{build-mingw.bat /?} for usage). You can also
specify an alternative package repository with the \c{BUILD2_REPO} environment
variable.

For example, if your MinGW distribution is in \c{C:\\mingw\\}, then you could
run it (from the command prompt that we have started earlier) like this:

\
> .\build-mingw.bat C:\mingw\bin\g++
\

If you are using the \c{build2-mingw} package then you should be able to
use just \c{g++} for the compiler:

\
> .\build-mingw.bat g++
\

Note also that at about half way through (\c{bpkg fetch} at step 4 below) the
script will stop and prompt you to verify the authenticity of the repository
certificate.

The end result of the bootstrap process (performed either with the script or
manually) is the installed toolchain as well as the \c{bpkg} configuration in
\c{build2-toolchain-X.Y\\} that can be used to \l{#UPGRADE upgrade} to newer
versions. It can also be used to uninstall the toolchain:

\
> cd build2-toolchain-X.Y
> bpkg uninstall build2 bpkg
\

The rest of this section outlines the manual bootstrap process.

\dl|

\li|1. Bootstrap, Phase 1\n

First, we build a minimal build system with the provided
\c{bootstrap-mingw.bat} batch file. Normally, the only argument you will pass
to this script is the C++ compiler to use but there is also a way to specify
compile options; run \c{bootstrap-mingw.bat /?} and see the
\c{build2\\INSTALL} file for details.

\
> cd build2
> .\bootstrap-mingw.bat g++ -static

> build2\b-boot --version
\

|

\li|\n2. Bootstrap, Phase 2\n

Then, we rebuild the build system with the result of Phase 1 linking
libraries statically.

\
> build2\b-boot config.cxx=g++ config.bin.lib=static
> move /y build2\b.exe build2\b-boot.exe

> build2\b-boot --version
\

|

\li|\n3. Stage\n

At this step the entire toolchain is built and staged:

\
> cd ..  # Back to build2-toolchain-X.Y.Z\

> build2\build2\b-boot configure      ^
  config.cxx=g++                      ^
  config.bin.suffix=-stage            ^
  config.install.root=C:\build2       ^
  config.install.data_root=root\stage

> build2\build2\b-boot install
\

The strange-looking \c{config.install.data_root=root\\stage} means install
data files (as opposed to executable files) into the \c{stage\\} subdirectory
of wherever \c{config.install.root} points to (so in our case it will be
\c{C:\\build2\\stage\\}). This subdirectory is temporary and will be removed
in a few steps.

Verify that the toolchain binaries can be found and work (this relies on the
\c{PATH} environment variable we have set earlier):

\
> where b-stage
C:\build2\bin\b-stage.exe

> where bpkg-stage
C:\build2\bin\bpkg-stage.exe

> b-stage --version
> bpkg-stage --version
\

At the next step we will use \c{bpkg} to build and install the \"final\"
toolchain. If for some reason you prefer not to build from packages (for
example, because the machine is offline), then you can convert this step into
the \"final\" installation and skip the rest. For this you will need to
change the \c{configure} command line above along these lines:

\
> build2\build2\b-boot configure ^
  config.cxx=g++                 ^
  config.cc.coptions=-O3         ^
  config.install.root=C:\build2
\

|

\li|\n4. Install\n

Next, we use the staged toolchain to build and install the \"final\" toolchain
from the package repository using the \c{bpkg} package manager. First, we
create the \c{bpkg} configuration. The configuration values are pretty similar
to the previous step and you may want/need to make similar adjustments.

\
> cd ..  # Back to build2-build\
> md build2-toolchain-X.Y
> cd build2-toolchain-X.Y

> bpkg-stage create             ^
  cc                            ^
  config.cxx=g++                ^
  config.cc.coptions=-O3        ^
  config.install.root=C:\build2
\

Next, we add the package repository, build, and install:

\
> bpkg-stage add https://pkg.cppget.org/1/alpha
> bpkg-stage fetch
> bpkg-stage build build2 bpkg
> bpkg-stage install build2 bpkg
\

Finally, we verify the result (note that the \c{where} command is not
available on Windows XP without the Resource Kit installed):

\
> where b
C:\build2\bin\b.exe

> where bpkg
C:\build2\bin\bpkg.exe

> b --version
> bpkg --version
\

|

\li|\n5. Clean\n

The last thing we need to do is uninstall the staged toolchain:

\
> cd ..\build2-toolchain-X.Y.Z  # Back to bootstrap.
> b uninstall
\

||
"