summaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2008-08-26 12:55:22 (GMT)
committerSteven Knight <knight@baldmt.com>2008-08-26 12:55:22 (GMT)
commit0307a78b041c16b5e9ad60c19f669e856f32f49f (patch)
treeca4759db03d83fd713566e90877b104e9d8d590c /doc
parent5e7a97bda2ba7f206c231a28276a237b030da386 (diff)
downloadSCons-0307a78b041c16b5e9ad60c19f669e856f32f49f.zip
SCons-0307a78b041c16b5e9ad60c19f669e856f32f49f.tar.gz
SCons-0307a78b041c16b5e9ad60c19f669e856f32f49f.tar.bz2
Issue 2099: have Execute() print an error message if an action
fails. Better document the behavior of returning the exit status, and that exit-on-failure is the SConscript writer's responsibility.
Diffstat (limited to 'doc')
-rw-r--r--doc/man/scons.127
-rw-r--r--doc/user/factories.in26
-rw-r--r--doc/user/factories.xml26
3 files changed, 75 insertions, 4 deletions
diff --git a/doc/man/scons.1 b/doc/man/scons.1
index 21e475e..baaa234 100644
--- a/doc/man/scons.1
+++ b/doc/man/scons.1
@@ -3545,6 +3545,33 @@ The exit value of the command
or return value of the Python function
will be returned.
+Note that
+.B scons
+will print an error message if the executed
+.I action
+fails--that is,
+exits with or returns a non-zero value.
+.B scons
+will
+.I not ,
+however,
+automatically terminate the build
+if the specified
+.I action
+fails.
+If you want the build to stop in response to a failed
+.BR Execute ()
+call,
+you must explicitly check for a non-zero return value:
+
+.ES
+Execute(Copy('file.out', 'file.in'))
+
+if Execute("mkdir sub/dir/ectory"):
+ # The mkdir failed, don't try to build.
+ Exit(1)
+.EE
+
'\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
.TP
.RI Exit([ value ])
diff --git a/doc/user/factories.in b/doc/user/factories.in
index 94af6a3..34973f1 100644
--- a/doc/user/factories.in
+++ b/doc/user/factories.in
@@ -440,11 +440,10 @@
You can also execute an &Action; returned by a factory
(or actually, any &Action;)
at the time the &SConscript; file is read
- by wrapping it up in the &Execute; function.
+ by using the &Execute; function.
For example, if we need to make sure that
a directory exists before we build any targets,
-
</para>
<scons_example name="Execute">
@@ -482,4 +481,27 @@
</para>
+ <para>
+
+ The &Execute; function returns the exit status
+ or return value of the underlying action being executed.
+ It will also print an error message if the action
+ fails and returns a non-zero value.
+ &SCons; will <emphasis>not</emphasis>, however,
+ actually stop the build if the action fails.
+ If you want the build to stop
+ in response to a failure in an action called by &Execute;,
+ you must do so by explicitly
+ checking the return value
+ and calling the &Exit; function
+ (or a Python equivalent):
+
+ </para>
+
+ <sconstruct>
+ if Execute(Mkdir('__ROOT__/tmp/my_temp_directory')):
+ # A problem occurred while making the temp directory.
+ Exit(1)
+ </sconstruct>
+
</section>
diff --git a/doc/user/factories.xml b/doc/user/factories.xml
index ae6e9d0..9599930 100644
--- a/doc/user/factories.xml
+++ b/doc/user/factories.xml
@@ -395,11 +395,10 @@
You can also execute an &Action; returned by a factory
(or actually, any &Action;)
at the time the &SConscript; file is read
- by wrapping it up in the &Execute; function.
+ by using the &Execute; function.
For example, if we need to make sure that
a directory exists before we build any targets,
-
</para>
<programlisting>
@@ -441,4 +440,27 @@
</para>
+ <para>
+
+ The &Execute; function returns the exit status
+ or return value of the underlying action being executed.
+ It will also print an error message if the action
+ fails and returns a non-zero value.
+ &SCons; will <emphasis>not</emphasis>, however,
+ actually stop the build if the action fails.
+ If you want the build to stop
+ in response to a failure in an action called by &Execute;,
+ you must do so by explicitly
+ checking the return value
+ and calling the &Exit; function
+ (or a Python equivalent):
+
+ </para>
+
+ <programlisting>
+ if Execute(Mkdir('/tmp/my_temp_directory')):
+ # A problem occurred while making the temp directory.
+ Exit(1)
+ </programlisting>
+
</section>