diff options
Diffstat (limited to 'doc/user/factories.xml')
-rw-r--r-- | doc/user/factories.xml | 329 |
1 files changed, 197 insertions, 132 deletions
diff --git a/doc/user/factories.xml b/doc/user/factories.xml index ced0229..806e36b 100644 --- a/doc/user/factories.xml +++ b/doc/user/factories.xml @@ -1,6 +1,28 @@ +<?xml version='1.0'?> +<!DOCTYPE sconsdoc [ + <!ENTITY % scons SYSTEM "../scons.mod"> + %scons; + + <!ENTITY % builders-mod SYSTEM "../generated/builders.mod"> + %builders-mod; + <!ENTITY % functions-mod SYSTEM "../generated/functions.mod"> + %functions-mod; + <!ENTITY % tools-mod SYSTEM "../generated/tools.mod"> + %tools-mod; + <!ENTITY % variables-mod SYSTEM "../generated/variables.mod"> + %variables-mod; + +]> + +<chapter id="chap-factories" + 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/scons.xsd scons.xsd"> +<title>Platform-Independent File System Manipulation</title> + <!-- - Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 The SCons Foundation + Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 The SCons Foundation Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the @@ -60,9 +82,12 @@ </para> - <programlisting> - Command("file.out", "file.in", Copy("$TARGET", "$SOURCE")) - </programlisting> + <scons_example name="factories_Copy1"> + <file name="SConstruct" printme="1"> +Command("file.out", "file.in", Copy("$TARGET", "$SOURCE")) + </file> + <file name="file.in">file.in</file> + </scons_example> <para> @@ -75,10 +100,9 @@ </para> - <screen> - % <userinput>scons -Q</userinput> - Copy("file.out", "file.in") - </screen> + <scons_output example="factories_Copy1" suffix="1"> + <scons_output_command>scons -Q</scons_output_command> + </scons_output> <para> @@ -87,9 +111,12 @@ </para> - <programlisting> - Command("file.out", [], Copy("$TARGET", "file.in")) - </programlisting> + <scons_example name="factories_Copy2"> + <file name="SConstruct" printme="1"> +Command("file.out", [], Copy("$TARGET", "file.in")) + </file> + <file name="file.in">file.in</file> + </scons_example> <para> @@ -97,10 +124,9 @@ </para> - <screen> - % <userinput>scons -Q</userinput> - Copy("file.out", "file.in") - </screen> + <scons_output example="factories_Copy2" suffix="1"> + <scons_output_command>scons -Q</scons_output_command> + </scons_output> <para> @@ -119,14 +145,26 @@ </para> - <programlisting> - Command("file.out", "file.in", - [ - Copy("tempfile", "$SOURCE"), - "modify tempfile", - Copy("$TARGET", "tempfile"), - ]) - </programlisting> + <scons_example name="factories_Copy3"> + <file name="S" printme="1"> +Command("file.out", "file.in", + [ + Copy("tempfile", "$SOURCE"), + "modify tempfile", + Copy("$TARGET", "tempfile"), + ]) + </file> + <file name="SConstruct"> +env = DefaultEnvironment() +import os +env['ENV']['PATH'] = env['ENV']['PATH'] + os.pathsep + os.getcwd() +SConscript('S') + </file> + <file name="file.in">file.in</file> + <file name="modify" chmod="0755"> +touch $* + </file> + </scons_example> <para> @@ -134,12 +172,9 @@ </para> - <screen> - % <userinput>scons -Q</userinput> - Copy("tempfile", "file.in") - modify tempfile - Copy("file.out", "tempfile") - </screen> + <scons_output example="factories_Copy3" suffix="1"> + <scons_output_command>scons -Q</scons_output_command> + </scons_output> </section> @@ -161,15 +196,27 @@ </para> - <programlisting> - Command("file.out", "file.in", - [ - Delete("tempfile"), - Copy("tempfile", "$SOURCE"), - "modify tempfile", - Copy("$TARGET", "tempfile"), - ]) - </programlisting> + <scons_example name="factories_Delete1"> + <file name="S" printme="1"> +Command("file.out", "file.in", + [ + Delete("tempfile"), + Copy("tempfile", "$SOURCE"), + "modify tempfile", + Copy("$TARGET", "tempfile"), + ]) + </file> + <file name="SConstruct"> +env = DefaultEnvironment() +import os +env['ENV']['PATH'] = env['ENV']['PATH'] + os.pathsep + os.getcwd() +SConscript('S') + </file> + <file name="file.in">file.in</file> + <file name="modify" chmod="0755"> +touch $* + </file> + </scons_example> <para> @@ -177,13 +224,9 @@ </para> - <screen> - % <userinput>scons -Q</userinput> - Delete("tempfile") - Copy("tempfile", "file.in") - modify tempfile - Copy("file.out", "tempfile") - </screen> + <scons_output example="factories_Delete1" suffix="1"> + <scons_output_command>scons -Q</scons_output_command> + </scons_output> <para> @@ -194,13 +237,16 @@ </para> - <programlisting> - Command("file.out", "file.in", - [ - Delete("$TARGET"), - Copy("$TARGET", "$SOURCE") - ]) - </programlisting> + <scons_example name="factories_Delete2"> + <file name="SConstruct" printme="1"> +Command("file.out", "file.in", + [ + Delete("$TARGET"), + Copy("$TARGET", "$SOURCE") + ]) + </file> + <file name="file.in">file.in</file> + </scons_example> <para> @@ -208,11 +254,9 @@ </para> - <screen> - % <userinput>scons -Q</userinput> - Delete("file.out") - Copy("file.out", "file.in") - </screen> + <scons_output example="factories_Delete2" suffix="1"> + <scons_output_command>scons -Q</scons_output_command> + </scons_output> <para> @@ -247,14 +291,26 @@ </para> - <programlisting> - Command("file.out", "file.in", - [ - Copy("tempfile", "$SOURCE"), - "modify tempfile", - Move("$TARGET", "tempfile"), - ]) - </programlisting> + <scons_example name="factories_Move"> + <file name="S" printme="1"> +Command("file.out", "file.in", + [ + Copy("tempfile", "$SOURCE"), + "modify tempfile", + Move("$TARGET", "tempfile"), + ]) + </file> + <file name="SConstruct"> +env = DefaultEnvironment() +import os +env['ENV']['PATH'] = env['ENV']['PATH'] + os.pathsep + os.getcwd() +SConscript('S') + </file> + <file name="file.in">file.in</file> + <file name="modify" chmod="0755"> +touch $* + </file> + </scons_example> <para> @@ -262,12 +318,9 @@ </para> - <screen> - % <userinput>scons -Q</userinput> - Copy("tempfile", "file.in") - modify tempfile - Move("file.out", "tempfile") - </screen> + <scons_output example="factories_Move" suffix="1"> + <scons_output_command>scons -Q</scons_output_command> + </scons_output> </section> @@ -282,13 +335,22 @@ </para> - <programlisting> - Command("file.out", "file.in", - [ - Copy("$TARGET", "$SOURCE"), - Touch("$TARGET"), - ]) - </programlisting> + <scons_example name="factories_Touch"> + <file name="S" printme="1"> +Command("file.out", "file.in", + [ + Copy("$TARGET", "$SOURCE"), + Touch("$TARGET"), + ]) + </file> + <file name="SConstruct"> +env = DefaultEnvironment() +import os +env['ENV']['PATH'] = env['ENV']['PATH'] + os.pathsep + os.getcwd() +SConscript('S') + </file> + <file name="file.in">file.in</file> + </scons_example> <para> @@ -296,11 +358,9 @@ </para> - <screen> - % <userinput>scons -Q</userinput> - Copy("file.out", "file.in") - Touch("file.out") - </screen> + <scons_output example="factories_Touch" suffix="1"> + <scons_output_command>scons -Q</scons_output_command> + </scons_output> </section> @@ -319,17 +379,29 @@ </para> - <programlisting> - Command("file.out", "file.in", - [ - Delete("tempdir"), - Mkdir("tempdir"), - Copy("tempdir/${SOURCE.file}", "$SOURCE"), - "process tempdir", - Move("$TARGET", "tempdir/output_file"), - Delete("tempdir"), - ]) - </programlisting> + <scons_example name="factories_Mkdir"> + <file name="S" printme="1"> +Command("file.out", "file.in", + [ + Delete("tempdir"), + Mkdir("tempdir"), + Copy("tempdir/${SOURCE.file}", "$SOURCE"), + "process tempdir", + Move("$TARGET", "tempdir/output_file"), + Delete("tempdir"), + ]) + </file> + <file name="SConstruct"> +env = DefaultEnvironment() +import os +env['ENV']['PATH'] = env['ENV']['PATH'] + os.pathsep + os.getcwd() +SConscript('S') + </file> + <file name="file.in">file.in</file> + <file name="process" chmod="0755"> +touch $* + </file> + </scons_example> <para> @@ -337,15 +409,9 @@ </para> - <screen> - % <userinput>scons -Q</userinput> - Delete("tempdir") - Mkdir("tempdir") - Copy("tempdir/file.in", "file.in") - process tempdir - Move("file.out", "tempdir/output_file") - scons: *** [file.out] tempdir/output_file: No such file or directory - </screen> + <scons_output example="factories_Mkdir" suffix="1"> + <scons_output_command>scons -Q</scons_output_command> + </scons_output> </section> @@ -363,13 +429,16 @@ </para> - <programlisting> - Command("file.out", "file.in", - [ - Copy("$TARGET", "$SOURCE"), - Chmod("$TARGET", 0755), - ]) - </programlisting> + <scons_example name="factories_Chmod"> + <file name="SConstruct" printme="1"> +Command("file.out", "file.in", + [ + Copy("$TARGET", "$SOURCE"), + Chmod("$TARGET", 0755), + ]) + </file> + <file name="file.in">file.in</file> + </scons_example> <para> @@ -377,11 +446,9 @@ </para> - <screen> - % <userinput>scons -Q</userinput> - Copy("file.out", "file.in") - Chmod("file.out", 0755) - </screen> + <scons_output example="factories_Chmod" suffix="1"> + <scons_output_command>scons -Q</scons_output_command> + </scons_output> </section> @@ -401,9 +468,11 @@ </para> - <programlisting> - Execute(Mkdir('/tmp/my_temp_directory')) - </programlisting> + <scons_example name="factories_Execute"> + <file name="SConstruct" printme="1"> +Execute(Mkdir('__ROOT__/tmp/my_temp_directory')) + </file> + </scons_example> <para> @@ -413,15 +482,9 @@ </para> - <screen> - % <userinput>scons</userinput> - scons: Reading SConscript files ... - Mkdir("/tmp/my_temp_directory") - scons: done reading SConscript files. - scons: Building targets ... - scons: `.' is up to date. - scons: done building targets. - </screen> + <scons_output example="factories_Execute" suffix="1"> + <scons_output_command>scons</scons_output_command> + </scons_output> <para> @@ -457,10 +520,12 @@ </para> - <programlisting> - if Execute(Mkdir('/tmp/my_temp_directory')): - # A problem occurred while making the temp directory. - Exit(1) - </programlisting> + <sconstruct> +if Execute(Mkdir('__ROOT__/tmp/my_temp_directory')): + # A problem occurred while making the temp directory. + Exit(1) + </sconstruct> </section> + +</chapter> |