@@ -3171,8 +3171,8 @@ def create(target, source, env):
31713171 # A function that will write a 'prefix=$SOURCE'
31723172 # string into the file name specified as the
31733173 # $TARGET.
3174- f = open(str(target[0]), 'wb')
3175- f.write('prefix=' + source[0].get_contents())
3174+ with open(str(target[0]), 'wb') as f:
3175+ f.write('prefix=' + source[0].get_contents())
31763176
31773177# Fetch the prefix= argument, if any, from the command
31783178# line, and use /usr/local as the default.
@@ -3206,90 +3206,75 @@ env.UpdateValue(target = Value(output), source = Value(input))
32063206</arguments >
32073207<summary >
32083208<para >
3209- Use the
3210- &f-VariantDir;
3211- function to create a copy of your sources in another location:
3212- if a name under
3213- <parameter >variant_dir</parameter >
3214- is not found but exists under
3215- <parameter >src_dir</parameter >,
3216- the file or directory is copied to
3217- <parameter >variant_dir</parameter >.
3218- Target files can be built in a different directory
3219- than the original sources by simply refering to the sources (and targets)
3220- within the variant tree.
3221- </para >
3222-
3223- <para >
3209+ Sets up an alternate build location.
3210+ When building in the <parameter >variant_dir</parameter >,
3211+ &SCons; backfills as needed with files from <parameter >src_dir</parameter >
3212+ to create a complete build directory.
32243213&f-VariantDir;
32253214can be called multiple times with the same
32263215<parameter >src_dir</parameter >
32273216to set up multiple builds with different options
3228- (<parameter >variants</parameter >).
3217+ (<emphasis >variants</emphasis >).
3218+ </para >
3219+
3220+ <para >
32293221The
3230- <parameter >src_dir </parameter >
3231- location must be in or underneath the SConstruct file's directory, and
3232- <parameter >variant_dir </parameter >
3222+ <parameter >variant </parameter >
3223+ location must be in or underneath the project top directory,
3224+ and <parameter >src_dir </parameter >
32333225may not be underneath
3234- <parameter >src_dir</parameter >.
3235- <!--
3236- TODO: Can the above restrictions be clarified or relaxed?
3237- TODO: The latter restriction is clearly not completely right;
3238- TODO: src_dir = '.' works fine with a build dir under it.
3239- -->
3226+ <parameter >variant_dir</parameter >.
32403227</para >
32413228
32423229<para >
3243- The default behavior is for
3244- &scons;
3245- to physically duplicate the source files in the variant tree.
3230+ By default, &SCons;
3231+ physically duplicates the source files and SConscript files
3232+ as needed into the variant tree.
32463233Thus, a build performed in the variant tree is guaranteed to be identical
32473234to a build performed in the source tree even if
32483235intermediate source files are generated during the build,
3249- or preprocessors or other scanners search for included files
3236+ or if preprocessors or other scanners search for included files
32503237relative to the source file,
3251- or individual compilers or other invoked tools are hard-coded
3238+ or if individual compilers or other invoked tools are hard-coded
32523239to put derived files in the same directory as source files.
3240+ Only the files &SCons; calculates are needed for the build are
3241+ duplicated into <parameter >variant_dir</parameter >.
32533242</para >
32543243
32553244<para >
32563245If possible on the platform,
3257- the duplication is performed by linking rather than copying;
3258- see also the
3246+ the duplication is performed by linking rather than copying.
3247+ This behavior is affected by the
32593248<option >--duplicate</option >
32603249command-line option.
3261- Moreover, only the files needed for the build are duplicated;
3262- files and directories that are not used are not present in
3263- <parameter >variant_dir</parameter >.
32643250</para >
32653251
32663252<para >
3267- Duplicating the source tree may be disabled by setting the
3268- <literal >duplicate</literal >
3253+ Duplicating the source files may be disabled by setting the
3254+ <parameter >duplicate</parameter >
32693255argument to
3270- <literal >0</literal >
3271- (zero).
3256+ <constant >False</constant >.
32723257This will cause
3273- &scons ;
3258+ &SCons ;
32743259to invoke Builders using the path names of source files in
32753260<parameter >src_dir</parameter >
32763261and the path names of derived files within
32773262<parameter >variant_dir</parameter >.
3278- This is always more efficient than
3279- <literal >duplicate=1</literal >,
3280- and is usually safe for most builds
3281- (but see above for cases that may cause problems).
3263+ This is more efficient than
3264+ <literal >duplicate=True</literal >,
3265+ and is safe for most builds;
3266+ revert to <constant >True</constant >
3267+ if it causes problems.
32823268</para >
32833269
32843270<para >
3285- Note that
32863271&f-VariantDir;
3287- works most naturally with a subsidiary SConscript file.
3288- However, you would then call the subsidiary SConscript file
3289- not in the source directory, but in the
3272+ works most naturally with used with a subsidiary SConscript file.
3273+ The subsidiary SConscript file is called as if it
3274+ were in
32903275<parameter >variant_dir</parameter >,
32913276regardless of the value of
3292- <literal >duplicate</literal >.
3277+ <parameter >duplicate</parameter >.
32933278This is how you tell
32943279&scons;
32953280which variant of a source tree to build:
@@ -3319,15 +3304,11 @@ Examples:
33193304# use names in the build directory, not the source directory
33203305VariantDir('build', 'src', duplicate=0)
33213306Program('build/prog', 'build/source.c')
3322- </example_commands >
33233307
3324- <example_commands >
33253308# this builds both the source and docs in a separate subtree
33263309VariantDir('build', '.', duplicate=0)
33273310SConscript(dirs=['build/src','build/doc'])
3328- </example_commands >
33293311
3330- <example_commands >
33313312# same as previous example, but only uses SConscript
33323313SConscript(dirs='src', variant_dir='build/src', duplicate=0)
33333314SConscript(dirs='doc', variant_dir='build/doc', duplicate=0)
0 commit comments