Skip to content

Commit edab5fe

Browse files
committed
More manpage tweaking of Variables and ARGUMENTS
Signed-off-by: Mats Wichmann <[email protected]>
1 parent 4abe243 commit edab5fe

File tree

1 file changed

+59
-43
lines changed

1 file changed

+59
-43
lines changed

doc/man/scons.xml

Lines changed: 59 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -391,8 +391,8 @@ and can be used in the &SConscript; files to modify
391391
the build in any way:</para>
392392

393393
<programlisting language="python">
394-
if ARGUMENTS.get('debug', 0):
395-
env = Environment(CCFLAGS='-g')
394+
if ARGUMENTS.get("debug", ""):
395+
env = Environment(CCFLAGS="-g")
396396
else:
397397
env = Environment()
398398
</programlisting>
@@ -401,8 +401,8 @@ else:
401401
in the <link linkend="v-ARGLIST">&ARGLIST;</link> list,
402402
indexed by their order on the command line.
403403
This allows you to process them in order rather than by name,
404-
if necessary. Each &ARGLIST; entry is a tuple containing
405-
(<replaceable>argname</replaceable>, <replaceable>argvalue</replaceable>).
404+
if necessary. Each &ARGLIST; entry is a tuple consisting
405+
of the name and the value.
406406
</para>
407407

408408
<para>
@@ -3478,20 +3478,20 @@ include:</para>
34783478
<para>In addition to the global functions and methods,
34793479
&scons;
34803480
supports a number of variables
3481-
that can be used in &SConscript; files
3481+
that can be used for run-time queries in &SConscript; files
34823482
to affect how you want the build to be performed.</para>
34833483

34843484
<variablelist>
34853485
<varlistentry id="v-ARGLIST">
34863486
<term>&ARGLIST;</term>
34873487
<listitem>
34883488
<para>A list of the
3489-
<emphasis>keyword</emphasis>=<emphasis>value</emphasis>
3490-
arguments specified on the command line.
3489+
<emphasis>variable</emphasis>=<emphasis>value</emphasis>
3490+
build variable arguments specified on the command line.
34913491
Each element in the list is a tuple
3492-
containing the argument.
3492+
consisting of the variable and its value.
34933493
The separate
3494-
<emphasis>keyword</emphasis>
3494+
<emphasis>variable</emphasis>
34953495
and
34963496
<emphasis>value</emphasis>
34973497
elements of the tuple
@@ -3501,41 +3501,54 @@ subscripting for elements
35013501
and
35023502
<emphasis role="bold">[1]</emphasis>
35033503
of the tuple, or, more readably, by using tuple unpacking.
3504-
Example:</para>
3504+
Examples:</para>
35053505

35063506
<programlisting language="python">
3507-
print("first keyword, value =", ARGLIST[0][0], ARGLIST[0][1])
3508-
print("second keyword, value =", ARGLIST[1][0], ARGLIST[1][1])
3509-
key, value = ARGLIST[2]
3510-
print("third keyword, value =", key, value)
3511-
for key, value in ARGLIST:
3512-
# process key and value
3507+
print("first variable, value =", ARGLIST[0][0], ARGLIST[0][1])
3508+
print("second variable, value =", ARGLIST[1][0], ARGLIST[1][1])
3509+
var, value = ARGLIST[2]
3510+
print("third variable, value =", var, value)
3511+
for var, value in ARGLIST:
3512+
# process variable and value
35133513
</programlisting>
3514+
3515+
<para>
3516+
The values obtained from &ARGLIST;
3517+
(or from <link linkend="v-ARGUMENTS">&ARGUMENTS;</link>)
3518+
are always strings since they originate from outside the &SCons; process.
3519+
As "untrusted data",
3520+
they should be validated before usage,
3521+
and may need conversion to an appropriate type.
3522+
</para>
35143523
</listitem>
35153524
</varlistentry>
35163525

35173526
<varlistentry id="v-ARGUMENTS">
35183527
<term>&ARGUMENTS;</term>
35193528
<listitem>
35203529
<para>A dictionary of all the
3521-
<emphasis>keyword</emphasis>=<emphasis>value</emphasis>
3522-
arguments specified on the command line.
3523-
The dictionary is not in order,
3524-
and if a given keyword has
3530+
<emphasis>variable</emphasis>=<emphasis>value</emphasis>
3531+
build variable arguments specified on the command line.
3532+
The dictionary is in command-line order,
3533+
so if a given variable has
35253534
more than one value assigned to it
35263535
on the command line,
35273536
the last (right-most) value is
3528-
the one in the &ARGUMENTS;
3537+
the one saved in the &ARGUMENTS;
35293538
dictionary.</para>
35303539

35313540
<para>Example:</para>
35323541

35333542
<programlisting language="python">
3534-
if ARGUMENTS.get('debug', 0):
3535-
env = Environment(CCFLAGS='-g')
3543+
if ARGUMENTS.get("debug", ""):
3544+
env = Environment(CCFLAGS="-g")
35363545
else:
35373546
env = Environment()
35383547
</programlisting>
3548+
3549+
<para>
3550+
See also <link linkend="v-ARGLIST">&ARGLIST;</link>.
3551+
</para>
35393552
</listitem>
35403553
</varlistentry>
35413554

@@ -3570,8 +3583,7 @@ list of targets specified using the
35703583
&Default; function,
35713584
the contents of the list may change
35723585
on each successive call to &Default;.
3573-
See the
3574-
&DEFAULT_TARGETS; list, below,
3586+
See <link linkend="v-DEFAULT_TARGETS">&DEFAULT_TARGETS;</link>
35753587
for additional information.</para>
35763588

35773589
<para>Example:</para>
@@ -3590,12 +3602,13 @@ if 'special/program' in BUILD_TARGETS:
35903602
<listitem>
35913603
<para>A list of the targets explicitly specified on
35923604
the command line. If there are command line targets,
3593-
this list will have the same contents as &BUILD_TARGETS;.
3605+
this list has the same contents as
3606+
<link linkend="v-BUILD_TARGETS">&BUILD_TARGETS;</link>.
35943607
If there are no targets specified on the command line,
35953608
the list is empty. The elements of this list are strings.
35963609
This can be used, for example,
35973610
to take specific actions only
3598-
when certain targets are explicitly being built.</para>
3611+
when a certain targets is explicitly requested for building.</para>
35993612

36003613
<para>Example:</para>
36013614

@@ -3617,7 +3630,7 @@ that have been specified using the
36173630
&f-link-Default;
36183631
function. If there are no command line
36193632
targets, this list will have the same contents as
3620-
&BUILD_TARGETS;.
3633+
<link linkend="v-BUILD_TARGETS">&BUILD_TARGETS;</link>.
36213634
Since the elements of the list are nodes,
36223635
you need to call the &Python;
36233636
<function>str</function>
@@ -4656,7 +4669,7 @@ env = conf.Finish()
46564669
<para>Often when building software,
46574670
specialized information needs to be conveyed at build time
46584671
to override the defaults in the build scripts.
4659-
Commandline arguments (like <literal>--implcit-cache</literal>)
4672+
Command-line arguments (like <literal>--implcit-cache</literal>)
46604673
and giving names of build targets are two ways to do that.
46614674
Another is to provide variable-assignment arguments
46624675
on the command line.
@@ -4677,21 +4690,23 @@ Variables specified in the above way
46774690
can be manually processed by accessing the
46784691
<link linkend="v-ARGUMENTS">&ARGUMENTS;</link> dictionary
46794692
(or <link linkend="v-ARGLIST">&ARGLIST;</link> list),
4680-
but using a &Variables; object allows you to describe anticipated
4681-
variables and structure them into types with validation,
4682-
value conversion, defaults, help messages and aliases,
4683-
conceptually similar to the structure of options
4693+
but using a &Variables; object allows you to describe
4694+
anticipated variables,
4695+
convert them to a suitable type if necessary,
4696+
validate the values are within defined constraints,
4697+
and define defaults, help messages and aliases.
4698+
This is conceptually similar to the structure of options
46844699
(see &f-link-AddOption;).
4685-
It also allows pulling variables from a saved
4686-
configuration file or a custom dictionary in an &SConscript; file.
4700+
It also allows obtaining values from a saved variables file,
4701+
or from a custom dictionary in an &SConscript; file.
46874702
The processed variables can then be applied to the desired &consenv;.
46884703
</para>
46894704

46904705
<para>
4691-
Conceptually, arguments are used to convey information to the
4706+
Roughly speaking, arguments are used to convey information to the
46924707
&SCons; program about how it should behave;
46934708
variables are used to convey information to the build
4694-
(though the line between the two is certainly not absolute).
4709+
(although &SCons; does not enforce any such constraint).
46954710
</para>
46964711

46974712
<para>To obtain an object for manipulating variables,
@@ -4731,8 +4746,8 @@ CC = os.environ.get('CC')
47314746
<para>If
47324747
<parameter>args</parameter>
47334748
is specified, it must be a dictionary.
4734-
The key-value pairs will be added to those
4735-
obtained from
4749+
The key-value pairs from <parameter>args</parameter>
4750+
will be added to those obtained from
47364751
<parameter>files</parameter>, if any.
47374752
Keys from <parameter>args</parameter>
47384753
take precendence over same-named keys from <parameter>files</parameter>.
@@ -4799,7 +4814,7 @@ mechanism to define a variable which the user is
47994814
<emphasis>required</emphasis> to supply;
48004815
if necessary this can be implemented by accessing
48014816
<link linkend="v-ARGUMENTS">&ARGUMENTS;</link> directly,
4802-
although that only applies to the command-line,
4817+
although that only applies to the command line,
48034818
not to any stored-values files.
48044819
</para>
48054820

@@ -4884,15 +4899,16 @@ vars.Add('COLOR', validator=valid_color)
48844899
<para>A convenience method that adds
48854900
one or more customizable &consvars;
48864901
to a &Variables; object in one call;
4887-
equivalent to calling &Add; multiple times.
4902+
equivalent to calling
4903+
<link linkend='v-Add'><function>Add</function></link>
4904+
multiple times.
48884905
The <parameter>args</parameter>
48894906
are tuples (or lists)
48904907
that contain the arguments
48914908
for an individual call to the &Add; method.
48924909
Since tuples are not &Python; mappings,
48934910
the arguments cannot use the keyword form,
4894-
but rather are positional arguments as documented for
4895-
<link linkend='v-Add'><function>Add</function></link>:
4911+
but rather are positional arguments as documented for &Add;:
48964912
a required name, the other four optional,
48974913
but must be in the specified order if used.
48984914
</para>

0 commit comments

Comments
 (0)