[Scons-users] SCons.Script.GetBuildFailures not reporting BuildError raised by pseudo-builder

Vrijnsen, Jeroen jeroen.vrijnsen at philips.com
Mon Mar 6 05:51:20 EST 2017


To be more specific, I use SCons 2.3.4, and the following is a simple way to reproduce it:


import os
import SCons.Errors

env = Environment(ENV = {'PATH' : os.environ['PATH']})
env.SConscript(dirs='.', name='scons_hooks.py', exports='env', duplicate=0)

raise SCons.Errors.BuildError(errstr="RAISED MY ERROR")

import atexit
import os
import SCons.Errors
import SCons.Script
import sys

def buildFailureToString(bf):
    """Convert an element of GetBuildFailures() to a string
    in a useful way."""
    if bf is None:  # unknown targets product None in list
        return '(unknown tgt)'
    elif isinstance(bf, SCons.Errors.StopError):
        return str(bf)
    elif bf.node:
        return str(bf.node) + ': ' + bf.errstr
    elif bf.filename:
        return bf.filename + ': ' + bf.errstr
    return 'unknown failure: ' + bf.errstr

def buildStatus():
    """Convert the build status to a 2-tuple, (status, msg)."""
    bf = SCons.Script.GetBuildFailures()
    if bf:
        # bf is normally a list of build failures; if an element is None,
        # it's because of a target that scons doesn't know anything about.
        status = 1
        message = os.linesep.join(["Failed building %s" % buildFailureToString(x) for x in bf if x is not None])
        # if bf is None, the build completed successfully.
        status = 0
        message = ''

    return (status, message)

def displayBuildStatus():
    Display the build status. Called by atexit. Here you could do all kinds of complicated things.
    status, message = buildStatus()
    if status:
        print message
        print "Build FAILED!!!!"
        print "Build SUCCEEDED"

This happily prints 'succeeded', but I want it to print 'failed'... is that possible?


The information contained in this message may be confidential and legally protected under applicable law. The message is intended solely for the addressee(s). If you are not the intended recipient, you are hereby notified that any use, forwarding, dissemination, or reproduction of this message is strictly prohibited and may be unlawful. If you are not the intended recipient, please contact the sender by return e-mail and destroy all copies of the original message.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist4.pair.net/pipermail/scons-users/attachments/20170306/600a6d16/attachment.html>

More information about the Scons-users mailing list