From 83f47c96cc4ef4659c2a1221abe04cbaeda1c1bb Mon Sep 17 00:00:00 2001 From: stevenknight Date: Sat, 16 Jan 2010 15:27:15 +0000 Subject: [PATCH] Fix the Requires() examples by adding a sleep command to the infrastructure and using it to force the SConstruct file(s) to generate version.c files with new timestamps each run. Fix the description of the example, since the verson.o file does get recompiled each run, but the use of Requires() means the downstream hello executable doesn't get relinked because of it. git-svn-id: http://scons.tigris.org/svn/scons/trunk@4624 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- bin/scons-doc.py | 4 +++ doc/scons.mod | 1 + doc/user/depends.in | 53 +++++++++++++++++----------------- doc/user/depends.xml | 69 +++++++++++++++++++++++++------------------- 4 files changed, 72 insertions(+), 55 deletions(-) diff --git a/bin/scons-doc.py b/bin/scons-doc.py index 6ea429be..e385b081 100644 --- a/bin/scons-doc.py +++ b/bin/scons-doc.py @@ -490,11 +490,15 @@ def command_ls(args, c, test, dict): else: return ls(test.workpath('WORK')) +def command_sleep(args, c, test, dict): + time.sleep(int(args[0])) + CommandDict = { 'scons' : command_scons, 'touch' : command_touch, 'edit' : command_edit, 'ls' : command_ls, + 'sleep' : command_sleep, } def ExecuteCommand(args, c, t, dict): diff --git a/doc/scons.mod b/doc/scons.mod index d8689098..f8d1fe05 100644 --- a/doc/scons.mod +++ b/doc/scons.mod @@ -50,6 +50,7 @@ rmic"> SCons"> ScCons"> +sleep"> swig"> tar"> tex"> diff --git a/doc/user/depends.in b/doc/user/depends.in index 50669737..8ba05048 100644 --- a/doc/user/depends.in +++ b/doc/user/depends.in @@ -1613,7 +1613,7 @@ If we list version.c as an actual source file, - though, then version.o + though, then the version.o file will get rebuilt every time we run &SCons; (because the &SConstruct; file itself changes the contents of version.c) @@ -1623,27 +1623,23 @@ - + - - % scons -Q - gcc -o hello.o -c hello.c - gcc -o version.o -c version.c - gcc -o hello hello.o version.o - % scons -Q - gcc -o version.o -c version.c - gcc -o hello hello.o version.o - % scons -Q - gcc -o version.o -c version.c - gcc -o hello hello.o version.o - + (Note that for the above example to work, + we &sleep; for one second in between each run, + so that the &SConstruct; file will create a + version.c file with a time string + that's one second later than the previous run.) + + @@ -1695,19 +1691,24 @@ With these changes, - we get the desired behavior of - re-building the version.o file, - and therefore re-linking the hello executable, - only when the hello.c has changed: + we get the desired behavior of only + re-linking the hello executable + when the hello.c has changed, + even though the version.o is rebuilt + (because the &SConstruct; file still changes the + version.c contents directly each run): - scons -Q - scons -Q + scons -Q hello + sleep 1 + scons -Q hello + sleep 1 edit hello.c - scons -Q - scons -Q + scons -Q hello + sleep 1 + scons -Q hello diff --git a/doc/user/depends.xml b/doc/user/depends.xml index 8715a36a..cfff07b6 100644 --- a/doc/user/depends.xml +++ b/doc/user/depends.xml @@ -1563,7 +1563,7 @@ If we list version.c as an actual source file, - though, then version.o + though, then the version.o file will get rebuilt every time we run &SCons; (because the &SConstruct; file itself changes the contents of version.c) @@ -1573,27 +1573,30 @@ - + (Note that for the above example to work, + we &sleep; for one second in between each run, + so that the &SConstruct; file will create a + version.c file with a time string + that's one second later than the previous run.) - - % scons -Q - gcc -o hello.o -c hello.c - gcc -o version.o -c version.c - gcc -o hello hello.o version.o - % scons -Q - gcc -o version.o -c version.c - gcc -o hello hello.o version.o - % scons -Q - gcc -o version.o -c version.c - gcc -o hello hello.o version.o - + @@ -1639,27 +1642,35 @@ With these changes, - we get the desired behavior of - re-building the version.o file, - and therefore re-linking the hello executable, - only when the hello.c has changed: + we get the desired behavior of only + re-linking the hello executable + when the hello.c has changed, + even though the version.o is rebuilt + (because the &SConstruct; file still changes the + version.c contents directly each run): - % scons -Q + % scons -Q hello cc -o version.o -c version.c cc -o hello.o -c hello.c cc -o hello version.o hello.o - % scons -Q - scons: `.' is up to date. + % sleep 1 + % scons -Q hello + cc -o version.o -c version.c + scons: `hello' is up to date. + % sleep 1 % edit hello.c [CHANGE THE CONTENTS OF hello.c] - % scons -Q + % scons -Q hello + cc -o version.o -c version.c cc -o hello.o -c hello.c cc -o hello version.o hello.o - % scons -Q - scons: `.' is up to date. + % sleep 1 + % scons -Q hello + cc -o version.o -c version.c + scons: `hello' is up to date. -- 2.26.2