Search:

PmWiki

pmwiki.org

edit SideBar

Main / Scons

This is an alternative to make. Written like Python (and in fact, the interpretation tool is Python-based).

Notes

You can assign values to variables as arguments at the scons command, i.e.

scons toolpath=<path>

It saves the arguments you define in options.cache. If you get an error about Source directory cannot be under variant directory. then try re-specifying the arguments, like builddir.

http://www.scons.org/doc/production/HTML/scons-user.html#idm18609400

Construction Variables

This page describes how you would set up something like a license server port: https://scons.org/doc/2.0.1/HTML/scons-user.html#sect-execution-environments

For example

#construction environment creation, with construction variables
env = Environment(
    ENV=os.environ,
    tools=["gcc", "gnulink", "as"],
    CC= compilerName,
    AS= compilerName,
    LINK= compilerName,
    OBJCOPY= compilerObjCopy,
)

env["ENV"]["RLM_LICENSE"] = "5053@10.21.51.205"

Invoking Shell Commands

Use the Python construct

from subprocess import call
call("pwd")

OR you can use the Command Builder which doesn't require the instantiation of a new builder:
https://scons.org/doc/2.0.1/HTML/scons-user/c3762.html
Executes a specific action (or list of actions) to build a target file or files. This is more convenient than defining a separate Builder object for a single special-case build.
Note that they stupidly don't explain that "target" and "source" are keywords and not arbitrary variable names, so they MUST be used as shown. It's a really poor design because the action given to any builder is executed at the Scons top level, but the target and source file paths are at the location of the SConscript file where you set up the builder (i.e. the project folder).

Here's an example that works (given a couple previously defined variables):

DOXYGEN_DIR = OUTPUT_DIR.Dir("doxygen")
DOXYFILE_NAME = PROJECT_DIR.File("Doxyfile")

doxyfile_builder = Builder(action = 'doxygen $SOURCE' )
env.Append(BUILDERS = {'Doxygen' : doxyfile_builder})
env.Doxygen(DOXYGEN_DIR, DOXYFILE_NAME)
env.Clean(DOXYGEN_DIR, DOXYGEN_DIR)

Page last modified on April 08, 2019, at 02:41 PM