Skip to content

Commit 2c3983f

Browse files
authored
Merge pull request SCons#4494 from mwichmann/doc/mergeflags
Update MergeFlags doc
2 parents cc96cf3 + 7d30161 commit 2c3983f

File tree

3 files changed

+28
-23
lines changed

3 files changed

+28
-23
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER
110110
(cache-cleanup-error, future-reserved-variable), improve unittest, tweak
111111
Sphinx build.
112112
- Add locking around creation of CacheDir config file. Fixes #4489.
113+
- Clarify MergeFlags usage of a dict argument.
113114

114115

115116
RELEASE 4.6.0 - Sun, 19 Nov 2023 17:22:20 -0700

RELEASE.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ DOCUMENTATION
103103
A warning about overwriting env['ENV'] and one about Configure
104104
checks possibly not running in in no-exec mode also added.
105105
- Clarify how SCons finds the project top directory, and what that is used for.
106+
- Clarify MergeFlags usage of a dict argument.
106107

107108

108109

SCons/Environment.xml

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ In this case, space-separated strings are not split.</para>
638638
</listitem>
639639
<listitem>
640640
<para>A dictionary is processed in order,
641-
adding each key:value pair as a valued macro.
641+
adding each key-value pair as a valued macro.
642642
Use the value <constant>None</constant> if the macro should not have a value.
643643
</para>
644644
</listitem>
@@ -723,7 +723,7 @@ Appending a string <parameter>val</parameter>
723723
to a dictonary-typed &consvar; enters
724724
<parameter>val</parameter> as the key in the dictionary,
725725
and <literal>None</literal> as its value.
726-
Using a tuple type to supply a <literal>key, value</literal>
726+
Using a tuple type to supply a key-value pair
727727
only works for the special case of &cv-CPPDEFINES;
728728
described above.
729729
</para>
@@ -2342,35 +2342,38 @@ env.MergeShellPaths({'INCLUDE': ['c:/inc1', 'c:/inc2']}, prepend=0)
23422342
<para>
23432343
Merges values from
23442344
<parameter>arg</parameter>
2345-
into &consvars; in the current &consenv;.
2346-
If
2347-
<parameter>arg</parameter>
2345+
into &consvars; in <parameter>env</parameter>.
2346+
If <parameter>arg</parameter> is a dictionary,
2347+
each key-value pair represents a
2348+
&consvar; name and the corresponding flags to merge.
2349+
If <parameter>arg</parameter>
23482350
is not a dictionary,
2349-
it is converted to one by calling
2350-
&f-link-env-ParseFlags;
2351-
on the argument
2351+
&MergeFlags; attempts to convert it to one
23522352
before the values are merged.
2353-
Note that
2353+
&f-link-env-ParseFlags; is used for this,
2354+
so values to be converted are subject to the
2355+
same limitations:
2356+
&ParseFlags; has knowledge of which &consvars; certain
2357+
flags should go to, but not all;
2358+
and only for GCC and compatible compiler chains.
23542359
<parameter>arg</parameter>
2355-
must be a single value,
2356-
so multiple strings must
2357-
be passed in as a list,
2358-
not as separate arguments to
2359-
&f-env-MergeFlags;.
2360+
must be a single object,
2361+
so to pass multiple strings,
2362+
enclose them in a list.
23602363
</para>
23612364

23622365
<para>
23632366
If <literal>unique</literal> is true (the default),
2364-
duplicate values are not stored.
2365-
When eliminating duplicate values,
2366-
any &consvars; that end with
2367-
the string
2367+
duplicate values are not retained.
2368+
In case of duplication,
2369+
any &consvar; names that end in
23682370
<literal>PATH</literal>
2369-
keep the left-most unique value.
2371+
keep the left-most value so the
2372+
path searcb order is not altered.
23702373
All other &consvars; keep
2371-
the right-most unique value.
2374+
the right-most value.
23722375
If <literal>unique</literal> is false,
2373-
values are added even if they are duplicates.
2376+
values are appended even if they are duplicates.
23742377
</para>
23752378

23762379
<para>
@@ -2379,14 +2382,14 @@ Examples:
23792382

23802383
<example_commands>
23812384
# Add an optimization flag to $CCFLAGS.
2382-
env.MergeFlags('-O3')
2385+
env.MergeFlags({'CCFLAGS': '-O3'})
23832386

23842387
# Combine the flags returned from running pkg-config with an optimization
23852388
# flag and merge the result into the construction variables.
23862389
env.MergeFlags(['!pkg-config gtk+-2.0 --cflags', '-O3'])
23872390

23882391
# Combine an optimization flag with the flags returned from running pkg-config
2389-
# twice and merge the result into the construction variables.
2392+
# for two distinct packages and merge into the construction variables.
23902393
env.MergeFlags(
23912394
[
23922395
'-O3',

0 commit comments

Comments
 (0)