Skip to content

Commit c4d9168

Browse files
committed
Minor type and doc tweaks [skip appveyor]
Small changes harvested from abandoned PR SCons#4671 so they're not lost. These changes omit the large surgery to the Builder Objects section in doc/man/scons.xml from the PR. The changes consist of a few doc formatting changes, entity usage, moving one chunk of text in the SharedObject entry down ito its own paragraph, noting when a builder is single source, and, in the code, consistently using the single_source builder argument as a boolean. Signed-off-by: Mats Wichmann <mats@linux.com>
1 parent c005b06 commit c4d9168

File tree

6 files changed

+51
-48
lines changed

6 files changed

+51
-48
lines changed

SCons/BuilderTests.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -714,8 +714,8 @@ def func(target, source, env) -> None:
714714
infiles.append(test.workpath('%d.in' % i))
715715
outfiles.append(test.workpath('%d.out' % i))
716716
test.write(infiles[-1], "\n")
717-
builder = SCons.Builder.Builder(action=SCons.Action.Action(func,None),
718-
single_source = 1, suffix='.out')
717+
builder = SCons.Builder.Builder(action=SCons.Action.Action(func, None),
718+
single_source=True, suffix='.out')
719719
env['CNT'] = [0]
720720
tgt = builder(env, target=outfiles[0], source=infiles[0])[0]
721721
s = str(tgt)

SCons/EnvironmentTests.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,10 @@ def TestEnvironment(self, *args, **kw):
156156
if key not in kw:
157157
kw[key] = value
158158
if 'BUILDERS' not in kw:
159-
static_obj = SCons.Builder.Builder(action = {},
160-
emitter = {},
161-
suffix = '.o',
162-
single_source = 1)
159+
static_obj = SCons.Builder.Builder(action={},
160+
emitter={},
161+
suffix='.o',
162+
single_source=True)
163163
kw['BUILDERS'] = {'Object' : static_obj}
164164
static_obj.add_action('.cpp', 'fake action')
165165

SCons/Node/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ def get_contents_dir(node):
215215
contents.append('%s %s\n' % (n.get_csig(), n.name))
216216
return ''.join(contents)
217217

218-
def get_contents_file(node):
218+
def get_contents_file(node) -> bytes:
219219
if not node.rexists():
220220
return b''
221221
fname = node.rfile().get_abspath()

SCons/Tool/Tool.xml

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -281,38 +281,41 @@ when it is done linking it.
281281
Builds an object file intended for
282282
inclusion in a shared library.
283283
Source files must have one of the same set of extensions
284-
specified above for the
285-
&b-StaticObject;
284+
specified for the
285+
&b-link-StaticObject;
286286
builder method.
287-
On some platforms building a shared object requires additional
288-
compiler option
289-
(e.g. <option>-fPIC</option> for <command>gcc</command>)
290-
in addition to those needed to build a
291-
normal (static) object, but on some platforms there is no difference between a
292-
shared object and a normal (static) one. When there is a difference, SCons
293-
will only allow shared objects to be linked into a shared library, and will
294-
use a different suffix for shared objects. On platforms where there is no
295-
difference, SCons will allow both normal (static)
296-
and shared objects to be linked into a
297-
shared library, and will use the same suffix for shared and normal
298-
(static) objects.
299287
The target object file prefix,
300288
specified by the &cv-link-SHOBJPREFIX; &consvar;
301289
(by default, the same as &cv-link-OBJPREFIX;),
302290
and suffix,
303291
specified by the &cv-link-SHOBJSUFFIX; &consvar;,
304292
are automatically added to the target if not already present.
293+
&b-SharedObject; is a single-source builder.
305294
Examples:
306295
</para>
307296

308297
<example_commands>
309298
env.SharedObject(target='ddd', source='ddd.c')
310299
env.SharedObject(target='eee.o', source='eee.cpp')
311300
env.SharedObject(target='fff.obj', source='fff.for')
301+
env.SharedObject(source=Glob('*.c'))
312302
</example_commands>
313303

314304
<para>
315-
Note that the source files will be scanned
305+
On some platforms building a shared object requires additional
306+
compiler option(s)
307+
(e.g. <option>-fPIC</option> for <command>gcc</command>)
308+
in addition to those needed to build a
309+
normal (static) object.
310+
If shared and static objects differ,
311+
&SCons; will allow only shared objects
312+
to be linked into a shared library,
313+
and will use a different suffix for shared objects
314+
to help indicate and track the difference.
315+
</para>
316+
317+
<para>
318+
Source files will be scanned
316319
according to the suffix mappings in the
317320
<classname>SourceFileScanner</classname>
318321
object.
@@ -364,10 +367,10 @@ will raise an error if there is any mismatch.
364367
<para>
365368
Builds a static object file
366369
from one or more C, C++, D, or Fortran source files.
367-
Source files must have one of the following extensions:
370+
The file extension mapping is shown in the table:
368371
</para>
369372

370-
<example_commands>
373+
<literallayout><literal>
371374
.asm assembly language file
372375
.ASM assembly language file
373376
.c C file
@@ -396,28 +399,30 @@ Source files must have one of the following extensions:
396399
POSIX: assembly language file + C pre-processor
397400
.spp assembly language file + C pre-processor
398401
.SPP assembly language file + C pre-processor
399-
</example_commands>
402+
</literal></literallayout>
400403

401404
<para>
402405
The target object file prefix,
403406
specified by the &cv-link-OBJPREFIX; &consvar;
404-
(nothing by default),
407+
(empty string by default),
405408
and suffix,
406409
specified by the &cv-link-OBJSUFFIX; &consvar;
407410
(<filename>.obj</filename> on Windows systems,
408411
<filename>.o</filename> on POSIX systems),
409412
are automatically added to the target if not already present.
413+
&b-StaticObject; is a single-source builder.
410414
Examples:
411415
</para>
412416

413417
<example_commands>
414418
env.StaticObject(target='aaa', source='aaa.c')
415419
env.StaticObject(target='bbb.o', source='bbb.c++')
416420
env.StaticObject(target='ccc.obj', source='ccc.f')
421+
env.StaticObject(source=Glob('*.c'))
417422
</example_commands>
418423

419424
<para>
420-
Note that the source files will be scanned
425+
Source files will be scanned
421426
according to the suffix mappings in the
422427
<classname>SourceFileScanner</classname>
423428
object.

SCons/Tool/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ def createObjBuilders(env):
408408
suffix='$OBJSUFFIX',
409409
src_builder=['CFile', 'CXXFile'],
410410
source_scanner=SourceFileScanner,
411-
single_source=1)
411+
single_source=True)
412412
env['BUILDERS']['StaticObject'] = static_obj
413413
env['BUILDERS']['Object'] = static_obj
414414

@@ -421,7 +421,7 @@ def createObjBuilders(env):
421421
suffix='$SHOBJSUFFIX',
422422
src_builder=['CFile', 'CXXFile'],
423423
source_scanner=SourceFileScanner,
424-
single_source=1)
424+
single_source=True)
425425
env['BUILDERS']['SharedObject'] = shared_obj
426426

427427
return (static_obj, shared_obj)

doc/man/scons.xml

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,7 +1130,7 @@ when encountering an otherwise unexplained error.</para>
11301130
(When
11311131
&scons;
11321132
is executed without the
1133-
<option>-j</option>
1133+
<link linkend="opt-jobs"><option>-j</option></link>
11341134
option,
11351135
the elapsed wall-clock time will typically
11361136
be slightly longer than the total time spent
@@ -1142,7 +1142,7 @@ When
11421142
is executed
11431143
<emphasis>with</emphasis>
11441144
the
1145-
<option>-j</option>
1145+
<link linkend="opt-jobs"><option>-j</option></link>
11461146
option,
11471147
and your build configuration allows good parallelization,
11481148
the elapsed wall-clock time should
@@ -2289,7 +2289,7 @@ which can yield unpredictable behavior with some compilers.</para>
22892289
<varlistentry>
22902290
<term><emphasis role="bold">future-reserved-variable</emphasis></term>
22912291
<listitem>
2292-
<para>Warnings about construction variables which
2292+
<para>Warnings about &consvars; which
22932293
are currently allowed,
22942294
but will become reserved variables in a future release.
22952295
</para>
@@ -2377,7 +2377,7 @@ Add another "-no" to disable.
23772377
<listitem>
23782378
<para>Warnings about the version of &Python;
23792379
not being able to support parallel builds when the
2380-
<option>-j</option>
2380+
<link linkend="opt-jobs"><option>-j</option></link>
23812381
option is used.
23822382
These warnings are enabled by default.</para>
23832383
<para>
@@ -2619,7 +2619,7 @@ settings. Otherwise, &f-env-Clone; takes the same arguments as
26192619
&SCons; provides a special &consenv; called the
26202620
<firstterm>&DefEnv;</firstterm>.
26212621
The &defenv; is used only for global functions, that is,
2622-
construction activities called without the context of a regular &consenv;.
2622+
build requests called without the context of a regular &consenv;.
26232623
See &f-link-DefaultEnvironment; for more information.
26242624
</para>
26252625

@@ -5890,7 +5890,7 @@ Adding new Tool modules is described in
58905890
<title>Builder Objects</title>
58915891

58925892
<para>&scons;
5893-
can be extended to build different types of targets
5893+
can be extended to build additional types of targets
58945894
by adding new Builder objects
58955895
to a &consenv;.
58965896
<emphasis>In general</emphasis>,
@@ -5899,7 +5899,7 @@ when you want to build a new type of file or other external target.
58995899
For output file types &scons; already knows about,
59005900
you can usually modify the behavior of premade Builders
59015901
such as &b-link-Program;, &b-link-Object; or &b-link-Library;
5902-
by changing the &consvars; they use
5902+
by changing the &consvars; that control their behavior
59035903
(&cv-link-CC;, &cv-link-LINK;, etc.).
59045904
In this manner you can, for example, change the compiler to use,
59055905
which is simpler and less error-prone than writing a new builder.
@@ -5911,8 +5911,8 @@ The documentation for each Builder lists which
59115911
using the
59125912
&f-link-Builder;
59135913
factory function.
5914-
Once created, a builder is added to an environment
5915-
by entering it in the &cv-link-BUILDERS; dictionary
5914+
Once created, a builder is added to a &consenv;
5915+
by registering it in the &cv-link-BUILDERS; dictionary
59165916
in that environment (some of the examples
59175917
in this section illustrate this).
59185918
Doing so automatically triggers &SCons; to add a method
@@ -6445,16 +6445,14 @@ env.MyBuild('sub/dir/foo.out', 'sub/dir/foo.in')
64456445

64466446
<warning>
64476447
<para>
6448-
&Python; only keeps one current directory
6449-
location even if there are multiple threads.
6448+
&Python; only tracks one current directory location,
6449+
even if there are multiple executing threads.
64506450
This means that use of the
64516451
<parameter>chdir</parameter>
6452-
argument
6453-
will
6452+
argument will
64546453
<emphasis>not</emphasis>
6455-
work with the SCons
6456-
<option>-j</option>
6457-
option,
6454+
work with &SCons; in multi-threaded mode
6455+
(the <link linkend="opt-jobs"><option>-j</option></link> option),
64586456
because individual worker threads spawned
64596457
by SCons interfere with each other
64606458
when they start changing directory.</para>
@@ -6466,8 +6464,8 @@ when they start changing directory.</para>
64666464
<para>Any additional keyword arguments supplied
64676465
when a Builder object is created
64686466
(that is, when the &f-link-Builder; function is called)
6469-
will be set in the executing construction
6470-
environment when the Builder object is called.
6467+
will be set in the executing &consenv;
6468+
when the Builder object is called.
64716469
The canonical example here would be
64726470
to set a &consvar; to
64736471
the repository of a source code system.</para>
@@ -6629,7 +6627,7 @@ will expand &consvars; in any argument strings,
66296627
including
66306628
<parameter>action</parameter>,
66316629
at the time it is called,
6632-
using the construction variables in the &consenv; through which
6630+
using the &consvars; in the &consenv; through which
66336631
it was called. The global function form &f-link-Action;
66346632
delays variable expansion until
66356633
the Action object is actually used.

0 commit comments

Comments
 (0)