[Scons-users] How to debug problems?

Mats Wichmann mats at wichmann.us
Mon Aug 28 19:10:03 EDT 2017


On 08/28/2017 05:00 PM, Bill Deegan wrote:
> --tree=prune is one place to look
> 
> --taskmastertrace=FILE can help, but it's complicated to understand
> what's going on.  As it's dumping debug info from the guts of SCons
> 
> 
> Also are you doing Glob()'s?
> That can explain why the first run has issues (file not actually there),
> and the second run completes.
> 
> Are there any SideEffect files with this builder? (or any builders in your
> system)
> 
> Can you share your builder?
> Or a small test case which reproduces?

Yeah, there's a Glob.

The code for building the .dat files if needed looks like the following.
The generator tool is built from the project sources, and so running it
in a cross-build scenario is avoided as it won't be the right binary
type for the build host.

######################################################################
# Generate Cbor from json files
######################################################################
json2cbor = env.get('BUILD_DIR') +
'resource/csdk/security/tool/json2cbor' + env.get('PROGSUFFIX')

def generate_actions(source, target, env, for_signature):
    Depends(target, json2cbor)
    return " %s %s %s" % (json2cbor, source[0], target[0])

builder = Builder(generator = generate_actions,
                  suffix = '.dat',
                  src_suffix = '.json')

env.Append(BUILDERS = {'Cbor' : builder})

def ScanJSON(env, directory):
    targets = []
    if env.GetOption('clean') or env.get('SECURED') != '1':
        return targets
    dst_dir = env.get('BUILD_DIR') + '/' + directory + '/'
    src_dir = env.get('SRC_DIR') + '/' + directory + '/'
    for json_file in Glob('*.json'):
        targets += env.Install(dst_dir, str(json_file))
        if env.get('CROSS_COMPILE') != None:
            cbor_file = src_dir + re.sub('\.json$', '.dat', str(json_file))
            targets += Install(dst_dir, cbor_file)
        else:
            cbor_file = env.Cbor(json_file)
            targets.append(cbor_file)
            cbor_file = Flatten(cbor_file)[0].name
            src = dst_dir + cbor_file
            dst = src_dir + cbor_file
            Command(dst, src, Copy("$TARGET", "$SOURCE"))

    return targets

AddMethod(env, ScanJSON)


More information about the Scons-users mailing list