diff options
Diffstat (limited to 'doc/user/separate.xml')
-rw-r--r-- | doc/user/separate.xml | 219 |
1 files changed, 131 insertions, 88 deletions
diff --git a/doc/user/separate.xml b/doc/user/separate.xml index 8ad357c..e973795 100644 --- a/doc/user/separate.xml +++ b/doc/user/separate.xml @@ -1,6 +1,27 @@ +<?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-separate" + 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>Separating Source and Build Directories</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 @@ -151,9 +172,18 @@ program using the F<build/foo.c> path name. </para> - <programlisting> - SConscript('src/SConscript', variant_dir='build') - </programlisting> + <scons_example name="separate_ex1"> + <file name="SConstruct" printme="1"> +SConscript('src/SConscript', variant_dir='build') + </file> + <file name="src/SConscript"> +env = Environment() +env.Program('hello.c') + </file> + <file name="src/hello.c"> +int main() { printf("Hello, world!\n"); } + </file> + </scons_example> <para> @@ -162,15 +192,11 @@ program using the F<build/foo.c> path name. </para> - <screen> - % <userinput>ls src</userinput> - SConscript hello.c - % <userinput>scons -Q</userinput> - cc -o build/hello.o -c build/hello.c - cc -o build/hello build/hello.o - % <userinput>ls build</userinput> - SConscript hello hello.c hello.o - </screen> + <scons_output example="separate_ex1" suffix="1"> + <scons_output_command>ls src</scons_output_command> + <scons_output_command>scons -Q</scons_output_command> + <scons_output_command>ls build</scons_output_command> + </scons_output> <para> @@ -240,9 +266,9 @@ program using the F<build/foo.c> path name. </para> - <programlisting> - #include "file.h" - </programlisting> + <sconstruct> +#include "file.h" + </sconstruct> <para> @@ -293,9 +319,9 @@ program using the F<build/foo.c> path name. </para> - <programlisting> - SConscript('src/SConscript', variant_dir='build', duplicate=0) - </programlisting> + <sconstruct> +SConscript('src/SConscript', variant_dir='build', duplicate=0) + </sconstruct> <para> @@ -308,15 +334,15 @@ program using the F<build/foo.c> path name. </para> <screen> - % <userinput>ls src</userinput> - SConscript - hello.c - % <userinput>scons -Q</userinput> - cc -c src/hello.c -o build/hello.o - cc -o build/hello build/hello.o - % <userinput>ls build</userinput> - hello - hello.o +% <userinput>ls src</userinput> +SConscript +hello.c +% <userinput>scons -Q</userinput> +cc -c src/hello.c -o build/hello.o +cc -o build/hello build/hello.o +% <userinput>ls build</userinput> +hello +hello.o </screen> </section> @@ -332,11 +358,16 @@ program using the F<build/foo.c> path name. </para> - <programlisting> - VariantDir('build', 'src') - env = Environment() - env.Program('build/hello.c') - </programlisting> + <scons_example name="separate_builddir"> + <file name="SConstruct" printme="1"> +VariantDir('build', 'src') +env = Environment() +env.Program('build/hello.c') + </file> + <file name="src/hello.c"> +int main() { printf("Hello, world!\n"); } + </file> + </scons_example> <para> @@ -358,15 +389,11 @@ program using the F<build/foo.c> path name. </para> - <screen> - % <userinput>ls src</userinput> - hello.c - % <userinput>scons -Q</userinput> - cc -o build/hello.o -c build/hello.c - cc -o build/hello build/hello.o - % <userinput>ls build</userinput> - hello hello.c hello.o - </screen> + <scons_output example="separate_builddir" suffix="1"> + <scons_output_command>ls src</scons_output_command> + <scons_output_command>scons -Q</scons_output_command> + <scons_output_command>ls build</scons_output_command> + </scons_output> <para> @@ -375,11 +402,16 @@ program using the F<build/foo.c> path name. </para> - <programlisting> - VariantDir('build', 'src', duplicate=0) - env = Environment() - env.Program('build/hello.c') - </programlisting> + <scons_example name="separate_duplicate0"> + <file name="SConstruct" printme="1"> +VariantDir('build', 'src', duplicate=0) +env = Environment() +env.Program('build/hello.c') + </file> + <file name="src/hello.c"> +int main() { printf("Hello, world!\n"); } + </file> + </scons_example> <para> @@ -388,15 +420,11 @@ program using the F<build/foo.c> path name. </para> - <screen> - % <userinput>ls src</userinput> - hello.c - % <userinput>scons -Q</userinput> - cc -o build/hello.o -c src/hello.c - cc -o build/hello build/hello.o - % <userinput>ls build</userinput> - hello hello.o - </screen> + <scons_output example="separate_duplicate0" suffix="1"> + <scons_output_command>ls src</scons_output_command> + <scons_output_command>scons -Q</scons_output_command> + <scons_output_command>ls build</scons_output_command> + </scons_output> </section> @@ -414,10 +442,19 @@ program using the F<build/foo.c> path name. </para> - <programlisting> - env = Environment() - env.Program('hello.c') - </programlisting> + <scons_example name="separate_builddir_sconscript"> + <file name="SConstruct"> +VariantDir('build', 'src') +SConscript('build/SConscript') + </file> + <file name="src/SConscript" printme="1"> +env = Environment() +env.Program('hello.c') + </file> + <file name="src/hello.c"> +int main() { printf("Hello, world!\n"); } + </file> + </scons_example> <para> @@ -425,11 +462,8 @@ program using the F<build/foo.c> path name. </para> - - <programlisting> - VariantDir('build', 'src') - SConscript('build/SConscript') - </programlisting> + <scons_example_file example="separate_builddir_sconscript" name="SConstruct"> + </scons_example_file> <para> @@ -437,15 +471,11 @@ program using the F<build/foo.c> path name. </para> - <screen> - % <userinput>ls src</userinput> - SConscript hello.c - % <userinput>scons -Q</userinput> - cc -o build/hello.o -c build/hello.c - cc -o build/hello build/hello.o - % <userinput>ls build</userinput> - SConscript hello hello.c hello.o - </screen> + <scons_output example="separate_builddir_sconscript" suffix="1"> + <scons_output_command>ls src</scons_output_command> + <scons_output_command>scons -Q</scons_output_command> + <scons_output_command>ls build</scons_output_command> + </scons_output> <para> @@ -470,10 +500,26 @@ program using the F<build/foo.c> path name. </para> - <programlisting> - env = Environment() - env.Program('hello', Glob('*.c')) - </programlisting> + <scons_example name="separate_glob_builddir_sconscript"> + <file name="SConstruct"> +VariantDir('build', 'src') +SConscript('build/SConscript') + </file> + <file name="src/SConscript" printme="1"> +env = Environment() +env.Program('hello', Glob('*.c')) + </file> + <file name="src/f1.c"> +#include "f2.h" +int main() { printf(f2()); } + </file> + <file name="src/f2.c"> +const char * f2() { return("Hello, world!\n"); } + </file> + <file name="src/f2.h"> +const char * f2(); + </file> + </scons_example> <para> @@ -484,16 +530,11 @@ program using the F<build/foo.c> path name. </para> - <screen> - % <userinput>ls src</userinput> - SConscript f1.c f2.c f2.h - % <userinput>scons -Q</userinput> - cc -o build/f1.o -c build/f1.c - cc -o build/f2.o -c build/f2.c - cc -o build/hello build/f1.o build/f2.o - % <userinput>ls build</userinput> - SConscript f1.c f1.o f2.c f2.h f2.o hello - </screen> + <scons_output example="separate_glob_builddir_sconscript" suffix="1"> + <scons_output_command>ls src</scons_output_command> + <scons_output_command>scons -Q</scons_output_command> + <scons_output_command>ls build</scons_output_command> + </scons_output> <para> @@ -518,3 +559,5 @@ program using the F<build/foo.c> path name. </section> --> + +</chapter> |