Skip to content

Commit 7273ea6

Browse files
committed
Modify the Builder Methods manpage section [skip appveyor]
In clarifying the detail on when a builder's target can be deduced, it seemed like the concept of a single-source builder ought to be introduced in this context. So now those builders we know are single-source have that notation in their entry in this section. Also mentions that pseudo-Builders may have a diffeent calling sequence. A chunk of text about dependencies previously appeared after the listing of builder methods, where it would be hard to spot. Moved up into the text before the listing, and integrate in a bit more smoothly. A couple of very minor typing things adjusted along the way - mainly using single_source consistently as a bool. Signed-off-by: Mats Wichmann <mats@linux.com>
1 parent c005b06 commit 7273ea6

File tree

8 files changed

+331
-432
lines changed

8 files changed

+331
-432
lines changed

CHANGES.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,8 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER
175175
- Add more unit tests to internal AppendPath, PrependPath functions.
176176
- Add unit tests to show .filebase method strips only the last suffix if
177177
several apparent suffixes are present, and .suffix returns the last.
178+
- Improve the Builder Methods intro section in manpage, making sure
179+
all prose appears before the listing of methods.
178180

179181

180182
RELEASE 4.9.1 - Thu, 27 Mar 2025 11:40:20 -0700
@@ -190,7 +192,6 @@ RELEASE 4.9.1 - Thu, 27 Mar 2025 11:40:20 -0700
190192
From Mats Wichmann:
191193
- Fix typos in CCFLAGS test. Didn't affect the test itself, but
192194
didn't correctly apply the DefaultEnvironment speedup.
193-
194195
- New CacheDir initialization code failed on Python 3.7 for unknown
195196
reason (worked on 3.8+). Adjusted the approach a bit. Fixes #4694.
196197
- Try to fix Windows fails on Docbook tests in case xsltproc is found.

RELEASE.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,9 @@ DOCUMENTATION
145145

146146
- Improve the wording of AppendENVPath and PrependENVPath in manpage.
147147

148+
- Improve the descriptive portion of the Builder Methods section in
149+
the manpage: reword, reorganize.
150+
148151
DEVELOPMENT
149152
-----------
150153

@@ -201,5 +204,4 @@ Thanks to the following contributors listed below for their contributions to thi
201204
==========================================================================================
202205
.. code-block:: text
203206

204-
205207
git shortlog --no-merges -ns 4.9.1..HEAD

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)

0 commit comments

Comments
 (0)