@@ -74,7 +74,7 @@ This file is processed by the bin/SConsDoc.py module.
74
74
<refsect1 id =' description' >
75
75
<title >DESCRIPTION</title >
76
76
<para >
77
- &scons;
77
+ &SCons; is an extensible open source build system that
78
78
orchestrates the construction of software
79
79
(and other tangible products such as documentation files)
80
80
by determining which
@@ -105,23 +105,26 @@ The CPython project retired 3.6 in Sept 2021:
105
105
<ulink url =" https://peps.python.org/pep-0494" />.
106
106
</para >
107
107
108
- <para >You set up an &SCons;
109
- build system by writing a script
108
+ <para >
109
+ You set up an &SCons; build by writing a script
110
110
that describes things to build (<firstterm >targets</firstterm >), and,
111
111
if necessary, the rules to build those files (<firstterm >actions</firstterm >).
112
112
&SCons; comes with a collection of <firstterm >Builder</firstterm > methods
113
- which apply premade actions for building many common software components
113
+ which supply premade Actions for building many common software components
114
114
such as executable programs, object files and libraries,
115
115
so that for many software projects,
116
116
only the targets and input files (<firstterm >sources</firstterm >)
117
117
need be specified in a call to a builder.
118
- &SCons; thus can operate at a level of abstraction above that of pure filenames.
119
- For example if you specify a library target named "foo",
118
+ </para >
119
+
120
+ <para >
121
+ &SCons; operates at a level of abstraction above that of pure filenames.
122
+ For example if you specify a shared library target named "foo",
120
123
&SCons; keeps track of the actual operating system dependent filename
121
- (such as <filename >libfoo.so</filename > on a GNU/Linux system),
122
- and how to refer to that library in later construction steps
123
- that want to use it, so you don't have to specify that precise
124
- information yourself.
124
+ (such as <filename >libfoo.so</filename > on a GNU/Linux system
125
+ and < filename >foo.dll</ filename > on Windows),
126
+ and gives you a handle to refer to that target in other steps,
127
+ so you don't have to use system-specific strings yourself.
125
128
&SCons; can also scan automatically for dependency information,
126
129
such as header files included by source code files
127
130
(for example, <literal >#include</literal >
@@ -136,50 +139,58 @@ to support additional input file types.
136
139
including a cryptographic hash of the contents of source files,
137
140
is cached for later reuse.
138
141
By default this hash (the <firstterm >&contentsig; </firstterm >)
139
- is used to determine if a file has changed since the last build,
140
- although this can be controlled by selecting an appropriate
142
+ is used to decide if a file has changed since the last build,
143
+ although other algorithms can be used by selecting an appropriate
141
144
<firstterm >&f-link-Decider; </firstterm > function.
142
145
Implicit dependency files are also part of out-of-date computation.
143
146
The scanned implicit dependency information can optionally be
144
147
cached and used to speed up future builds.
145
148
A hash of each executed build action (the <firstterm >&buildsig; </firstterm >)
146
- is cached, so that changes to build instructions (changing flags, etc.)
147
- or to the build tools themselves (new version )
149
+ is also cached, so that changes to build instructions (changing flags, etc.)
150
+ or to the build tools themselves (e.g. a compiler upgrade )
148
151
can also trigger a rebuild.
149
152
</para >
150
153
151
154
<para >
152
- &SCons; supports the concept of separated source and build
153
- directories through the definition of
155
+ &SCons; supports separated source and build
156
+ directories (also called "out-of-tree builds")
157
+ through the definition of
154
158
<firstterm >variant directories</firstterm >
155
- (see the &f-link-VariantDir; function).
159
+ Using a separated build directory helps keep
160
+ the source directory clean of artifacts when doing searches,
161
+ allows setting up differing builds ("variants") without conflicts,
162
+ and allows resetting the build by just removing the build directory
163
+ (note that SCons does have a "clean" mode as well).
164
+ See the &f-link-VariantDir; description for more details.
156
165
</para >
157
166
158
167
<para >
159
168
When invoked, &scons;
160
- looks for a file named
161
- &SConstruct;
162
- (other names are also accepted,
163
- see <xref linkend =" sconscript_files" />)
164
- in the current directory and reads the
165
- build configuration from that file;
166
- that directory is considered the project top directory.
169
+ looks for a file describing the build configuration
170
+ in the current directory and reads that in.
171
+ The file is by default named &SConstruct; ,
172
+ although some variants of that,
173
+ or a developer-chosen name, are also accepted
174
+ (see <xref linkend =" sconscript_files" />).
175
+ If found, the currrent directory
176
+ is set as the project top directory.
167
177
Certain command-line options specify alternate
168
- places to look for the &SConstruct;
178
+ places to look for &SConstruct;
169
179
(see
170
180
<link linkend =" opt-directory" ><option >-C</option ></link >,
171
181
<link linkend =" opt-D" ><option >-D</option ></link >,
172
182
<link linkend =" opt-up" ><option >-u</option ></link > and
173
183
<link linkend =" opt-U" ><option >-U</option ></link >),
174
- which will set the project top directory to the place found.
175
- A path to the main build configuration file can also be
184
+ which will set the project top directory to the path found.
185
+ A path to the build configuration can also be
176
186
specified with the
177
187
<link linkend =" opt-f" ><option >-f</option ></link > option,
178
188
which leaves the current directory as the project top directory.
179
189
</para >
190
+
180
191
<para >
181
192
The build configuration may be split into multiple files:
182
- the &SConstruct; file may specify additional
193
+ the &SConstruct; file can specify additional
183
194
configuration files by calling the
184
195
&f-link-SConscript; function,
185
196
and any file thus invoked may
@@ -196,23 +207,24 @@ configuration files for a project
196
207
(including the &SConstruct; file),
197
208
regardless of the actual file names or number of such files.
198
209
A hierarchical build is not recursive - all of
199
- the SConscript files are processed in a single pass,
200
- although each is processed in a separate context so
201
- as not to interfere with one another. &SCons; provides
202
- mechanisms for information to be shared between
203
- SConscript files when needed.
210
+ the SConscript files are processed in a single pass
211
+ so that &scons; has a picture of the complete
212
+ dependency tree when it begins considering what needs building.
213
+ Each SConscript file is processed in a separate context
214
+ so settings made in one script do not leak into another;
215
+ information can however be shared explicitly between scripts.
204
216
</para >
205
217
206
- <para >Before reading the & SConscript; files,
218
+ <para >Before reading the SConscript files,
207
219
&scons;
208
- looks for a directory named
209
- <filename >site_scons</filename >
210
- in various system directories and in the
211
- project top directory, or, if specified,
212
- the directory from the
220
+ looks for a <firstterm >site directory</firstterm > -
221
+ a directory named <filename >site_scons</filename >
222
+ is searched for in various system directories and in the
223
+ project top directory, or if the
213
224
<link linkend =" opt-site-dir" ><option >--site-dir</option ></link >
214
- option instead, and prepends the ones it
215
- finds to the &Python; module search path (<varname >sys.path</varname >),
225
+ option is given, checks only for that directory.
226
+ Found site directories are prepended
227
+ to the &Python; module search path (<varname >sys.path</varname >),
216
228
thus allowing modules in such directories to be imported in
217
229
the normal &Python; way in &SConscript; files.
218
230
For each found site directory,
@@ -231,28 +243,31 @@ controlling the site directories.
231
243
232
244
<para >
233
245
&SConscript; files are written in the
234
- <firstterm >&Python; </firstterm > programming language,
235
- although it is normally not necessary to be a &Python;
236
- programmer to use &scons; effectively.
237
- &SConscript; files are invoked in a context that makes
238
- the facilities described in this manual page available
239
- in their local namespace without any special steps.
246
+ <firstterm >&Python; </firstterm > programming language.
247
+ For many tasks, the simple syntax can be understood from examples,
248
+ so it is normally not necessary to be a &Python;
249
+ programmer to use &SCons; effectively.
250
+ &SConscript; files are executed in a context that makes
251
+ the facilities described in this manual page directly
252
+ available (that is, no need to <literal >import</literal >).
240
253
Standard &Python; scripting capabilities
241
- such as flow control, data manipulation, and imported &Python; libraries
242
- are available to use to handle complicated build situations .
254
+ such as flow control, data manipulation, and imported &Python; modules
255
+ are available to use in more complicated build configurations .
243
256
Other &Python; files can be made a part of the build system,
244
257
but they do not automatically have the &SCons; context and
245
258
need to import it if they need access (described later).
246
259
</para >
247
260
248
261
<para >
249
- &scons;
250
- reads and executes all of the included &SConscript; files
262
+ &SCons; reads and executes all of the included &SConscript; files
251
263
<emphasis >before</emphasis >
252
264
it begins building any targets.
253
- To make this clear,
254
- &scons;
255
- prints the following messages about what it is doing:</para >
265
+ Progress messages show this behavior
266
+ (the state change lines - those
267
+ beginning with the <literal >scons:</literal > tag -
268
+ may be suppressed using the
269
+ <link linkend =" opt-Q" ><option >-Q</option ></link > option):
270
+ </para >
256
271
257
272
<screen >
258
273
$ <userinput >scons foo.out</userinput >
@@ -264,43 +279,48 @@ scons: done building targets.
264
279
$
265
280
</screen >
266
281
267
- <para >The status messages
268
- (lines beginning with the <literal >scons:</literal > tag)
269
- may be suppressed using the
270
- <link linkend =" opt-Q" ><option >-Q</option ></link >
271
- option.</para >
272
-
273
282
<para >
274
283
To assure reproducible builds,
275
284
&SCons;
276
285
uses a restricted <firstterm >execution environment</firstterm >
277
286
for running external commands used to build targets,
278
287
rather then propagating the full environment
279
288
in effect at the time &scons; was called.
280
- This helps avoid problems like picking up accidental settings,
289
+ This helps avoid problems like picking up accidental
290
+ or malicious settings,
281
291
temporary debug values that are no longer needed,
282
- or one developer having different settings than another
283
- (or than the CI/CD pipeline).
284
- Environment variables that are needed for proper
285
- operation of such commands need to be set explicitly,
286
- which can be done either by assigning the desired values,
287
- or by picking values individually out of environment variables
288
- using the &Python; <systemitem >os.environ</systemitem > dictionary.
289
- The execution environment for a given &consenv; is
290
- contained in its &cv-link-ENV; &consvar; .
291
- A few environment variables are picked up automatically -
292
- see <xref linkend =" environment" />).
293
- </para >
294
-
295
- <para >
296
- In particular, if the compiler or other commands
297
- that you want to use to build your target files
298
- are not in standard system locations,
299
- &scons;
300
- will not find them unless
301
- you explicitly include the locations into the
302
- <varname >PATH</varname > element of the
303
- execution environment.
292
+ or a developer having different settings than another
293
+ (or than the CI pipeline).
294
+ Environment variables needed for the proper
295
+ operation of such commands must be set in the
296
+ execution environment explicitly,
297
+ either by assigning the desired values,
298
+ or by picking those values individually or collectively
299
+ out of environment variables exposed by the &Python;
300
+ <systemitem >os.environ</systemitem > dictionary
301
+ (as external program inputs they should be validate
302
+ before use).
303
+ The execution environment for a given &consenv;
304
+ is its &cv-link-ENV; value.
305
+ A small number of environment variables are picked up automatically
306
+ by &scons; itself (see <xref linkend =" environment" />).
307
+ </para >
308
+
309
+ <para >
310
+ In particular, if a compiler or other external command
311
+ needed to build a target file
312
+ is not in &scons; ' idea of a standard system location,
313
+ it will not be found at runtime unless
314
+ you explicitly add the location into the
315
+ execution environment's <varname >PATH</varname > element.
316
+ This is a particular consideration on Windows platforms,
317
+ where it is common for a command to install into an app-specific
318
+ location and depend on setting
319
+ <varname >PATH</varname > in order for them to be found,
320
+ which does not automatically work for &SCons; .
321
+ </para >
322
+
323
+ <para >
304
324
One example approach is to
305
325
extract the entire <envar >PATH</envar >
306
326
environment variable and set that into the
@@ -323,13 +343,13 @@ import os
323
343
env = Environment(
324
344
ENV={
325
345
'PATH': os.environ['PATH'],
326
- 'ANDROID_HOME ': os.environ['ANDROID_HOME '],
327
- 'ANDROID_NDK_HOME ': os.environ['ANDROID_NDK_HOME '],
346
+ 'MODULEPATH ': os.environ['MODULEPATH '],
347
+ 'PKG_CONFIG_PATH ': os.environ['PKG_CONFIG_PATH '],
328
348
}
329
349
)
330
350
</programlisting >
331
351
332
- <para >Or you may explicitly propagate the invoking user's
352
+ <para >Or you can explicitly propagate the invoking user's
333
353
complete external environment:</para >
334
354
335
355
<programlisting language =" python" >
@@ -435,6 +455,7 @@ and the PharLap ETS compiler.
435
455
On Windows system which identify as <emphasis >cygwin</emphasis >
436
456
(that is, if &scons; is invoked from a cygwin shell),
437
457
the order changes to prefer the GCC toolchain over the MSVC tools.
458
+ <!-- Seems odd to still list OS/2 (though it lives in some form as ArcaOS -->
438
459
On OS/2 systems,
439
460
&scons;
440
461
searches in order for the
@@ -447,13 +468,17 @@ searches for the native compiler tools
447
468
(MIPSpro, Visual Age, aCC, and Forte tools respectively)
448
469
and the GCC tool chain.
449
470
On all other platforms,
450
- including POSIX (Linux and UNIX) platforms,
471
+ including POSIX (Linux and UNIX) and macOS platforms,
451
472
&scons;
452
473
searches in order
453
474
for the GCC tool chain,
454
475
and the Intel compiler tools.
455
- These default values may be overridden
456
- by appropriate setting of &consvars; .</para >
476
+ The defaul tool selection can be pre-empted
477
+ through the use of the <parameter >tools</parameter >
478
+ argument to &consenv; creation methods,
479
+ explcitly calling the &f-link-Tool; loader,
480
+ the through the setting of various setting of &consvars; .
481
+ </para >
457
482
458
483
<refsect2 id =' target_selection' >
459
484
<title >Target Selection</title >
0 commit comments