@@ -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,23 +139,29 @@ 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 >
@@ -177,9 +186,10 @@ specified with the
177
186
<link linkend =" opt-f" ><option >-f</option ></link > option,
178
187
which leaves the current directory as the project top directory.
179
188
</para >
189
+
180
190
<para >
181
191
The build configuration may be split into multiple files:
182
- the &SConstruct; file may specify additional
192
+ the &SConstruct; file can specify additional
183
193
configuration files by calling the
184
194
&f-link-SConscript; function,
185
195
and any file thus invoked may
@@ -196,23 +206,24 @@ configuration files for a project
196
206
(including the &SConstruct; file),
197
207
regardless of the actual file names or number of such files.
198
208
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.
209
+ the SConscript files are processed in a single pass
210
+ so that &scons; has a picture of the complete
211
+ dependency tree at all times.
212
+ Each SConscript file is processed in a separate context
213
+ so settings made in one script do not leak into another;
214
+ information can however be shared explicitly between scripts.
204
215
</para >
205
216
206
217
<para >Before reading the &SConscript; files,
207
218
&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
219
+ looks for a <firstterm >site directory</firstterm > -
220
+ a directory named <filename >site_scons</filename >
221
+ is searched for in various system directories and in the
222
+ project top directory, or if the
213
223
<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 >),
224
+ option is given, checks only for that directory.
225
+ Found site directories are prepended
226
+ to the &Python; module search path (<varname >sys.path</varname >),
216
227
thus allowing modules in such directories to be imported in
217
228
the normal &Python; way in &SConscript; files.
218
229
For each found site directory,
@@ -231,28 +242,31 @@ controlling the site directories.
231
242
232
243
<para >
233
244
&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.
245
+ <firstterm >&Python; </firstterm > programming language.
246
+ For many tasks, the simple syntax can be understood from examples,
247
+ so it is normally not necessary to be a &Python;
248
+ programmer to use &SCons; effectively.
249
+ &SConscript; files are executed in a context that makes
250
+ the facilities described in this manual page directly
251
+ available (that is, no need to <literal >import</literal >).
240
252
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 .
253
+ such as flow control, data manipulation, and imported &Python; modules
254
+ are available to use in more complicated build configurations .
243
255
Other &Python; files can be made a part of the build system,
244
256
but they do not automatically have the &SCons; context and
245
257
need to import it if they need access (described later).
246
258
</para >
247
259
248
260
<para >
249
- &scons;
250
- reads and executes all of the included &SConscript; files
261
+ &SCons; reads and executes all of the included &SConscript; files
251
262
<emphasis >before</emphasis >
252
263
it begins building any targets.
253
- To make this clear,
254
- &scons;
255
- prints the following messages about what it is doing:</para >
264
+ Progress messages show this behavior
265
+ (the state change lines - those
266
+ beginning with the <literal >scons:</literal > tag -
267
+ may be suppressed using the
268
+ <link linkend =" opt-Q" ><option >-Q</option ></link > option):
269
+ </para >
256
270
257
271
<screen >
258
272
$ <userinput >scons foo.out</userinput >
@@ -264,43 +278,48 @@ scons: done building targets.
264
278
$
265
279
</screen >
266
280
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
281
<para >
274
282
To assure reproducible builds,
275
283
&SCons;
276
284
uses a restricted <firstterm >execution environment</firstterm >
277
285
for running external commands used to build targets,
278
286
rather then propagating the full environment
279
287
in effect at the time &scons; was called.
280
- This helps avoid problems like picking up accidental settings,
288
+ This helps avoid problems like picking up accidental
289
+ or malicious settings,
281
290
temporary debug values that are no longer needed,
282
291
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 than the CI pipeline).
293
+ Environment variables needed for the proper
294
+ operation of such commands must be set in the
295
+ execution environment explicitly,
296
+ either by assigning the desired values,
297
+ or by picking those values individually or collectively
298
+ out of environment variables exposed by the &Python;
299
+ <systemitem >os.environ</systemitem > dictionary
300
+ (as external program inputs they should be validate
301
+ before use).
302
+ The execution environment for a given &consenv;
303
+ is its &cv-link-ENV; value.
304
+ A small number of environment variables are picked up automatically
305
+ by &scons; itself (see <xref linkend =" environment" />).
306
+ </para >
307
+
308
+ <para >
309
+ In particular, if a compiler or other external command
310
+ needed to build a target file
311
+ is not in &scons; ' idea of a standard system location,
312
+ it will not be found at runtime unless
313
+ you explicitly add the location into the
314
+ execution environment's <varname >PATH</varname > element.
315
+ This is a particular consideration on Windows platforms,
316
+ where it is common for a command to install into an app-specific
317
+ location and depend on setting
318
+ <varname >PATH</varname > in order for them to be found,
319
+ which does not automatically work for &SCons; .
320
+ </para >
321
+
322
+ <para >
304
323
One example approach is to
305
324
extract the entire <envar >PATH</envar >
306
325
environment variable and set that into the
@@ -323,13 +342,13 @@ import os
323
342
env = Environment(
324
343
ENV={
325
344
'PATH': os.environ['PATH'],
326
- 'ANDROID_HOME ': os.environ['ANDROID_HOME '],
327
- 'ANDROID_NDK_HOME ': os.environ['ANDROID_NDK_HOME '],
345
+ 'MODULEPATH ': os.environ['MODULEPATH '],
346
+ 'PKG_CONFIG_PATH ': os.environ['PKG_CONFIG_PATH '],
328
347
}
329
348
)
330
349
</programlisting >
331
350
332
- <para >Or you may explicitly propagate the invoking user's
351
+ <para >Or you can explicitly propagate the invoking user's
333
352
complete external environment:</para >
334
353
335
354
<programlisting language =" python" >
@@ -435,6 +454,7 @@ and the PharLap ETS compiler.
435
454
On Windows system which identify as <emphasis >cygwin</emphasis >
436
455
(that is, if &scons; is invoked from a cygwin shell),
437
456
the order changes to prefer the GCC toolchain over the MSVC tools.
457
+ <!-- Seems odd to still list OS/2 (though it lives in some form as ArcaOS -->
438
458
On OS/2 systems,
439
459
&scons;
440
460
searches in order for the
@@ -447,13 +467,17 @@ searches for the native compiler tools
447
467
(MIPSpro, Visual Age, aCC, and Forte tools respectively)
448
468
and the GCC tool chain.
449
469
On all other platforms,
450
- including POSIX (Linux and UNIX) platforms,
470
+ including POSIX (Linux and UNIX) and macOS platforms,
451
471
&scons;
452
472
searches in order
453
473
for the GCC tool chain,
454
474
and the Intel compiler tools.
455
- These default values may be overridden
456
- by appropriate setting of &consvars; .</para >
475
+ The defaul tool selection can be pre-empted
476
+ through the use of the <parameter >tools</parameter >
477
+ argument to &consenv; creation methods,
478
+ explcitly calling the &f-link-Tool; loader,
479
+ the through the setting of various setting of &consvars; .
480
+ </para >
457
481
458
482
<refsect2 id =' target_selection' >
459
483
<title >Target Selection</title >
0 commit comments