diff options
Diffstat (limited to 'doc/user/misc.xml')
-rw-r--r-- | doc/user/misc.xml | 221 |
1 files changed, 131 insertions, 90 deletions
diff --git a/doc/user/misc.xml b/doc/user/misc.xml index a8885d7..dde75bf 100644 --- a/doc/user/misc.xml +++ b/doc/user/misc.xml @@ -76,9 +76,9 @@ --> - <programlisting> + <sconstruct> EnsurePythonVersion(2, 5) - </programlisting> + </sconstruct> <para> @@ -145,9 +145,9 @@ --> - <programlisting> + <sconstruct> EnsureSConsVersion(1, 0) - </programlisting> + </sconstruct> <para> @@ -189,21 +189,23 @@ </para> - <programlisting> + <scons_example name="Exit"> + <file name="SConstruct" printme="1"> if ARGUMENTS.get('FUTURE'): print "The FUTURE option is not supported yet!" Exit(2) env = Environment() env.Program('hello.c') - </programlisting> + </file> + <file name="hello.c"> + hello.c + </file> + </scons_example> - <screen> - % <userinput>scons -Q FUTURE=1</userinput> - The FUTURE option is not supported yet! - % <userinput>scons -Q</userinput> - cc -o hello.o -c hello.c - cc -o hello hello.o - </screen> + <scons_output example="Exit"> + <scons_output_command>scons -Q FUTURE=1</scons_output_command> + <scons_output_command>scons -Q</scons_output_command> + </scons_output> <para> @@ -243,36 +245,47 @@ </para> - <programlisting> + <scons_example name="FindFile1a"> + <file name="SConstruct" printme="1"> # one directory print FindFile('missing', '.') t = FindFile('exists', '.') print t.__class__, t - </programlisting> + </file> + <file name="exists"> + exists + </file> + </scons_example> - <screen> - % <userinput>scons -Q</userinput> - None - <class 'SCons.Node.FS.File'> exists - scons: `.' is up to date. - </screen> + <scons_output example="FindFile1a" os="posix"> + <scons_output_command>scons -Q</scons_output_command> + </scons_output> - <programlisting> + <scons_example name="FindFile1b"> + <file name="SConstruct" printme="1"> # several directories includes = [ '.', 'include', 'src/include'] headers = [ 'nonesuch.h', 'config.h', 'private.h', 'dist.h'] for hdr in headers: print '%-12s' % ('%s:' % hdr), FindFile(hdr, includes) - </programlisting> + </file> + <file name="config.h"> + exists + </file> + <directory name="src"></directory> + <directory name="src/include"></directory> + <file name="src/include/private.h"> + exists + </file> + <directory name="include"></directory> + <file name="include/dist.h"> + exists + </file> + </scons_example> - <screen> - % <userinput>scons -Q</userinput> - nonesuch.h: None - config.h: config.h - private.h: src/include/private.h - dist.h: include/dist.h - scons: `.' is up to date. - </screen> + <scons_output example="FindFile1b" os="posix"> + <scons_output_command>scons -Q</scons_output_command> + </scons_output> <!-- The man page says this should work, but it fails. <para> @@ -315,19 +328,29 @@ </para> - <programlisting> + <scons_example name="FindFile1d"> + <file name="SConstruct" printme="1"> print FindFile('multiple', ['sub1', 'sub2', 'sub3']) print FindFile('multiple', ['sub2', 'sub3', 'sub1']) print FindFile('multiple', ['sub3', 'sub1', 'sub2']) - </programlisting> + </file> + <directory name="sub1"></directory> + <file name="sub1/multiple"> + exists + </file> + <directory name="sub2"></directory> + <file name="sub2/multiple"> + exists + </file> + <directory name="sub3"></directory> + <file name="sub3/multiple"> + exists + </file> + </scons_example> - <screen> - % <userinput>scons -Q</userinput> - sub1/multiple - sub2/multiple - sub3/multiple - scons: `.' is up to date. - </screen> + <scons_output example="FindFile1d" os="posix"> + <scons_output_command>scons -Q</scons_output_command> + </scons_output> <!-- file may be a list of file names or a single file name. --> @@ -339,38 +362,34 @@ </para> - <programlisting> + <scons_example name="FindFile2"> + <file name="SConstruct" printme="1"> # Neither file exists, so build will fail - Command('derived', 'leaf', 'cat >$TARGET $SOURCE') + Command('derived', 'leaf', 'cat >$TARGET $SOURCE') print FindFile('leaf', '.') print FindFile('derived', '.') - </programlisting> - - <screen> - % <userinput>scons -Q</userinput> - None - derived - scons: *** [derived] Source `leaf' not found, needed by target `derived'. - </screen> + </file> + </scons_example> - <programlisting> - # Neither file exists, so build will fail - Command('derived', 'leaf', 'cat >$TARGET $SOURCE') - print FindFile('leaf', '.') - print FindFile('derived', '.') + <scons_output example="FindFile2" os="posix"> + <scons_output_command>scons -Q</scons_output_command> + </scons_output> + <scons_example name="FindFile2"> + <file name="SConstruct" printme="1"> # Only 'leaf' exists - Command('derived', 'leaf', 'cat >$TARGET $SOURCE') + Command('derived', 'leaf', 'cat >$TARGET $SOURCE') print FindFile('leaf', '.') print FindFile('derived', '.') - </programlisting> - - <screen> - % <userinput>scons -Q</userinput> + </file> + <file name="leaf"> leaf - derived - cat > derived leaf - </screen> + </file> + </scons_example> + + <scons_output example="FindFile2" os="posix"> + <scons_output_command>scons -Q</scons_output_command> + </scons_output> <para> @@ -379,17 +398,21 @@ </para> - <programlisting> + <scons_example name="FindFile3"> + <file name="SConstruct" printme="1"> # Only 'src/leaf' exists VariantDir('build', 'src') print FindFile('leaf', 'build') - </programlisting> + </file> + <directory name="src"></directory> + <file name="src/leaf"> + leaf + </file> + </scons_example> - <screen> - % <userinput>scons -Q</userinput> - build/leaf - scons: `.' is up to date. - </screen> + <scons_output example="FindFile3" os="posix"> + <scons_output_command>scons -Q</scons_output_command> + </scons_output> </section> @@ -414,13 +437,21 @@ </para> - <programlisting> + <scons_example name="Flatten1"> + <file name="SConstruct" printme="1"> objects = [ Object('prog1.c'), Object('prog2.c', CCFLAGS='-DFOO'), ] Program(objects) - </programlisting> + </file> + <file name="prog1.c"> + prog1.c + </file> + <file name="prog2.c"> + prog2.c + </file> + </scons_example> <para> @@ -430,12 +461,9 @@ </para> - <screen> - % <userinput>scons -Q</userinput> - cc -o prog1.o -c prog1.c - cc -o prog2.o -c -DFOO prog2.c - cc -o prog1 prog1.o prog2.o - </screen> + <scons_output example="Flatten1"> + <scons_output_command>scons -Q</scons_output_command> + </scons_output> <para> @@ -450,7 +478,8 @@ </para> - <programlisting> + <scons_example name="Flatten2"> + <file name="SConstruct" printme="1"> objects = [ Object('prog1.c'), Object('prog2.c', CCFLAGS='-DFOO'), @@ -459,7 +488,14 @@ for object_file in objects: print object_file.abspath - </programlisting> + </file> + <file name="prog1.c"> + prog1.c + </file> + <file name="prog2.c"> + prog2.c + </file> + </scons_example> <para> @@ -471,12 +507,9 @@ </para> - <screen> - % <userinput>scons -Q</userinput> - AttributeError: 'NodeList' object has no attribute 'abspath': - File "/home/my/project/SConstruct", line 8: - print object_file.abspath - </screen> + <scons_output example="Flatten2"> + <scons_output_command>scons -Q</scons_output_command> + </scons_output> <para> @@ -486,7 +519,8 @@ </para> - <programlisting> + <scons_example name="Flatten3"> + <file name="SConstruct" printme="1"> objects = [ Object('prog1.c'), Object('prog2.c', CCFLAGS='-DFOO'), @@ -495,7 +529,14 @@ for object_file in Flatten(objects): print object_file.abspath - </programlisting> + </file> + <file name="prog1.c"> + prog1.c + </file> + <file name="prog2.c"> + prog2.c + </file> + </scons_example> <!-- @@ -529,14 +570,14 @@ </para> - <programlisting> + <sconstruct> env = Environment( LAUNCHDIR = GetLaunchDir(), ) env.Command('directory_build_info', '$LAUNCHDIR/build_info' Copy('$TARGET', '$SOURCE')) - </programlisting> + </sconstruct> <para> |