Skip to content

Commit 418f3ea

Browse files
committed
Further tweak CPPDEFINES description [skip appveyor]
Signed-off-by: Mats Wichmann <[email protected]>
1 parent 1deef3b commit 418f3ea

File tree

2 files changed

+41
-42
lines changed

2 files changed

+41
-42
lines changed

SCons/Defaults.xml

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -92,23 +92,24 @@ to each definition in &cv-link-CPPDEFINES;.
9292
<summary>
9393
<para>
9494
A platform independent specification of C preprocessor macro definitions.
95-
The definitions will be added to command lines
95+
The definitions are added to command lines
9696
through the automatically-generated
97-
&cv-link-_CPPDEFFLAGS; &consvar; (see above),
97+
&cv-link-_CPPDEFFLAGS; &consvar;,
9898
which is constructed according to
99-
the type of value of &cv-CPPDEFINES;:
99+
the contents of &cv-CPPDEFINES;:
100100
</para>
101101

102102
<para>
103103
If &cv-CPPDEFINES; is a string,
104104
the values of the
105105
&cv-link-CPPDEFPREFIX; and &cv-link-CPPDEFSUFFIX; &consvars;
106-
will be respectively prepended and appended to
107-
each definition in &cv-CPPDEFINES;.
106+
are respectively prepended and appended to
107+
each definition in &cv-CPPDEFINES;,
108+
split on whitespace.
108109
</para>
109110

110111
<example_commands>
111-
# Will add -Dxyz to POSIX compiler command lines,
112+
# Adds -Dxyz to POSIX compiler command lines,
112113
# and /Dxyz to Microsoft Visual C++ command lines.
113114
env = Environment(CPPDEFINES='xyz')
114115
</example_commands>
@@ -117,15 +118,19 @@ env = Environment(CPPDEFINES='xyz')
117118
If &cv-CPPDEFINES; is a list,
118119
the values of the
119120
&cv-CPPDEFPREFIX; and &cv-CPPDEFSUFFIX; &consvars;
120-
will be respectively prepended and appended to
121+
are respectively prepended and appended to
121122
each element in the list.
122123
If any element is a list or tuple,
123-
then the first item is the name being
124-
defined and the second item is its value:
124+
then the first item is the macro name
125+
and the second item is the definition.
126+
If the definition is not omitted,
127+
these are combined into a
128+
<literal>name=definition</literal> item
129+
before the preending/appending.
125130
</para>
126131

127132
<example_commands>
128-
# Will add -DB=2 -DA to POSIX compiler command lines,
133+
# Adds -DB=2 -DA to POSIX compiler command lines,
129134
# and /DB=2 /DA to Microsoft Visual C++ command lines.
130135
env = Environment(CPPDEFINES=[('B', 2), 'A'])
131136
</example_commands>
@@ -134,48 +139,43 @@ env = Environment(CPPDEFINES=[('B', 2), 'A'])
134139
If &cv-CPPDEFINES; is a dictionary,
135140
the values of the
136141
&cv-CPPDEFPREFIX; and &cv-CPPDEFSUFFIX; &consvars;
137-
will be respectively prepended and appended to
138-
each item from the dictionary.
139-
The key of each dictionary item
140-
is a name being defined
141-
to the dictionary item's corresponding value;
142-
if the value is
143-
<literal>None</literal>,
144-
then the name is defined without an explicit value.
145-
Note that to ensure build order will be stable,
142+
are respectively prepended and appended to
143+
each key from the dictionary.
144+
If the value for a key is not <literal>None</literal>,
145+
then the key is the macro name and the value
146+
is the definition and these are combined into a
147+
<literal>name=definition</literal> item
148+
before the prepending/appending.
149+
Note that to ensure a stable build order,
146150
&SCons; sorts the flags generated from the dictionary,
147151
since a changed command line triggers a rebuild
148152
(older &Python; interpreters did
149-
not guarantee to preserve dictionary keys in insert order),
153+
not guarantee to preserve dictionary keys in insert order).
150154
This precaution may be removed in a future version.
151155
</para>
152156

153157
<example_commands>
154-
# Will add -DA -DB=2 to POSIX compiler command lines,
155-
# and /DA /DB=2 to Microsoft Visual C++ command lines.
158+
# Adds -DA -DB=2 to POSIX compiler command lines,
159+
# or /DA /DB=2 to Microsoft Visual C++ command lines.
156160
env = Environment(CPPDEFINES={'B':2, 'A':None})
157161
</example_commands>
158162

159163
<para>
160164
Depending on how contents are added to &cv-CPPDEFINES;,
161165
it may end up as a compound type,
162166
for example a list containing strings, tuples and/or dictionaries.
163-
&SCons; will still expand this correctly.
167+
&SCons; expands this correctly.
164168
</para>
165169

166170
<para>
167-
Note that if a value contains spaces (or other syntax that
168-
will be meaningful to the shell that calls the compiler)
169-
it needs to be quoted:
171+
Note that &SCons; may call the compiler via a shell.
172+
If a macro definition contains characters such as spaces that
173+
have meaning to the shell, you may need to use the shell's
174+
quoting syntax to avoid interpretation before the
175+
preprocessor sees it. In particular, function-like macros
176+
may be supported (see the documentation for the compiler in question),
177+
but parentheses frequently have meaning to shells.
170178
</para>
171-
172-
<example_commands>
173-
# SPACED will just get the string 'spaced', arg will be a separate arg
174-
env = Environment(CPPDEFINES={'SPACED': 'spaced arg'})
175-
# SPACED will get the full value
176-
env = Environment(CPPDEFINES={'SPACED': '"spaced arg"'})
177-
</example_commands>
178-
179179
</summary>
180180
</cvar>
181181

SCons/Environment.xml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -613,13 +613,12 @@ scons: `.' is up to date.
613613
<para>
614614
Multiple &cv-CPPDEFINES; macros can be supplied in a sequence of tuples,
615615
or using the dictionary form.
616-
If a given macro should not have a value,
616+
If a given macro name should not have a definition,
617617
the value can be omitted from the given tuple;
618-
for the dictionary form,
618+
if using the dictionary form,
619619
specify the value as <constant>None</constant>.
620620
</para>
621621

622-
<!--TODO: at last check, this newly created example blew up SConsDoc/lxml -->
623622
<example_commands>
624623
env = Environment()
625624
env.Append(CPPDEFINES =[("ONE", 1), ("TWO", )])
@@ -643,18 +642,18 @@ See &cv-link-CPPDEFINES; for more details.
643642

644643
<para>
645644
Adding a string <parameter>val</parameter>
646-
to a dictonary &consvar; will enter
647-
<parameter>val</parameter> as the key in the dict,
645+
to a dictonary-typed &consvar; enters
646+
<parameter>val</parameter> as the key in the dictionary,
648647
and <literal>None</literal> as its value.
649-
Using a tuple type to supply a key + value only works
650-
for the special case of &cv-CPPDEFINES;
648+
Using a tuple type to supply a <literal>key, value</literal>
649+
only works for the special case of &cv-CPPDEFINES;
651650
described above.
652651
</para>
653652

654653
<para>
655654
Although most combinations of types work without
656655
needing to know the details, some combinations
657-
do not make sense and a &Python; exception will be raised.
656+
do not make sense and &Python; raises an exception.
658657
</para>
659658

660659
<para>

0 commit comments

Comments
 (0)