diff --git a/CHANGES.txt b/CHANGES.txt index ca52cc4a7..f22ee86b0 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -27,6 +27,8 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER - runtest.py once again finds "external" tests, such as the tests for tools in scons-contrib. An earlier rework had broken this. Fixes #4699. - Clarify how pre/post actions on an alias work. + - Improve the Builder Methods intro section in manpage, making sure + all prose appears before the listing of methods. 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 From Mats Wichmann: - Fix typos in CCFLAGS test. Didn't affect the test itself, but didn't correctly apply the DefaultEnvironment speedup. - - New CacheDir initialization code failed on Python 3.7 for unknown reason (worked on 3.8+). Adjusted the approach a bit. Fixes #4694. - Try to fix Windows fails on Docbook tests in case xsltproc is found. diff --git a/RELEASE.txt b/RELEASE.txt index 2219bf786..4dced2594 100644 --- a/RELEASE.txt +++ b/RELEASE.txt @@ -61,12 +61,16 @@ DOCUMENTATION DEVELOPMENT ----------- +- List visible changes in the way SCons is developed + - runtest.py once again finds "external" tests, such as the tests for tools in scons-contrib. An earlier rework had broken this. Fixes #4699. +- Improve the descriptive portion of the Builder Methods section in + the manpage: reword, reorganize. + Thanks to the following contributors listed below for their contributions to this release. ========================================================================================== .. code-block:: text - git shortlog --no-merges -ns 4.9.1..HEAD diff --git a/SCons/BuilderTests.py b/SCons/BuilderTests.py index fff26171e..f4c91f991 100644 --- a/SCons/BuilderTests.py +++ b/SCons/BuilderTests.py @@ -714,8 +714,8 @@ def func(target, source, env) -> None: infiles.append(test.workpath('%d.in' % i)) outfiles.append(test.workpath('%d.out' % i)) test.write(infiles[-1], "\n") - builder = SCons.Builder.Builder(action=SCons.Action.Action(func,None), - single_source = 1, suffix='.out') + builder = SCons.Builder.Builder(action=SCons.Action.Action(func, None), + single_source=True, suffix='.out') env['CNT'] = [0] tgt = builder(env, target=outfiles[0], source=infiles[0])[0] s = str(tgt) diff --git a/SCons/Node/__init__.py b/SCons/Node/__init__.py index dba1c968c..f8dc3b1f0 100644 --- a/SCons/Node/__init__.py +++ b/SCons/Node/__init__.py @@ -215,7 +215,7 @@ def get_contents_dir(node): contents.append('%s %s\n' % (n.get_csig(), n.name)) return ''.join(contents) -def get_contents_file(node): +def get_contents_file(node) -> bytes: if not node.rexists(): return b'' fname = node.rfile().get_abspath() diff --git a/SCons/Tool/Tool.xml b/SCons/Tool/Tool.xml index fcd33fe93..19511fe14 100644 --- a/SCons/Tool/Tool.xml +++ b/SCons/Tool/Tool.xml @@ -36,13 +36,13 @@ if it is not already present. Example: - + # builds foo.c env.CFile(target='foo.c', source='foo.l') # builds bar.c env.CFile(target='bar', source='bar.y') - + @@ -3343,62 +3272,13 @@ it is omitted in this listing for brevity. - -All -targets of builder methods automatically depend on their sources. -An explicit dependency can -be specified using the -&f-link-env-Depends; -method of a &consenv; (see below). - -In addition, -&scons; -automatically scans -source files for various programming languages, -so the dependencies do not need to be specified explicitly. -By default, SCons can -C source files, -C++ source files, -Fortran source files with -.F -(POSIX systems only), -.fpp, -or -.FPP -file extensions, -and assembly language files with -.S -(POSIX systems only), -.spp, -or -.SPP -files extensions -for C preprocessor dependencies. -SCons also has default support -for scanning D source files, -You can also write your own Scanners -to add support for additional source file types. -These can be added to the default -Scanner object used by the -&b-link-Object;, &b-link-StaticObject; and &b-link-SharedObject; -Builders by adding them -to the -SourceFileScanner -object. -See -for more information about -defining your own Scanner objects -and using the -SourceFileScanner -object. - &SCons; Functions and Environment Methods -&SCons; provides a variety of &consenv; methods +&SCons; provides a variety of &consenv; methods and global functions to manipulate the build configuration. Often, a &consenv; method and a global function with the same name exist for convenience. @@ -3441,19 +3321,17 @@ with two key differences: -&Consenv; methods that change the environment +&Consenv; methods that read from or change the environment act on the environment instance from which they are called, -while the corresponding global function acts on -a special “hidden” &consenv; called the Default Environment. -In some cases, the global function may take -an initial argument giving the object to operate on. +while the corresponding global function reads from +a special “hidden” &consenv; called the &DefEnv; String-valued arguments (including strings in list-valued arguments) -are subject to construction variable expansion +are subject to &consvar; expansion by the environment method form; variable expansion is not immediately performed in the global function. For example, Default('$MYTARGET') @@ -5872,7 +5750,7 @@ Adding new Tool modules is described in Builder Objects &scons; -can be extended to build different types of targets +can be extended to build additional types of targets by adding new Builder objects to a &consenv;. In general, @@ -5881,7 +5759,7 @@ when you want to build a new type of file or other external target. For output file types &scons; already knows about, you can usually modify the behavior of premade Builders such as &b-link-Program;, &b-link-Object; or &b-link-Library; -by changing the &consvars; they use +by changing the &consvars; that control their behavior (&cv-link-CC;, &cv-link-LINK;, etc.). In this manner you can, for example, change the compiler to use, which is simpler and less error-prone than writing a new builder. @@ -5893,8 +5771,8 @@ The documentation for each Builder lists which using the &f-link-Builder; factory function. -Once created, a builder is added to an environment -by entering it in the &cv-link-BUILDERS; dictionary +Once created, a builder is added to a &consenv; +by registering it in the &cv-link-BUILDERS; dictionary in that environment (some of the examples in this section illustrate this). Doing so automatically triggers &SCons; to add a method @@ -6427,16 +6305,14 @@ env.MyBuild('sub/dir/foo.out', 'sub/dir/foo.in') -&Python; only keeps one current directory -location even if there are multiple threads. +&Python; only tracks one current directory location, +even if there are multiple executing threads. This means that use of the chdir -argument -will +argument will not -work with the SCons - -option, +work with &SCons; in multi-threaded mode +(the option), because individual worker threads spawned by SCons interfere with each other when they start changing directory. @@ -6448,8 +6324,8 @@ when they start changing directory. Any additional keyword arguments supplied when a Builder object is created (that is, when the &f-link-Builder; function is called) -will be set in the executing construction -environment when the Builder object is called. +will be set in the executing &consenv; +when the Builder object is called. The canonical example here would be to set a &consvar; to the repository of a source code system. @@ -6468,6 +6344,19 @@ and emitter functions. + +When handling errors in a custom builder method, +remember that the corresponding Action is executed at a different +time than the &SConscript; file statement calling the builder. +Wrapping a builder call in a try block +is not useful, +as success of the builder call is not the same as +the build itself succeeding. +If necessary, code a Builder's Action to exit with +a useful exception message indicating the problem in the &SConscript; files. +Programmatic recovery from build errors is rarely useful. + + @@ -6611,7 +6500,7 @@ will expand &consvars; in any argument strings, including action, at the time it is called, -using the construction variables in the &consenv; through which +using the &consvars; in the &consenv; through which it was called. The global function form &f-link-Action; delays variable expansion until the Action object is actually used.