Fix the Requires() examples by adding a sleep command to the
[scons.git] / doc / user / depends.in
index 50669737ee3d0800c37ba0096c07d9912015c2ee..8ba05048affde3b379e687eb68d4d7bda9606bb1 100644 (file)
     <para>
 
     If we list <filename>version.c</filename> as an actual source file,
-    though, then <filename>version.o</filename>
+    though, then the <filename>version.o</filename> file
     will get rebuilt every time we run &SCons;
     (because the &SConstruct; file itself changes
     the contents of <filename>version.c</filename>)
 
     </para>
 
-    <!--
-
     <scons_output example="no-Requires">
-      <scons_output_command>scons -Q</scons_output_command>
-      <scons_output_command>scons -Q</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_command>sleep 1</scons_output_command>
+      <scons_output_command>scons -Q hello</scons_output_command>
     </scons_output>
 
-    -->
+    <para>
 
-    <screen>
-      % <userinput>scons -Q</userinput>
-      gcc -o hello.o -c hello.c
-      gcc -o version.o -c version.c
-      gcc -o hello hello.o version.o
-      % <userinput>scons -Q</userinput>
-      gcc -o version.o -c version.c
-      gcc -o hello hello.o version.o
-      % <userinput>scons -Q</userinput>
-      gcc -o version.o -c version.c
-      gcc -o hello hello.o version.o
-    </screen>
+    (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
+    <filename>version.c</filename> file with a time string
+    that's one second later than the previous run.)
+
+    </para>
 
     <para>
 
     <para>
 
     With these changes,
-    we get the desired behavior of
-    re-building the <filename>version.o</filename> file,
-    and therefore re-linking the <filename>hello</filename> executable,
-    only when the <filename>hello.c</filename> has changed:
+    we get the desired behavior of only
+    re-linking the <filename>hello</filename> executable
+    when the <filename>hello.c</filename> has changed,
+    even though the <filename>version.o</filename> is rebuilt
+    (because the &SConstruct; file still changes the
+    <filename>version.c</filename> contents directly each run):
 
     </para>
 
     <scons_output example="Requires">
-      <scons_output_command>scons -Q</scons_output_command>
-      <scons_output_command>scons -Q</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_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</scons_output_command>
-      <scons_output_command>scons -Q</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>