[Scons-users] interrupted or failed build action handling

Mats Wichmann mats at wichmann.us
Wed Apr 29 14:34:18 EDT 2020


On 4/29/20 12:22 PM, daggs wrote:
> Greetings Bill,
>  
> you are correct, I'll clarify.
> I have an existing scons env that builds a product.
> I have a bash script that has three funcs, prep, bind and unbind.
>  
> I want to do the following:
> prep => bind => build product => unbind.
> when no matter how the build ends (success, failure or user
> interruption), unbind will be called.
> I thought adding prep as action, bind as another action which is
> depended on prep and set bind as depdency of the first action of the build.
> to warp it up, I thought of registering the unbind as an atexit handler
> and register the it to sigterm and sigint too.
>  
> I wondered if there is a more elegant way to do it.

This you should be able to do at the shell level, to keep it simple.

scons should have exit codes you can use to decide what to do if the
build fails - it will return 0 on success, non-zero on fail.

For example, trivial SConstruct which tries to build from a source file
which doesn't exist:

$ scons-3 -f scons-bad.py
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
scons: *** [foo.o] Source `foo.c' not found, needed by target `foo.o'.
scons: building terminated because of errors.
$ echo $?
2


Does this help?


More information about the Scons-users mailing list