diff options
Diffstat (limited to 'doc/user/depends.xml')
-rw-r--r-- | doc/user/depends.xml | 872 |
1 files changed, 467 insertions, 405 deletions
diff --git a/doc/user/depends.xml b/doc/user/depends.xml index d8e8719..5049565 100644 --- a/doc/user/depends.xml +++ b/doc/user/depends.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-depends" + 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>Dependencies</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 @@ -36,15 +58,19 @@ </para> - + <scons_example name="depends_ex1"> + <file name="SConstruct"> +Program('hello.c') + </file> + <file name="hello.c"> +int main() { printf("Hello, world!\n"); } +</file> + </scons_example> - <screen> - % <userinput>scons -Q</userinput> - cc -o hello.o -c hello.c - cc -o hello hello.o - % <userinput>scons -Q</userinput> - scons: `.' is up to date. - </screen> + <scons_output example="depends_ex1" os="posix" suffix="1"> + <scons_output_command>scons -Q</scons_output_command> + <scons_output_command>scons -Q</scons_output_command> + </scons_output> <para> @@ -57,13 +83,10 @@ </para> - <screen> - % <userinput>scons -Q hello</userinput> - cc -o hello.o -c hello.c - cc -o hello hello.o - % <userinput>scons -Q hello</userinput> - scons: `hello' is up to date. - </screen> + <scons_output example="depends_ex1" os="posix" suffix="2"> + <scons_output_command>scons -Q hello</scons_output_command> + <scons_output_command>scons -Q hello</scons_output_command> + </scons_output> <para> @@ -112,14 +135,11 @@ </para> - <screen> - % <userinput>scons -Q hello</userinput> - cc -o hello.o -c hello.c - cc -o hello hello.o - % <userinput>touch hello.c</userinput> - % <userinput>scons -Q hello</userinput> - scons: `hello' is up to date. - </screen> + <scons_output example="depends_ex1" os="posix" suffix="3"> + <scons_output_command>scons -Q hello</scons_output_command> + <scons_output_command>touch hello.c</scons_output_command> + <scons_output_command>scons -Q hello</scons_output_command> + </scons_output> <para> @@ -137,16 +157,11 @@ </para> - <screen> - % <userinput>scons -Q hello</userinput> - cc -o hello.o -c hello.c - cc -o hello hello.o - % <userinput>edit hello.c</userinput> - [CHANGE THE CONTENTS OF hello.c] - % <userinput>scons -Q hello</userinput> - cc -o hello.o -c hello.c - cc -o hello hello.o - </screen> + <scons_output example="depends_ex1" os="posix" suffix="4"> + <scons_output_command>scons -Q hello</scons_output_command> + <scons_output_command output=" [CHANGE THE CONTENTS OF hello.c]">edit hello.c</scons_output_command> + <scons_output_command>scons -Q hello</scons_output_command> + </scons_output> <para> @@ -157,10 +172,10 @@ </para> - <programlisting> - Program('hello.c') - Decider('MD5') - </programlisting> + <sconstruct> +Program('hello.c') +Decider('MD5') + </sconstruct> <para> @@ -201,16 +216,11 @@ </para> - <screen> - % <userinput>scons -Q hello</userinput> - cc -o hello.o -c hello.c - cc -o hello hello.o - % <userinput>edit hello.c</userinput> - [CHANGE A COMMENT IN hello.c] - % <userinput>scons -Q hello</userinput> - cc -o hello.o -c hello.c - scons: `hello' is up to date. - </screen> + <scons_output example="depends_ex1" os="posix" suffix="5"> + <scons_output_command>scons -Q hello</scons_output_command> + <scons_output_command output=" [CHANGE A COMMENT IN hello.c]" edit="STRIP CCCOM line">edit hello.c</scons_output_command> + <scons_output_command>scons -Q hello</scons_output_command> + </scons_output> <para> @@ -258,10 +268,15 @@ </para> - <programlisting> - Object('hello.c') - Decider('timestamp-newer') - </programlisting> + <scons_example name="depends_newer"> + <file name="SConstruct" printme="1"> +Object('hello.c') +Decider('timestamp-newer') + </file> + <file name="hello.c"> +int main() { printf("Hello, world!\n"); } + </file> + </scons_example> <para> @@ -271,13 +286,11 @@ </para> - <screen> - % <userinput>scons -Q hello.o</userinput> - cc -o hello.o -c hello.c - % <userinput>touch hello.c</userinput> - % <userinput>scons -Q hello.o</userinput> - cc -o hello.o -c hello.c - </screen> + <scons_output example="depends_newer" os="posix" suffix="1"> + <scons_output_command>scons -Q hello.o</scons_output_command> + <scons_output_command>touch hello.c</scons_output_command> + <scons_output_command>scons -Q hello.o</scons_output_command> + </scons_output> <para> @@ -289,10 +302,10 @@ </para> - <programlisting> - Object('hello.c') - Decider('make') - </programlisting> + <sconstruct> +Object('hello.c') +Decider('make') + </sconstruct> <para> @@ -324,10 +337,15 @@ </para> - <programlisting> - Object('hello.c') - Decider('timestamp-match') - </programlisting> + <scons_example name="depends_match"> + <file name="SConstruct" printme="1"> +Object('hello.c') +Decider('timestamp-match') + </file> + <file name="hello.c"> +int main() { printf("Hello, world!\n"); } + </file> + </scons_example> <para> @@ -341,13 +359,11 @@ </para> - <screen> - % <userinput>scons -Q hello.o</userinput> - cc -o hello.o -c hello.c - % <userinput>touch -t 198901010000 hello.c</userinput> - % <userinput>scons -Q hello.o</userinput> - cc -o hello.o -c hello.c - </screen> + <scons_output example="depends_match" os="posix" suffix="1"> + <scons_output_command>scons -Q hello.o</scons_output_command> + <scons_output_command>touch -t 198901010000 hello.c</scons_output_command> + <scons_output_command>scons -Q hello.o</scons_output_command> + </scons_output> <para> @@ -380,10 +396,15 @@ </para> - <programlisting> - Program('hello.c') - Decider('MD5-timestamp') - </programlisting> + <scons_example name="depends_MD5-timestamp"> + <file name="SConstruct" printme="1"> +Program('hello.c') +Decider('MD5-timestamp') + </file> + <file name="hello.c"> +int main() { printf("Hello, world!\n"); } + </file> + </scons_example> <para> @@ -399,7 +420,7 @@ output seems to get this wrong. Just in-line the output for now. - <scons_output example="MD5-timestamp" os="posix"> + <scons_output example="depends_MD5-timestamp" os="posix" suffix="1"> <scons_output_command>scons -Q hello</scons_output_command> <scons_output_command>touch hello.c</scons_output_command> <scons_output_command>scons -Q hello</scons_output_command> @@ -410,17 +431,17 @@ --> <screen> - % <userinput>scons -Q hello</userinput> - cc -o hello.o -c hello.c - cc -o hello hello.o - % <userinput>touch hello.c</userinput> - % <userinput>scons -Q hello</userinput> - scons: `hello' is up to date. - % <userinput>edit hello.c</userinput> - [CHANGE THE CONTENTS OF hello.c] - % <userinput>scons -Q hello</userinput> - cc -o hello.o -c hello.c - cc -o hello hello.o +% <userinput>scons -Q hello</userinput> +cc -o hello.o -c hello.c +cc -o hello hello.o +% <userinput>touch hello.c</userinput> +% <userinput>scons -Q hello</userinput> +scons: `hello' is up to date. +% <userinput>edit hello.c</userinput> + [CHANGE THE CONTENTS OF hello.c] +% <userinput>scons -Q hello</userinput> +cc -o hello.o -c hello.c +cc -o hello hello.o </screen> <para> @@ -493,17 +514,22 @@ </para> - <programlisting> - Program('hello.c') - def decide_if_changed(dependency, target, prev_ni): - if self.get_timestamp() != prev_ni.timestamp: - dep = str(dependency) - tgt = str(target) - if specific_part_of_file_has_changed(dep, tgt): - return True - return False - Decider(decide_if_changed) - </programlisting> + <scons_example name="depends_function"> + <file name="SConstruct" printme="1"> +Program('hello.c') +def decide_if_changed(dependency, target, prev_ni): + if self.get_timestamp() != prev_ni.timestamp: + dep = str(dependency) + tgt = str(target) + if specific_part_of_file_has_changed(dep, tgt): + return True + return False +Decider(decide_if_changed) + </file> + <file name="hello.c"> +int main() { printf("Hello, world!\n"); } + </file> + </scons_example> <para> @@ -608,37 +634,37 @@ </para> - <programlisting> - env = Environment() - - def config_file_decider(dependency, target, prev_ni): - import os.path - - # We always have to init the .csig value... - dep_csig = dependency.get_csig() - # .csig may not exist, because no target was built yet... - if 'csig' not in dir(prev_ni): - return True - # Target file may not exist yet - if not os.path.exists(str(target.abspath)): - return True - if dep_csig != prev_ni.csig: - # Some change on source file => update installed one - return True - return False - - def update_file(): - f = open("test.txt","a") - f.write("some line\n") - f.close() - - update_file() - - # Activate our own decider function - env.Decider(config_file_decider) - - env.Install("install","test.txt") - </programlisting> + <sconstruct> +env = Environment() + +def config_file_decider(dependency, target, prev_ni): + import os.path + + # We always have to init the .csig value... + dep_csig = dependency.get_csig() + # .csig may not exist, because no target was built yet... + if 'csig' not in dir(prev_ni): + return True + # Target file may not exist yet + if not os.path.exists(str(target.abspath)): + return True + if dep_csig != prev_ni.csig: + # Some change on source file => update installed one + return True + return False + +def update_file(): + f = open("test.txt","a") + f.write("some line\n") + f.close() + +update_file() + +# Activate our own decider function +env.Decider(config_file_decider) + +env.Install("install","test.txt") + </sconstruct> </section> @@ -670,13 +696,26 @@ </para> - <programlisting> - env1 = Environment(CPPPATH = ['.']) - env2 = env1.Clone() - env2.Decider('timestamp-match') - env1.Program('prog-MD5', 'program1.c') - env2.Program('prog-timestamp', 'program2.c') - </programlisting> + <scons_example name="depends_mixing"> + <file name="SConstruct" printme="1"> +env1 = Environment(CPPPATH = ['.']) +env2 = env1.Clone() +env2.Decider('timestamp-match') +env1.Program('prog-MD5', 'program1.c') +env2.Program('prog-timestamp', 'program2.c') + </file> + <file name="program1.c"> +#include "inc.h" +int main() { printf("Hello, world!\n"); } + </file> + <file name="program2.c"> +#include "inc.h" +int main() { printf("Hello, world!\n"); } + </file> + <file name="inc.h"> +#define INC 1 + </file> + </scons_example> <para> @@ -690,17 +729,11 @@ </para> - <screen> - % <userinput>scons -Q</userinput> - cc -o program1.o -c -I. program1.c - cc -o prog-MD5 program1.o - cc -o program2.o -c -I. program2.c - cc -o prog-timestamp program2.o - % <userinput>touch inc.h</userinput> - % <userinput>scons -Q</userinput> - cc -o program2.o -c -I. program2.c - cc -o prog-timestamp program2.o - </screen> + <scons_output example="depends_mixing" os="posix" suffix="1"> + <scons_output_command>scons -Q</scons_output_command> + <scons_output_command>touch inc.h</scons_output_command> + <scons_output_command>scons -Q</scons_output_command> + </scons_output> </section> @@ -737,10 +770,10 @@ </para> - <programlisting> - Program('hello.c') - SourceSignatures('MD5') - </programlisting> + <sconstruct> +Program('hello.c') +SourceSignatures('MD5') + </sconstruct> <para> @@ -748,10 +781,10 @@ </para> - <programlisting> - Program('hello.c') - SourceSignatures('timestamp') - </programlisting> + <sconstruct> +Program('hello.c') +SourceSignatures('timestamp') + </sconstruct> <para> @@ -805,10 +838,10 @@ </para> - <programlisting> - Program('hello.c') - TargetSignatures('MD5') - </programlisting> + <sconstruct> +Program('hello.c') +TargetSignatures('MD5') + </sconstruct> <para> @@ -819,10 +852,10 @@ </para> - <programlisting> - Program('hello.c') - TargetSignatures('timestamp') - </programlisting> + <sconstruct> +Program('hello.c') +TargetSignatures('timestamp') + </sconstruct> <para> @@ -848,11 +881,11 @@ </para> - <programlisting> - Program('hello.c') - TargetSignatures('source') - SourceSignatures('timestamp') - </programlisting> + <sconstruct> +Program('hello.c') +TargetSignatures('source') +SourceSignatures('timestamp') + </sconstruct> <para> @@ -914,14 +947,22 @@ </para> - <programlisting> - #include <hello.h> - int - main() - { - printf("Hello, %s!\n", string); - } - </programlisting> + <scons_example name="depends_include"> + <file name="SConstruct"> +Program('hello.c', CPPPATH = '.') + </file> + <file name="hello.c" printme="1"> +#include <hello.h> +int +main() +{ + printf("Hello, %s!\n", string); +} + </file> + <file name="hello.h"> +#define string "world" + </file> + </scons_example> <para> @@ -929,10 +970,8 @@ </para> - - <programlisting> - #define string "world" - </programlisting> + <scons_example_file example="depends_include" name="hello.h"> + </scons_example_file> <para> @@ -944,10 +983,8 @@ </para> - - <programlisting> - Program('hello.c', CPPPATH = '.') - </programlisting> + <scons_example_file example="depends_include" name="SConstruct"> + </scons_example_file> <para> @@ -960,18 +997,12 @@ </para> - <screen> - % <userinput>scons -Q hello</userinput> - cc -o hello.o -c -I. hello.c - cc -o hello hello.o - % <userinput>scons -Q hello</userinput> - scons: `hello' is up to date. - % <userinput>edit hello.h</userinput> - [CHANGE THE CONTENTS OF hello.h] - % <userinput>scons -Q hello</userinput> - cc -o hello.o -c -I. hello.c - cc -o hello hello.o - </screen> + <scons_output example="depends_include" os="posix" suffix="1"> + <scons_output_command>scons -Q hello</scons_output_command> + <scons_output_command>scons -Q hello</scons_output_command> + <scons_output_command output=" [CHANGE THE CONTENTS OF hello.h]">edit hello.h</scons_output_command> + <scons_output_command>scons -Q hello</scons_output_command> + </scons_output> <para> @@ -1016,9 +1047,14 @@ </para> - <programlisting> - Program('hello.c', CPPPATH = ['include', '/home/project/inc']) - </programlisting> + <scons_example name="depends_ex5"> + <file name="SConstruct" printme="1"> +Program('hello.c', CPPPATH = ['include', '/home/project/inc']) + </file> + <file name="hello.c"> +int main() { printf("Hello, world!\n"); } + </file> + </scons_example> <para> @@ -1026,11 +1062,9 @@ </para> - <screen> - % <userinput>scons -Q hello</userinput> - cc -o hello.o -c -Iinclude -I/home/project/inc hello.c - cc -o hello hello.o - </screen> + <scons_output example="depends_ex5" os="posix" suffix="1"> + <scons_output_command>scons -Q hello</scons_output_command> + </scons_output> <para> @@ -1038,12 +1072,9 @@ </para> - <screen> - C:\><userinput>scons -Q hello.exe</userinput> - cl /Fohello.obj /c hello.c /nologo /Iinclude /I\home\project\inc - link /nologo /OUT:hello.exe hello.obj - embedManifestExeCheck(target, source, env) - </screen> + <scons_output example="depends_ex5" os="win32" suffix="2"> + <scons_output_command>scons -Q hello.exe</scons_output_command> + </scons_output> </section> @@ -1095,13 +1126,10 @@ </para> - <screen> - % <userinput>scons -Q --implicit-cache hello</userinput> - cc -o hello.o -c hello.c - cc -o hello hello.o - % <userinput>scons -Q hello</userinput> - scons: `hello' is up to date. - </screen> + <scons_output example="depends_ex1" suffix="6"> + <scons_output_command>scons -Q --implicit-cache hello</scons_output_command> + <scons_output_command>scons -Q hello</scons_output_command> + </scons_output> <para> @@ -1113,9 +1141,9 @@ </para> - <programlisting> - SetOption('implicit_cache', 1) - </programlisting> + <sconstruct> +SetOption('implicit_cache', 1) + </sconstruct> <para> @@ -1178,13 +1206,10 @@ </para> - <screen> - % <userinput>scons -Q --implicit-deps-changed hello</userinput> - cc -o hello.o -c hello.c - cc -o hello hello.o - % <userinput>scons -Q hello</userinput> - scons: `hello' is up to date. - </screen> + <scons_output example="depends_ex1" suffix="7"> + <scons_output_command>scons -Q --implicit-deps-changed hello</scons_output_command> + <scons_output_command>scons -Q hello</scons_output_command> + </scons_output> <para> @@ -1216,13 +1241,10 @@ </para> - <screen> - % <userinput>scons -Q --implicit-deps-unchanged hello</userinput> - cc -o hello.o -c hello.c - cc -o hello hello.o - % <userinput>scons -Q hello</userinput> - scons: `hello' is up to date. - </screen> + <scons_output example="depends_ex1" suffix="8"> + <scons_output_command>scons -Q --implicit-deps-unchanged hello</scons_output_command> + <scons_output_command>scons -Q hello</scons_output_command> + </scons_output> <para> @@ -1269,23 +1291,23 @@ </para> <programlisting> - hello = Program('hello.c') - Depends(hello, 'other_file') +hello = Program('hello.c') +Depends(hello, 'other_file') </programlisting> <!-- XXX mention that you can use arrays for target and source? --> <screen> - % <userinput>scons -Q hello</userinput> - cc -c hello.c -o hello.o - cc -o hello hello.o - % <userinput>scons -Q hello</userinput> - scons: `hello' is up to date. - % <userinput>edit other_file</userinput> - [CHANGE THE CONTENTS OF other_file] - % <userinput>scons -Q hello</userinput> - cc -c hello.c -o hello.o - cc -o hello hello.o +% <userinput>scons -Q hello</userinput> +cc -c hello.c -o hello.o +cc -o hello hello.o +% <userinput>scons -Q hello</userinput> +scons: `hello' is up to date. +% <userinput>edit other_file</userinput> + [CHANGE THE CONTENTS OF other_file] +% <userinput>scons -Q hello</userinput> +cc -c hello.c -o hello.o +cc -o hello hello.o </screen> <para> @@ -1298,9 +1320,9 @@ </para> <programlisting> - hello = Program('hello.c') - goodbye = Program('goodbye.c') - Depends(hello, goodbye) +hello = Program('hello.c') +goodbye = Program('goodbye.c') +Depends(hello, goodbye) </programlisting> <para> @@ -1311,11 +1333,11 @@ </para> <screen> - % <userinput>scons -Q hello</userinput> - cc -c goodbye.c -o goodbye.o - cc -o goodbye goodbye.o - cc -c hello.c -o hello.o - cc -o hello hello.o +% <userinput>scons -Q hello</userinput> +cc -c goodbye.c -o goodbye.o +cc -o goodbye goodbye.o +cc -c hello.c -o hello.o +cc -o hello hello.o </screen> </section> @@ -1340,24 +1362,28 @@ </para> - <programlisting> - #define FOO_HEADER <foo.h> - #include FOO_HEADER - - int main() { - return FOO; - } - </programlisting> - - <screen> - % <userinput>scons -Q</userinput> - cc -o hello.o -c -I. hello.c - cc -o hello hello.o - % <userinput>edit foo.h</userinput> - [CHANGE CONTENTS OF foo.h] - % <userinput>scons -Q</userinput> - scons: `.' is up to date. - </screen> + <scons_example name="depends_macroinc"> + <file name="hello.c" printme="1"> +#define FOO_HEADER <foo.h> +#include FOO_HEADER + +int main() { + return FOO; +} + </file> + <file name="SConstruct"> +Program('hello', 'hello.c', CPPPATH='.') + </file> + <file name="foo.h"> +#define FOO 42 + </file> + </scons_example> + + <scons_output example="depends_macroinc" os="posix" suffix="1"> + <scons_output_command>scons -Q</scons_output_command> + <scons_output_command output=" [CHANGE CONTENTS OF foo.h]">edit foo.h</scons_output_command> + <scons_output_command>scons -Q</scons_output_command> + </scons_output> <para> @@ -1388,22 +1414,34 @@ priori specification of the dependency file. The produced hello.d file is not found (or used) for unknown reasons. --> - <programlisting> - obj = Object('hello.c', CCFLAGS='-MD -MF hello.d', CPPPATH='.') - SideEffect('hello.d', obj) - ParseDepends('hello.d') - Program('hello', obj) - </programlisting> - - <screen> - % <userinput>scons -Q</userinput> - cc -o hello.o -c -MD -MF hello.d -I. hello.c - cc -o hello hello.o - % <userinput>edit foo.h</userinput> - [CHANGE CONTENTS OF foo.h] - % <userinput>scons -Q</userinput> - cc -o hello.o -c -MD -MF hello.d -I. hello.c - </screen> + <scons_example name="depends_parsedep"> + <file name="hello.c"> +#define FOO_HEADER <foo.h> +#include FOO_HEADER + +int main() { + return FOO; +} + </file> + <file name="SConstruct" printme="1"> +obj = Object('hello.c', CCFLAGS='-MD -MF hello.d', CPPPATH='.') +SideEffect('hello.d', obj) +ParseDepends('hello.d') +Program('hello', obj) + </file> + <file name="foo.h"> +#define FOO 42 + </file> + <file name="hello.d"> +hello.o: hello.c foo.h + </file> + </scons_example> + + <scons_output example="depends_parsedep" os="posix" suffix="1"> + <scons_output_command>scons -Q</scons_output_command> + <scons_output_command output=" [CHANGE CONTENTS OF foo.h]">edit foo.h</scons_output_command> + <scons_output_command>scons -Q</scons_output_command> + </scons_output> <para> @@ -1413,10 +1451,28 @@ </para> - + <scons_example name="depends_parsedeprebuild"> + <file name="hello.c"> +#define FOO_HEADER <foo.h> +#include FOO_HEADER + +int main() { + return FOO; +} + </file> + <file name="SConstruct"> +obj = Object('hello.c', CCFLAGS='-MD -MF hello.d', CPPPATH='.') +SideEffect('hello.d', obj) +ParseDepends('hello.d') +Program('hello', obj) + </file> + <file name="foo.h"> +#define FOO 42 + </file> + </scons_example> <!-- - <scons_output example="parsedeprebuild" os="posix"> + <scons_output example="depends_parsedeprebuild" os="posix" suffix="1"> <scons_output_command>scons -Q</scons_output_command> <scons_output_command>scons -Q</scons_output_command> <scons_output_command>scons -Q</scons_output_command> @@ -1424,14 +1480,14 @@ --> <screen> - % <userinput>scons -Q</userinput> - cc -o hello.o -c -MD -MF hello.d -I. hello.c - cc -o hello hello.o - % <userinput>scons -Q --debug=explain</userinput> - scons: rebuilding `hello.o' because `foo.h' is a new dependency - cc -o hello.o -c -MD -MF hello.d -I. hello.c - % <userinput>scons -Q</userinput> - scons: `.' is up to date. +% <userinput>scons -Q</userinput> +cc -o hello.o -c -MD -MF hello.d -I. hello.c +cc -o hello hello.o +% <userinput>scons -Q --debug=explain</userinput> +scons: rebuilding `hello.o' because `foo.h' is a new dependency +cc -o hello.o -c -MD -MF hello.d -I. hello.c +% <userinput>scons -Q</userinput> +scons: `.' is up to date. </screen> <para> @@ -1474,16 +1530,25 @@ </para> - <programlisting> - hello_obj=Object('hello.c') - hello = Program(hello_obj) - Ignore(hello_obj, 'hello.h') - </programlisting> + <scons_example name="depends_ignore"> + <file name="SConstruct" printme="1"> +hello_obj=Object('hello.c') +hello = Program(hello_obj) +Ignore(hello_obj, 'hello.h') + </file> + <file name="hello.c"> +#include "hello.h" +int main() { printf("Hello, %s!\n", string); } + </file> + <file name="hello.h"> +#define string "world" + </file> + </scons_example> <!-- XXX mention that you can use lists for target and source? --> <!-- - <scons_output example="ignore"> + <scons_output example="depends_ignore" suffix="1"> <scons_output_command>scons -Q hello</scons_output_command> <scons_output_command>scons -Q hello</scons_output_command> <scons_output_command output=" [CHANGE THE CONTENTS OF hello.h]">edit hello.h</scons_output_command> @@ -1493,15 +1558,15 @@ --> <screen> - % <userinput>scons -Q hello</userinput> - cc -c -o hello.o hello.c - cc -o hello hello.o - % <userinput>scons -Q hello</userinput> - scons: `hello' is up to date. - % <userinput>edit hello.h</userinput> - [CHANGE THE CONTENTS OF hello.h] - % <userinput>scons -Q hello</userinput> - scons: `hello' is up to date. +% <userinput>scons -Q hello</userinput> +cc -c -o hello.o hello.c +cc -o hello hello.o +% <userinput>scons -Q hello</userinput> +scons: `hello' is up to date. +% <userinput>edit hello.h</userinput> + [CHANGE THE CONTENTS OF hello.h] +% <userinput>scons -Q hello</userinput> +scons: `hello' is up to date. </screen> <para> @@ -1526,8 +1591,8 @@ </para> <programlisting> - hello = Program('hello.c', CPPPATH=['/usr/include']) - Ignore(hello, '/usr/include/stdio.h') +hello = Program('hello.c', CPPPATH=['/usr/include']) +Ignore(hello, '/usr/include/stdio.h') </programlisting> <para> @@ -1541,21 +1606,23 @@ by default. </para> - <programlisting> - hello_obj=Object('hello.c') - hello = Program(hello_obj) - Ignore('.',[hello,hello_obj]) - </programlisting> - - <screen> - % <userinput>scons -Q</userinput> - scons: `.' is up to date. - % <userinput>scons -Q hello</userinput> - cc -o hello.o -c hello.c - cc -o hello hello.o - % <userinput>scons -Q hello</userinput> - scons: `hello' is up to date. - </screen> + <scons_example name="depends_ignore_explicit"> + <file name="SConstruct" printme="1"> +hello_obj=Object('hello.c') +hello = Program(hello_obj) +Ignore('.',[hello,hello_obj]) + </file> + <file name="hello.c"> +#include "stdio.h" +int main() { printf("Hello!\n"); } + </file> + </scons_example> + + <scons_output example="depends_ignore_explicit" os="posix" suffix="1"> + <scons_output_command>scons -Q</scons_output_command> + <scons_output_command>scons -Q hello</scons_output_command> + <scons_output_command>scons -Q hello</scons_output_command> + </scons_output> </section> <section> @@ -1600,16 +1667,22 @@ </para> - <programlisting> - import time + <scons_example name="depends_no-Requires"> + <file name="SConstruct" printme="1"> +import time - version_c_text = """ - char *date = "%s"; - """ % time.ctime(time.time()) - open('version.c', 'w').write(version_c_text) +version_c_text = """ +char *date = "%s"; +""" % time.ctime(time.time()) +open('version.c', 'w').write(version_c_text) - hello = Program(['hello.c', 'version.c']) - </programlisting> +hello = Program(['hello.c', 'version.c']) + </file> + <file name="hello.c"> +extern char *date; +int main() { printf("Hello, %s! I was built: %s\n", date); } + </file> + </scons_example> <para> @@ -1624,20 +1697,13 @@ </para> - <screen> - % <userinput>scons -Q hello</userinput> - cc -o hello.o -c hello.c - cc -o version.o -c version.c - cc -o hello hello.o version.o - % <userinput>sleep 1</userinput> - % <userinput>scons -Q hello</userinput> - cc -o version.o -c version.c - cc -o hello hello.o version.o - % <userinput>sleep 1</userinput> - % <userinput>scons -Q hello</userinput> - cc -o version.o -c version.c - cc -o hello hello.o version.o - </screen> + <scons_output example="depends_no-Requires" suffix="1"> + <scons_output_command>scons -Q hello</scons_output_command> + <scons_output_command>sleep 1</scons_output_command> + <scons_output_command>scons -Q hello</scons_output_command> + <scons_output_command>sleep 1</scons_output_command> + <scons_output_command>scons -Q hello</scons_output_command> + </scons_output> <para> @@ -1660,21 +1726,27 @@ </para> - <programlisting> - import time + <scons_example name="depends_Requires"> + <file name="SConstruct" printme="1"> +import time - version_c_text = """ - char *date = "%s"; - """ % time.ctime(time.time()) - open('version.c', 'w').write(version_c_text) +version_c_text = """ +char *date = "%s"; +""" % time.ctime(time.time()) +open('version.c', 'w').write(version_c_text) - version_obj = Object('version.c') +version_obj = Object('version.c') - hello = Program('hello.c', - LINKFLAGS = str(version_obj[0])) +hello = Program('hello.c', + LINKFLAGS = str(version_obj[0])) - Requires(hello, version_obj) - </programlisting> +Requires(hello, version_obj) + </file> + <file name="hello.c"> +extern char *date; +int main() { printf("Hello, %s! I was built: %s\n", date); } + </file> + </scons_example> <para> @@ -1702,27 +1774,16 @@ </para> - <screen> - % <userinput>scons -Q hello</userinput> - cc -o version.o -c version.c - cc -o hello.o -c hello.c - cc -o hello version.o hello.o - % <userinput>sleep 1</userinput> - % <userinput>scons -Q hello</userinput> - cc -o version.o -c version.c - scons: `hello' is up to date. - % <userinput>sleep 1</userinput> - % <userinput>edit hello.c</userinput> - [CHANGE THE CONTENTS OF hello.c] - % <userinput>scons -Q hello</userinput> - cc -o version.o -c version.c - cc -o hello.o -c hello.c - cc -o hello version.o hello.o - % <userinput>sleep 1</userinput> - % <userinput>scons -Q hello</userinput> - cc -o version.o -c version.c - scons: `hello' is up to date. - </screen> + <scons_output example="depends_Requires" suffix="1"> + <scons_output_command>scons -Q hello</scons_output_command> + <scons_output_command>sleep 1</scons_output_command> + <scons_output_command>scons -Q hello</scons_output_command> + <scons_output_command>sleep 1</scons_output_command> + <scons_output_command output=" [CHANGE THE CONTENTS OF hello.c]">edit hello.c</scons_output_command> + <scons_output_command>scons -Q hello</scons_output_command> + <scons_output_command>sleep 1</scons_output_command> + <scons_output_command>scons -Q hello</scons_output_command> + </scons_output> </section> @@ -1738,10 +1799,15 @@ </para> - <programlisting> - hello = Program('hello.c') - AlwaysBuild(hello) - </programlisting> + <scons_example name="depends_AlwaysBuild"> + <file name="SConstruct" printme="1"> +hello = Program('hello.c') +AlwaysBuild(hello) + </file> + <file name="hello.c"> +int main() { printf("Hello, %s!\n", string); } + </file> + </scons_example> <para> @@ -1752,13 +1818,10 @@ </para> - <screen> - % <userinput>scons -Q</userinput> - cc -o hello.o -c hello.c - cc -o hello hello.o - % <userinput>scons -Q</userinput> - cc -o hello hello.o - </screen> + <scons_output example="depends_AlwaysBuild" suffix="1"> + <scons_output_command>scons -Q</scons_output_command> + <scons_output_command>scons -Q</scons_output_command> + </scons_output> <para> @@ -1777,13 +1840,10 @@ </para> - <screen> - % <userinput>scons -Q</userinput> - cc -o hello.o -c hello.c - cc -o hello hello.o - % <userinput>scons -Q hello.o</userinput> - scons: `hello.o' is up to date. - </screen> + <scons_output example="depends_AlwaysBuild" suffix="2"> + <scons_output_command>scons -Q</scons_output_command> + <scons_output_command>scons -Q hello.o</scons_output_command> + </scons_output> <!-- @@ -1830,3 +1890,5 @@ operating system on which the build is performed (as reported by C<uname </section> --> + +</chapter> |