[Scons-users] pointer to info on using a project-built tool?

Mats Wichmann mats at wichmann.us
Mon Jun 12 16:58:07 EDT 2017


On 06/12/2017 01:12 PM, Bill Deegan wrote:
> Any chance you can post any of your code to help better understand your
> issue?

sure, the basics I can put here if it helps.  (I was actually hoping
there was some reading somewhere so I didn't need to pester people :)

meanwhile we're talking about the cross-build issue, which I guess is
something separate.  That problem is the tool can't really be built "in
isolation" which is what would make more sense for how it wants to be used.

In a generic place, before descending into various subdirectories:


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

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

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

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


In one of those subdirectories, in a tool directory dedicated only to
the conversion tool, which does however needs bits from elsewhere in the
tree:


######################################################################
# Source files and Targets
######################################################################
json2cbor_src = ['json2cbor.c']
json2cbor = tools_env.Program('json2cbor', json2cbor_src)
Alias("json2cbor", [json2cbor])
tools_env.AppendTarget('json2cbor')


and then in a place that has data files which need conversion:


    for json_file in Glob('*.json'):
        examples += examples_env.Install(svr_db_build_dir, str(json_file))
        examples += examples_env.Cbor(json_file)



More information about the Scons-users mailing list