Skip to content

Commit 7eb0d11

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 <[email protected]>
1 parent 76ff88d commit 7eb0d11

File tree

7 files changed

+345
-446
lines changed

7 files changed

+345
-446
lines changed

CHANGES.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER
2727
- runtest.py once again finds "external" tests, such as the tests for
2828
tools in scons-contrib. An earlier rework had broken this. Fixes #4699.
2929
- Clarify how pre/post actions on an alias work.
30+
- Improve the Builder Methods intro section in manpage, making sure
31+
all prose appears before the listing of methods.
3032

3133

3234
RELEASE 4.9.1 - Thu, 27 Mar 2025 11:40:20 -0700
@@ -42,7 +44,6 @@ RELEASE 4.9.1 - Thu, 27 Mar 2025 11:40:20 -0700
4244
From Mats Wichmann:
4345
- Fix typos in CCFLAGS test. Didn't affect the test itself, but
4446
didn't correctly apply the DefaultEnvironment speedup.
45-
4647
- New CacheDir initialization code failed on Python 3.7 for unknown
4748
reason (worked on 3.8+). Adjusted the approach a bit. Fixes #4694.
4849
- Try to fix Windows fails on Docbook tests in case xsltproc is found.

RELEASE.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,16 @@ DOCUMENTATION
6161
DEVELOPMENT
6262
-----------
6363

64+
- List visible changes in the way SCons is developed
65+
6466
- runtest.py once again finds "external" tests, such as the tests for
6567
tools in scons-contrib. An earlier rework had broken this. Fixes #4699.
6668

69+
- Improve the descriptive portion of the Builder Methods section in
70+
the manpage: reword, reorganize.
71+
6772
Thanks to the following contributors listed below for their contributions to this release.
6873
==========================================================================================
6974
.. code-block:: text
7075

71-
7276
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/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: 43 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ if it is not already present.
3636
Example:
3737
</para>
3838

39-
<example_commands>
39+
<programlisting language="python">
4040
# builds foo.c
4141
env.CFile(target='foo.c', source='foo.l')
4242

4343
# builds bar.c
4444
env.CFile(target='bar', source='bar.y')
45-
</example_commands>
45+
</programlisting>
4646

4747
<!--para> ** Left here for reference, does not need to be user-visible. **
4848
Note that for yacc files,
@@ -67,13 +67,13 @@ if it is not already present.
6767
Example:
6868
</para>
6969

70-
<example_commands>
70+
<programlisting language="python">
7171
# builds foo.cc
7272
env.CXXFile(target='foo.cc', source='foo.ll')
7373

7474
# builds bar.cc
7575
env.CXXFile(target='bar', source='bar.yy')
76-
</example_commands>
76+
</programlisting>
7777

7878
<!--para> ** Left here for reference, does not need to be user-visible. **
7979
Note that for yacc files,
@@ -141,9 +141,9 @@ are automatically added to the target if not already present.
141141
Example:
142142
</para>
143143

144-
<example_commands>
144+
<programlisting language="python">
145145
env.Program(target='foo', source=['foo.o', 'bar.c', 'baz.f'])
146-
</example_commands>
146+
</programlisting>
147147
</summary>
148148
</builder>
149149

@@ -187,9 +187,9 @@ it is appended (following a period) to the resulting library name.
187187
Example:
188188
</para>
189189

190-
<example_commands>
190+
<programlisting language="python">
191191
env.SharedLibrary(target='bar', source=['bar.c', 'foo.o'])
192-
</example_commands>
192+
</programlisting>
193193

194194
<para>
195195
On Windows systems, the
@@ -228,9 +228,9 @@ adds the version number to the library name, and creates any
228228
symbolic links that are needed.
229229
</para>
230230

231-
<example_commands>
231+
<programlisting language="python">
232232
env.SharedLibrary(target='bar', source=['bar.c', 'foo.o'], SHLIBVERSION='1.5.2')
233-
</example_commands>
233+
</programlisting>
234234

235235
<para>
236236
On a POSIX system, supplying a simple version string (no dots)
@@ -264,9 +264,9 @@ up and requiring user attention when it is run. If you change
264264
For example,
265265
</para>
266266

267-
<example_commands>
267+
<programlisting language="python">
268268
env.SharedLibrary(target='bar', source=['bar.cxx', 'foo.obj'], register=1)
269-
</example_commands>
269+
</programlisting>
270270

271271
<para>
272272
will register <filename>bar.dll</filename> as a COM object
@@ -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

308-
<example_commands>
297+
<programlisting language="python">
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')
312-
</example_commands>
301+
env.SharedObject(source=Glob('*.c'))
302+
</programlisting>
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.
@@ -342,9 +345,9 @@ are automatically added to the target if not already present.
342345
Example:
343346
</para>
344347

345-
<example_commands>
348+
<programlisting language="python">
346349
env.StaticLibrary(target='bar', source=['bar.c', 'foo.o'])
347-
</example_commands>
350+
</programlisting>
348351

349352
<para>
350353
Any object files listed in the
@@ -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

413-
<example_commands>
417+
<programlisting language="python">
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')
417-
</example_commands>
421+
env.StaticObject(source=Glob('*.c'))
422+
</programlisting>
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)