@@ -2519,7 +2519,7 @@ that can be used in &SConscript; files. Quick links:
2519
2519
<member ><link linkend =' construction_environments' >Construction Environments</link ></member >
2520
2520
<member ><link linkend =' tools' >Tools</link ></member >
2521
2521
<member ><link linkend =' builder_methods' >Builder Methods</link ></member >
2522
- <member ><link linkend =' methods_and_functions_to_do_things ' >Methods and Functions to do Things </link ></member >
2522
+ <member ><link linkend =' env_methods ' >Functions and Environment Methods </link ></member >
2523
2523
<member ><link linkend =' sconscript_variables' >SConscript Variables</link ></member >
2524
2524
<member ><link linkend =' construction_variables' >Construction Variables</link ></member >
2525
2525
<member ><link linkend =' configure_contexts' >Configure Contexts</link ></member >
@@ -3384,89 +3384,98 @@ object.</para>
3384
3384
3385
3385
</refsect2 >
3386
3386
3387
- <refsect2 id =' methods_and_functions_to_do_things ' >
3388
- <title >Methods and Functions To Do Things </title >
3387
+ <refsect2 id =' env_methods ' >
3388
+ <title >&SCons; Functions and Environment Methods </title >
3389
3389
3390
- <para >In addition to Builder methods,
3391
- &scons;
3392
- provides a number of other &consenv; methods
3393
- and global functions to
3394
- manipulate the build configuration.
3395
- Usually, a &consenv; method
3396
- and global function with the same name both exist
3397
- for convenience.
3398
- In the following list, the global function
3399
- is documented in this style:</para >
3390
+ <para >
3391
+ &SCons; provides a variety of &consenv; methods
3392
+ and global functions to manipulate the build configuration.
3393
+ Often, a &consenv; method and a global function with
3394
+ the same name exist for convenience.
3395
+ In this section, both forms are shown if the function can be called
3396
+ in either way.
3397
+ The documentation style for these is as follows:
3398
+ </para >
3400
3399
3401
3400
<programlisting language =" python" >
3402
- <function >Function</function >(<parameter >arguments, [optional arguments]</parameter >)
3401
+ <function >Function</function >(<parameter >arguments, [optional arguments, ...]</parameter >) # Global function
3402
+ <replaceable >env</replaceable >.<methodname >Function</methodname >(<parameter >arguments, [optional arguments, ...]</parameter >) # Environment method
3403
3403
</programlisting >
3404
3404
3405
- <para >and the &consenv; method looks like:</para >
3406
-
3407
- <programlisting language =" python" >
3408
- <replaceable >env</replaceable >.<methodname >Function</methodname >(<parameter >arguments, [optional arguments]</parameter >)
3409
- </programlisting >
3405
+ <para >
3406
+ In these function signatures,
3407
+ arguments in brackets (<literal >[]</literal >) are optional,
3408
+ and ellipses (<literal >...</literal >) indicate possible repetition.
3409
+ Positional vs. keyword arguments are usually detailed
3410
+ in the following text, not in the signature itself.
3411
+ The &Python; positional-only (<literal >/</literal >)
3412
+ and keyword-only (<literal >*</literal >) markers are not used.
3413
+ </para >
3410
3414
3411
- <para >If the function can be called both ways,
3412
- then both forms are listed.</para >
3415
+ <para >
3416
+ When the &Python; <literal >keyword=value</literal > style is shown,
3417
+ it can have two meanings.
3418
+ If the keyword argument is known to the function,
3419
+ the value is the default for that argument if it is omitted.
3420
+ If the keyword is unknown to the function,
3421
+ some methods treat it as a &consvar; assignment;
3422
+ otherwise an exception is raised for an unknown argument.
3423
+ </para >
3413
3424
3414
- <para >The global function and same-named
3415
- &consenv; method
3416
- provide almost identical functionality, with a couple of exceptions.
3417
- First, many of the &consenv; methods affect only that
3418
- &consenv; , while the global function has a
3419
- global effect (or, alternatively, takes an additional
3420
- positional argument to specify the affected &consenv; ).
3421
- Second, where appropriate,
3422
- calling the functionality through a &consenv; will
3423
- substitute &consvars; into
3424
- any supplied string arguments, while the global function,
3425
- unless it takes a &consenv; parameter,
3426
- does not have the context of a &consenv; to pick variables from,
3427
- and thus cannot perform substitutions.
3428
- For example:</para >
3425
+ <para >
3426
+ A global function and a same-named &consenv; method
3427
+ have the same base functionality,
3428
+ with two key differences:
3429
+ </para >
3429
3430
3430
- <programlisting language =" python" >
3431
- Default('$FOO')
3431
+ <orderedlist >
3432
+ <listitem >
3433
+ <para >
3434
+ &Consenv; methods that change the environment
3435
+ act on the environment instance from which they are called,
3436
+ while the corresponding global function acts on
3437
+ a special “hidden” &consenv; called the Default Environment.
3438
+ In some cases, the global function may take
3439
+ an initial argument giving the object to operate on.
3440
+ </para >
3441
+ </listitem >
3442
+ <listitem >
3443
+ <para >
3444
+ String-valued arguments
3445
+ (including strings in list-valued arguments)
3446
+ are subject to construction variable expansion
3447
+ by the environment method form;
3448
+ variable expansion is not immediately performed in the global function.
3449
+ For example, <userinput >Default('$MYTARGET')</userinput >
3450
+ adds <computeroutput >'$MYTARGET'</computeroutput > to the
3451
+ list of default targets,
3452
+ while if the value in <parameter >env</parameter > of
3453
+ <literal >MYTARGET</literal > is <literal >'mine'</literal >,
3454
+ <userinput >env.Default('$MYTARGET'</userinput > adds
3455
+ <computeroutput >'mine'</computeroutput >
3456
+ to the default targets.
3457
+ For more details on &consvar; expansion, see the
3458
+ <link linkend =" construction_variables" >&Consvars; </link > section.
3459
+ </para >
3460
+ </listitem >
3461
+ </orderedlist >
3432
3462
3433
- env = Environment(FOO='foo')
3434
- env.Default('$FOO')
3435
- </programlisting >
3436
-
3437
- <para >In the above example,
3438
- the call to the global &f-Default;
3439
- function will add a target named
3440
- <emphasis role =" bold" >$FOO</emphasis >
3441
- to the list of default targets,
3442
- while the call to the
3443
- &f-env-Default; &consenv; method
3444
- will expand the value
3445
- and add a target named
3446
- <emphasis role =" bold" >foo</emphasis >
3447
- to the list of default targets.
3448
- For more on &consvar; expansion,
3449
- see the
3450
- <link linkend =" construction_variables" >&Consvars; </link >
3451
- section below.
3452
- </para >
3453
-
3454
- <para >
3455
- Global functions are automatically in scope inside
3456
- &SConscript; files.
3457
- If you have custom &Python; code that you import into an &SConscript; file,
3458
- such code will need to bring them into their own scope.
3459
- You can do that by adding the following import
3460
- to the &Python; module:</para >
3463
+ <para >
3464
+ Global functions are automatically in scope inside &SConscript; files.
3465
+ If your project adds &Python; modules that you include
3466
+ via the &Python; <literal >import</literal > statement
3467
+ from an &SConscript; file,
3468
+ such code will need to add the functions
3469
+ to that module’s global scope explicitly.
3470
+ You can do that by adding the following import to the &Python; module:
3471
+ <userinput >from SCons.Script import *</userinput >.
3472
+ </para >
3461
3473
3462
- <programlisting language =" python" >
3463
- from SCons.Script import *
3464
- </programlisting >
3474
+ <para >
3475
+ &SCons; provides the following &consenv; methods and global functions.
3476
+ The list can be augmented on a project basis using &f-link-AddMethod;
3477
+ </para >
3465
3478
3466
- <para >&Consenv; methods
3467
- and global functions provided by
3468
- &scons;
3469
- include:</para >
3470
3479
3471
3480
<!-- '\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -->
3472
3481
<!-- '\" BEGIN GENERATED FUNCTION DESCRIPTIONS -->
0 commit comments