[Scons-users] Retrieving variables

Stefan Seefeld stefan at seefeld.name
Tue Jun 14 13:50:25 EDT 2016


Hello,

I'd like to support the following workflow to build my project:


$ scons config --python=/path/to/python arch=x86_64

$ scons


where the first ('config') line collects build parameter, runs some
config checks, and saves everything to a file, while the second line
then simply picks those values up and does the actual build. Here is the
code to achieve this:


if 'config' in COMMAND_LINE_TARGETS:
    # Clear the cache
    try: os.remove('bin.SCons/config.py')
    except: pass
if not os.path.exists('bin.SCons/'):
    os.mkdir('bin.SCons/')
vars = Variables('bin.SCons/config.py', ARGUMENTS)
...
env = Environment(toolpath=['config'],
                  variables=vars,
                  TARGET_ARCH=arch)

...


This works reasonably well, but presents a little problem: I use an
'arch' variable to specify the architecture (typically either 'x86' ot
'x86_64'). On Windows this requires the TARGET_ARCH variable to be set
when the Environment is constructed, so the appropriate msvc init script
is executed.

However, there doesn't appear any way to retrieve variables from the
Variables() instance above, so I have no way to fetch the value to set
it explicitly as I attempt above.

Is this an oversight ? Any suggestion on how to do this instead ? (Is
there a way to set the TARGET_ARCH flag after the Environment is created ?)


Thanks,

        Stefan


-- 

      ...ich hab' noch einen Koffer in Berlin...



More information about the Scons-users mailing list