forked from SCons/scons
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEnvironment.xml
More file actions
3835 lines (3473 loc) · 97.7 KB
/
Environment.xml
File metadata and controls
3835 lines (3473 loc) · 97.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?xml version="1.0"?>
<!--
SPDX-FileCopyrightText: Copyright The SCons Foundation (https://scons.org)
SPDX-License-Identifier: MIT
SPDX-FileType: DOCUMENTATION
This file is processed by the bin/SConsDoc.py module.
-->
<!DOCTYPE sconsdoc [
<!ENTITY % scons SYSTEM '../doc/scons.mod'>
%scons;
<!ENTITY % builders-mod SYSTEM '../doc/generated/builders.mod'>
%builders-mod;
<!ENTITY % functions-mod SYSTEM '../doc/generated/functions.mod'>
%functions-mod;
<!ENTITY % tools-mod SYSTEM '../doc/generated/tools.mod'>
%tools-mod;
<!ENTITY % variables-mod SYSTEM '../doc/generated/variables.mod'>
%variables-mod;
]>
<sconsdoc xmlns="http://www.scons.org/dbxsd/v1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.scons.org/dbxsd/v1.0 http://www.scons.org/dbxsd/v1.0/scons.xsd">
<!-- Construction variables -->
<cvar name="BUILDERS">
<summary>
<para>
A dictionary mapping the names of the builders
available through the &consenv; to underlying Builder objects.
Custom builders need to be added to this to make them available.
</para>
<para>
A platform-dependent default list of builders such as
&b-link-Program;, &b-link-Library; etc. is used to
populate this &consvar; when the &consenv; is initialized
via the presence/absence of the tools those builders depend on.
&cv-BUILDERS; can be examined to learn which builders will
actually be available at run-time.
</para>
<para>
Note that if you initialize this &consvar; through
assignment when the &consenv; is created,
that value for &cv-BUILDERS; will override any defaults:
</para>
<example_commands>
bld = Builder(action='foobuild < $SOURCE > $TARGET')
env = Environment(BUILDERS={'NewBuilder': bld})
</example_commands>
<para>
To instead use a new Builder object in addition to the default Builders,
add your new Builder object like this:
</para>
<example_commands>
env = Environment()
env.Append(BUILDERS={'NewBuilder': bld})
</example_commands>
<para>
or this:
</para>
<example_commands>
env = Environment()
env['BUILDERS']['NewBuilder'] = bld
</example_commands>
</summary>
</cvar>
<cvar name="ENV">
<summary>
<para>
The <firstterm>execution environment</firstterm> -
a dictionary of environment variables
used when &SCons; invokes external commands
to build targets defined in this &consenv;.
When &cv-ENV; is passed to a command,
all list values are assumed to be path lists and
are joined using the search path separator.
Any other non-string values are coerced to a string.
</para>
<para>
Note that by default
&SCons;
does
<emphasis>not</emphasis>
propagate the environment in effect when you execute
&scons; (the "shell environment")
to the execution environment.
This is so that builds will be guaranteed
repeatable regardless of the environment
variables set at the time
&scons;
is invoked.
If you want to propagate a
shell environment variable
to the commands executed
to build target files,
you must do so explicitly.
A common example is
the system &PATH;
environment variable,
so that
&scons;
will find utilities the same way
as the invoking shell (or other process):
</para>
<example_commands>
import os
env = Environment(ENV={'PATH': os.environ['PATH']})
</example_commands>
<para>
Although it is usually not recommended,
you can propagate the entire shell environment
in one go:
</para>
<example_commands>
import os
env = Environment(ENV=os.environ.copy())
</example_commands>
</summary>
</cvar>
<cvar name="SCANNERS">
<summary>
<para>
A list of the available implicit dependency scanners.
New file scanners may be added by
appending to this list,
although the more flexible approach
is to associate scanners
with a specific Builder.
See the manpage sections "Builder Objects"
and "Scanner Objects"
for more information.
</para>
</summary>
</cvar>
<cvar name="CHANGED_SOURCES">
<summary>
<para>
A reserved variable name
that may not be set or used in a &consenv;.
(See the manpage section "Variable Substitution"
for more information).
</para>
</summary>
</cvar>
<cvar name="CHANGED_TARGETS">
<summary>
<para>
A reserved variable name
that may not be set or used in a &consenv;.
(See the manpage section "Variable Substitution"
for more information).
</para>
</summary>
</cvar>
<cvar name="SOURCE">
<summary>
<para>
A reserved variable name
that may not be set or used in a &consenv;.
(See the manpage section "Variable Substitution"
for more information).
</para>
</summary>
</cvar>
<cvar name="SOURCES">
<summary>
<para>
A reserved variable name
that may not be set or used in a &consenv;.
(See the manpage section "Variable Substitution"
for more information).
</para>
</summary>
</cvar>
<cvar name="TARGET">
<summary>
<para>
A reserved variable name
that may not be set or used in a &consenv;.
(See the manpage section "Variable Substitution"
for more information).
</para>
</summary>
</cvar>
<cvar name="TARGETS">
<summary>
<para>
A reserved variable name
that may not be set or used in a &consenv;.
(See the manpage section "Variable Substitution"
for more information).
</para>
</summary>
</cvar>
<cvar name="UNCHANGED_SOURCES">
<summary>
<para>
A reserved variable name
that may not be set or used in a &consenv;.
(See the manpage section "Variable Substitution"
for more information).
</para>
</summary>
</cvar>
<cvar name="UNCHANGED_TARGETS">
<summary>
<para>
A reserved variable name
that may not be set or used in a &consenv;.
(See the manpage section "Variable Substitution"
for more information).
</para>
</summary>
</cvar>
<cvar name="TOOLS">
<summary>
<para>
A list of the names of the Tool specification modules
that were actually initialized in the current &consenv;.
This may be useful as a diagnostic aid
to see if a tool did (or did not) run.
The value is informative and is not guaranteed to be complete.
</para>
</summary>
</cvar>
<cvar name="CACHEDIR_CLASS">
<summary>
<para>
The class type that SCons should use when instantiating a
new &f-link-CacheDir; in this &consenv;. Must be
a subclass of the <classname>SCons.CacheDir.CacheDir</classname> class.
</para>
</summary>
</cvar>
<!-- Functions / Construction environment methods -->
<scons_function name="Action">
<arguments>
(action, [output, [var, ...]] [key=value, ...])
</arguments>
<summary>
<para>
A factory function to create an Action object for
the specified
<parameter>action</parameter>.
See the manpage section "Action Objects"
for a complete explanation of the arguments and behavior.
</para>
<para>
Note that the &f-env-Action;
form of the invocation will expand
&consvars; in any argument strings,
including the
<parameter>action</parameter>
argument, at the time it is called
using the &consvars; in the
&consenv; through which
&f-env-Action; was called.
The &f-Action; global function
form delays all variable expansion
until the Action object is actually used.
</para>
</summary>
</scons_function>
<scons_function name="AddMethod">
<arguments signature="global">
(object, function, [name])
</arguments>
<arguments signature="env">
(function, [name])
</arguments>
<summary>
<para>
Adds <parameter>function</parameter> to an object as a method.
<parameter>function</parameter> will be called with an instance
object as the first argument as for other methods.
If <parameter>name</parameter> is given, it is used as
the name of the new method, else the name of
<parameter>function</parameter> is used.
</para>
<para>
When the global function &f-AddMethod; is called,
the object to add the method to must be passed as the first argument;
typically this will be &Environment;,
in order to create a method which applies to all &consenvs;
subsequently constructed.
When called using the &f-env-AddMethod; form,
the method is added to the specified &consenv; only.
Added methods propagate through &f-env-Clone; calls.
</para>
<para>
More examples:
</para>
<example_commands>
# Function to add must accept an instance argument.
# The Python convention is to call this 'self'.
def my_method(self, arg):
print("my_method() got", arg)
# Use the global function to add a method to the Environment class:
AddMethod(Environment, my_method)
env = Environment()
env.my_method('arg')
# Use the optional name argument to set the name of the method:
env.AddMethod(my_method, 'other_method_name')
env.other_method_name('another arg')
</example_commands>
</summary>
</scons_function>
<scons_function name="AddPostAction">
<arguments>
(target, action)
</arguments>
<summary>
<para>
Arranges for the specified
<parameter>action</parameter>
to be performed
after the specified
<parameter>target</parameter>
has been built.
<parameter>action</parameter> may be
an Action object, or anything that
can be converted into an Action object.
See the manpage section "Action Objects"
for a complete explanation.
</para>
<para>
When multiple targets are supplied,
the action may be called multiple times,
once after each action that generates
one or more targets in the list.
</para>
<example_commands>
foo = Program('foo.c')
# remove execute permission from binary:
AddPostAction(foo, Chmod('$TARGET', "a-x"))
</example_commands>
</summary>
</scons_function>
<scons_function name="AddPreAction">
<arguments>
(target, action)
</arguments>
<summary>
<para>
Arranges for the specified
<parameter>action</parameter>
to be performed
before the specified
<parameter>target</parameter>
is built.
<parameter>action</parameter> may be
an Action object, or anything that
can be converted into an Action object.
See the manpage section "Action Objects"
for a complete explanation.
</para>
<para>
When multiple targets are specified,
the action(s) may be called multiple times,
once before each action that generates
one or more targets in the list.
</para>
<para>
Note that if any of the targets are built in multiple steps,
the action will be invoked just
before the "final" action that specifically
generates the specified target(s).
For example, when building an executable program
from a specified source
<filename>.c</filename>
file via an intermediate object file:
</para>
<example_commands>
foo = Program('foo.c')
AddPreAction(foo, 'pre_action')
</example_commands>
<para>
The specified
<literal>pre_action</literal>
would be executed before
&scons;
calls the link command that actually
generates the executable program binary
<filename>foo</filename>,
not before compiling the
<filename>foo.c</filename>
file into an object file.
</para>
</summary>
</scons_function>
<scons_function name="Alias">
<arguments>
(alias, [source, [action]])
</arguments>
<summary>
<para>
Creates an <firstterm>alias</firstterm> target that
can be used as a reference to zero or more other targets,
specified by the optional <parameter>source</parameter> parameter.
Aliases provide a way to give a shorter or more descriptive
name to specific targets,
and to group multiple targets under a single name.
The alias name, or an Alias Node object,
may be used as a dependency of any other target,
including another alias.
</para>
<para>
<parameter>alias</parameter> and <parameter>source</parameter>
may each be a string or Node object,
or a list of strings or Node objects;
if Nodes are used for
<parameter>alias</parameter>
they must be Alias nodes.
If <parameter>source</parameter> is omitted,
the alias is created but has no reference;
if selected for building this will result in a
<quote>Nothing to be done.</quote> message.
An empty alias can be used to define the alias
in a visible place in the project;
it can later be appended to in a subsidiary SConscript file
with the actual target(s) to refer to.
The optional
<parameter>action</parameter>
parameter specifies an action or list of actions
that will be executed
whenever the any of the alias targets are out-of-date.
</para>
<para>
&f-Alias; can be called for an existing alias,
which appends the <parameter>alias</parameter>
and/or <parameter>action</parameter> arguments
to the existing lists for that alias.
</para>
<para>
Returns a list of Alias Node objects representing the alias(es),
which exist outside of any physical file system.
The alias name space is separate from the name space for
tangible targets; to avoid confusion do not reuse
target names as alias names.
</para>
<para>
Examples:
</para>
<example_commands>
Alias('install')
Alias('install', '/usr/bin')
Alias(['install', 'install-lib'], '/usr/local/lib')
env.Alias('install', ['/usr/local/bin', '/usr/local/lib'])
env.Alias('install', ['/usr/local/man'])
env.Alias('update', ['file1', 'file2'], "update_database $SOURCES")
</example_commands>
</summary>
</scons_function>
<scons_function name="AlwaysBuild">
<arguments>
(target, ...)
</arguments>
<summary>
<para>
Marks each given
<parameter>target</parameter>
so that it is always assumed to be out-of-date,
and will always be rebuilt if needed.
Note, however, that
&f-AlwaysBuild;
does not add its target(s) to the default target list,
so the targets will only be built
if they are specified on the command line,
or are a dependent of a target specified on the command line--but
they will
<emphasis>always</emphasis>
be built if so specified.
Multiple targets can be passed in to a single call to
&f-AlwaysBuild;.
</para>
</summary>
</scons_function>
<scons_function name="Append">
<arguments signature="env">
(key=val, [...])
</arguments>
<summary>
<para>
Appends value(s) intelligently to &consvars; in
<varname>env</varname>.
The &consvars; and values to add to them are passed as
<parameter>key=val</parameter> pairs (&Python; keyword arguments).
&f-env-Append; is designed to allow adding values
without having to think about the data type of an existing &consvar;.
Regular &Python; syntax can also be used to manipulate the &consvar;,
but for that you may need to know the types involved,
for example pure &Python; lets you directly "add" two lists of strings,
but adding a string to a list or a list to a string requires
different syntax - things &f-Append; takes care of.
Some pre-defined &consvars; do have type expectations
based on how &SCons; will use them:
for example &cv-link-CPPDEFINES; is often a string or a list of strings,
but can also be a list of tuples or a dictionary;
while &cv-link-LIBEMITTER;
is expected to be a callable or list of callables,
and &cv-link-BUILDERS; is expected to be a dictionary.
Consult the documentation for the various &consvars; for more details.
</para>
<para>
The following descriptions apply to both the &f-Append;
and &f-Prepend; methods, as well as their
<emphasis role="bold">Unique</emphasis> variants,
with the differences being the insertion point of the added values
and whether duplication is allowed.
</para>
<para>
<parameter>val</parameter> can be almost any type.
If <varname>env</varname> does not have a &consvar;
named <parameter>key</parameter>,
then <parameter>key</parameter> is simply
stored with a value of <parameter>val</parameter>.
Otherwise, <parameter>val</parameter> is
combined with the existing value,
possibly converting into an appropriate type
which can hold the expanded contents.
There are a few special cases to be aware of.
Normally, when two strings are combined,
the result is a new string containing their concatenation
(and you are responsible for supplying any needed separation);
however, the contents of &cv-link-CPPDEFINES;
will be post-processed by adding a prefix and/or suffix
to each entry when the command line is produced,
so &SCons; keeps them separate -
appending a string will result in a separate string entry,
not a combined string.
For &cv-CPPDEFINES;. as well as
&cv-link-LIBS;, and the various <literal>*PATH</literal> variables,
&SCons; will amend the variable by supplying the compiler-specific
syntax (e.g. prepending a <literal>-D</literal> or <literal>/D</literal>
prefix for &cv-CPPDEFINES;), so you should omit this syntax when
adding values to these variables.
Examples (gcc syntax shown in the expansion of &CPPDEFINES;):
</para>
<example_commands>
env = Environment(CXXFLAGS="-std=c11", CPPDEFINES="RELEASE")
print(f"CXXFLAGS = {env['CXXFLAGS']}, CPPDEFINES = {env['CPPDEFINES']}")
# notice including a leading space in CXXFLAGS addition
env.Append(CXXFLAGS=" -O", CPPDEFINES="EXTRA")
print(f"CXXFLAGS = {env['CXXFLAGS']}, CPPDEFINES = {env['CPPDEFINES']}")
print("CPPDEFINES will expand to", env.subst('$_CPPDEFFLAGS'))
</example_commands>
<screen>
$ scons -Q
CXXFLAGS = -std=c11, CPPDEFINES = RELEASE
CXXFLAGS = -std=c11 -O, CPPDEFINES = deque(['RELEASE', 'EXTRA'])
CPPDEFINES will expand to -DRELEASE -DEXTRA
scons: `.' is up to date.
</screen>
<para>
Because &cv-link-CPPDEFINES; is intended for command-line
specification of C/C++ preprocessor macros,
additional syntax is accepted when adding to it.
The preprocessor accepts arguments to predefine a macro name by itself
(<computeroutput>-DFOO</computeroutput> for most compilers,
<computeroutput>/DFOO</computeroutput> for Microsoft C++),
which gives it an implicit value of <constant>1</constant>,
or can be given with a replacement value
(<computeroutput>-DBAR=TEXT</computeroutput>).
&SCons; follows these rules when adding to &cv-CPPDEFINES;:
</para>
<itemizedlist>
<listitem>
<para>A string is split on spaces,
giving an easy way to enter multiple macros in one addition.
Use an <literal>=</literal> to specify a valued macro.</para>
</listitem>
<listitem>
<para>A tuple is treated as a valued macro.
Use the value <constant>None</constant> if the macro should not have a value.
It is an error to supply more than two elements in such a tuple.</para>
</listitem>
<listitem>
<para>A list is processed in order,
adding each item without further interpretation.
In this case, space-separated strings are not split.</para>
</listitem>
<listitem>
<para>A dictionary is processed in order,
adding each key-value pair as a valued macro.
Use the value <constant>None</constant> if the macro should not have a value.
</para>
</listitem>
</itemizedlist>
<para>
Examples:
</para>
<example_commands>
env = Environment(CPPDEFINES="FOO")
print("CPPDEFINES =", env['CPPDEFINES'])
env.Append(CPPDEFINES="BAR=1")
print("CPPDEFINES =", env['CPPDEFINES'])
env.Append(CPPDEFINES=[("OTHER", 2)])
print("CPPDEFINES =", env['CPPDEFINES'])
env.Append(CPPDEFINES={"EXTRA": "arg"})
print("CPPDEFINES =", env['CPPDEFINES'])
print("CPPDEFINES will expand to", env.subst('$_CPPDEFFLAGS'))
</example_commands>
<screen>
$ scons -Q
CPPDEFINES = FOO
CPPDEFINES = deque(['FOO', 'BAR=1'])
CPPDEFINES = deque(['FOO', 'BAR=1', ('OTHER', 2)])
CPPDEFINES = deque(['FOO', 'BAR=1', ('OTHER', 2), ('EXTRA', 'arg')])
CPPDEFINES will expand to -DFOO -DBAR=1 -DOTHER=2 -DEXTRA=arg
scons: `.' is up to date.
</screen>
<para>
Examples of adding multiple macros:
</para>
<example_commands>
env = Environment()
env.Append(CPPDEFINES=[("ONE", 1), "TWO", ("THREE", )])
print("CPPDEFINES =", env['CPPDEFINES'])
env.Append(CPPDEFINES={"FOUR": 4, "FIVE": None})
print("CPPDEFINES =", env['CPPDEFINES'])
print("CPPDEFINES will expand to", env.subst('$_CPPDEFFLAGS'))
</example_commands>
<screen>
$ scons -Q
CPPDEFINES = [('ONE', 1), 'TWO', ('THREE',)]
CPPDEFINES = deque([('ONE', 1), 'TWO', ('THREE',), ('FOUR', 4), ('FIVE', None)])
CPPDEFINES will expand to -DONE=1 -DTWO -DTHREE -DFOUR=4 -DFIVE
scons: `.' is up to date.
</screen>
<para>
<emphasis>Changed in version 4.5</emphasis>:
clarified the use of tuples vs. other types,
handling is now consistent across the four functions.
</para>
<example_commands>
env = Environment()
env.Append(CPPDEFINES=("MACRO1", "MACRO2"))
print("CPPDEFINES =", env['CPPDEFINES'])
env.Append(CPPDEFINES=[("MACRO3", "MACRO4")])
print("CPPDEFINES =", env['CPPDEFINES'])
print("CPPDEFINES will expand to", env.subst('$_CPPDEFFLAGS'))
</example_commands>
<screen>
$ scons -Q
CPPDEFINES = ('MACRO1', 'MACRO2')
CPPDEFINES = deque(['MACRO1', 'MACRO2', ('MACRO3', 'MACRO4')])
CPPDEFINES will expand to -DMACRO1 -DMACRO2 -DMACRO3=MACRO4
scons: `.' is up to date.
</screen>
<para>
See &cv-link-CPPDEFINES; for more details.
</para>
<para>
Appending a string <parameter>val</parameter>
to a dictionary-typed &consvar; enters
<parameter>val</parameter> as the key in the dictionary,
and <literal>None</literal> as its value.
Using a tuple type to supply a key-value pair
only works for the special case of &cv-CPPDEFINES;
described above.
</para>
<para>
Although most combinations of types work without
needing to know the details, some combinations
do not make sense and &Python; raises an exception.
</para>
<para>
When using &f-env-Append; to modify &consvars;
which are path specifications (conventionally,
the names of such end in <literal>PATH</literal>),
it is recommended to add the values as a list of strings,
even if you are only adding a single string.
The same goes for adding library names to &cv-LIBS;.
</para>
<example_commands>
env.Append(CPPPATH=["#/include"])
</example_commands>
<para>
See also &f-link-env-AppendUnique;,
&f-link-env-Prepend; and &f-link-env-PrependUnique;.
</para>
</summary>
</scons_function>
<scons_function name="AppendENVPath">
<arguments signature="env">
(name, newpath, [envname, sep, delete_existing=False])
</arguments>
<summary>
<para>
Append path elements specified by <parameter>newpath</parameter>
to the given search path string or list <parameter>name</parameter>
in mapping <parameter>envname</parameter> in the &consenv;.
Supplying <parameter>envname</parameter> is optional:
the default is the execution environment &cv-link-ENV;.
Optional <parameter>sep</parameter> is used as the search path separator,
the default is the platform's separator (<systemitem>os.pathsep</systemitem>).
A path element will only appear once.
Any duplicates in <parameter>newpath</parameter> are dropped,
keeping the last appearing (to preserve path order).
If <parameter>delete_existing</parameter>
is <constant>False</constant> (the default)
any addition duplicating an existing path element is ignored;
if <parameter>delete_existing</parameter>
is <constant>True</constant> the existing value will
be dropped and the path element will be added at the end.
To help maintain uniqueness all paths are normalized (using
<systemitem>os.path.normpath</systemitem>
and
<systemitem>os.path.normcase</systemitem>).
</para>
<para>
Example:
</para>
<example_commands>
print('before:', env['ENV']['INCLUDE'])
include_path = '/foo/bar:/foo'
env.AppendENVPath('INCLUDE', include_path)
print('after:', env['ENV']['INCLUDE'])
</example_commands>
<para>Yields:</para>
<screen>
before: /foo:/biz
after: /biz:/foo/bar:/foo
</screen>
<para>
See also &f-link-env-PrependENVPath;.
</para>
</summary>
</scons_function>
<scons_function name="AppendUnique">
<arguments signature="env">
(key=val, [...], [delete_existing=False])
</arguments>
<summary>
<para>
Append values to &consvars; in the current &consenv;,
maintaining uniqueness.
Works like &f-link-env-Append;,
except that values that would become duplicates
are not added.
If <parameter>delete_existing</parameter>
is set to a true value, then for any duplicate,
the existing instance of <parameter>val</parameter> is first removed,
then <parameter>val</parameter> is appended,
having the effect of moving it to the end.
</para>
<para>
Example:
</para>
<example_commands>
env.AppendUnique(CCFLAGS='-g', FOO=['foo.yyy'])
</example_commands>
<para>
See also &f-link-env-Append;,
&f-link-env-Prepend;
and &f-link-env-PrependUnique;.
</para>
</summary>
</scons_function>
<scons_function name="Builder">
<arguments>
(action, [arguments])
</arguments>
<summary>
<para>
Creates a Builder object for
the specified
<parameter>action</parameter>.
See the manpage section "Builder Objects"
for a complete explanation of the arguments and behavior.
</para>
<para>
Note that the
<function>env.Builder</function>()
form of the invocation will expand
&consvars; in any arguments strings,
including the
<parameter>action</parameter>
argument,
at the time it is called
using the &consvars; in the
<varname>env</varname>
&consenv; through which
&f-env-Builder; was called.
The
&f-Builder;
form delays all variable expansion
until after the Builder object is actually called.
</para>
</summary>
</scons_function>
<scons_function name="CacheDir">
<arguments>
(cache_dir, custom_class=None)
</arguments>
<summary>
<para>
Direct
&scons;
to maintain a derived-file cache in
<parameter>cache_dir</parameter>.
The derived files in the cache will be shared
among all the builds specifying the same
<parameter>cache_dir</parameter>.
Specifying a
<parameter>cache_dir</parameter>
of
<constant>None</constant>
disables derived file caching.
</para>
<para>
Calling the environment method
&f-link-env-CacheDir;
limits the effect to targets built
through the specified &consenv;.
Calling the global function
&f-link-CacheDir;
sets a global default
that will be used by all targets built
through &consenvs;
that do not set up environment-specific
caching by calling &f-env-CacheDir;.
</para>
<para>
Caching behavior can be configured by passing a specialized cache
class as the optional <parameter>custom_class</parameter> parameter.
This class must be a subclass of
<classname>SCons.CacheDir.CacheDir</classname>.
&SCons; will internally invoke the custom class for performing
caching operations.
If the parameter is omitted or set to
<constant>None</constant>, &SCons; will use the default
<classname>SCons.CacheDir.CacheDir</classname> class.
</para>
<para>
When derived-file caching
is being used and
&scons;
finds a derived file that needs to be rebuilt,
it will first look in the cache to see if a
file with matching &buildsig; exists
(indicating the input file(s) and build action(s)
were identical to those for the current target),
and if so, will retrieve the file from the cache.
&scons;
will report
<computeroutput>Retrieved `file' from cache</computeroutput>
instead of the normal build message.
If the derived file is not present in the cache,
&scons;
will build it and
then place a copy of the built file in the cache,
identified by its &buildsig;, for future use.
</para>
<para>
The
<computeroutput>Retrieved `file' from cache</computeroutput>
messages are useful for human consumption,
but less useful when comparing log files between
&scons; runs which will show differences that are
noisy and not actually significant.
To disable,
use the <option>--cache-show</option> option.
With this option, &scons; changes printing
to always show the action that would
have been used to build the file without caching.
</para>
<para>
Derived-file caching
may be disabled for any invocation
of &scons; by giving the
<option>--cache-disable</option>
command line option;
cache updating may be disabled, leaving cache
fetching enabled, by giving the
<option>--cache-readonly</option> option.
</para>
<para>
If the
<option>--cache-force</option>
option is used,
&scons;
will place a copy of
<emphasis>all</emphasis>
derived files into the cache,
even if they already existed
and were not built by this invocation.
This is useful to populate a cache
the first time a
<parameter>cache_dir</parameter>
is used for a build,
or to bring a cache up to date after
a build with cache updating disabled
(<option>--cache-disable</option>
or <option>--cache-readonly</option>)
has been done.
</para>
<para>
The
&f-link-NoCache;
method can be used to disable caching of specific files. This can be
useful if inputs and/or outputs of some tool are impossible to
predict or prohibitively large.
</para>