Skip to content

Snippets

Brian Quistorff edited this page Jan 10, 2022 · 6 revisions

Loading dependencies from a JSON file

This is a way to store you dependencies in a simple data structure and loaded programmatically in your SConstruct

You can save the following to a file, e.g., deps.json

[["a.do", ["i1", "i2"], ["o1", "o2"]], ["b.do", ["i3"], ["o4"]]]

Then in your SConstruct you can do this:

def deps_from_json(fname):
    import json
    with open(fname, "r") as fhandle:
        return json.load(fhandle)

# dep_list = deps_from_json("deps.json")
#Generate builder instances from list
for do_file, inputs, outputs from dep_list:
    env.StataBuild(target = outputs, source = do_file, depends=inputs)

...

Clone this wiki locally