Passing parameters from one SConstruct to another SConstruct using scons
<p>I have a C project built using SCons that links with a C library also built by Scons. Both the library and the project have there own SConstruct files. I read in <a href="http://stackoverflow.com/a/23898880/6198533">this topic</a> that you can call a SConstruct from another SConstruct in the same way as you would call a SConscript:</p>

<pre><code>SConscript('folder/to/other/SConstruct')
</code></pre>

<p>Command line parameters provided to the top level SConstruct are automatically passed to the called SConstruct. But now I want to pass additional variables to the called SConstruct. I figured out that you can do this in the same way as you would do with SConscripts:</p>

<pre><code>SConscript('folder/to/other/SConsctruct', exports='my_variable')
</code></pre>

<p>And then import them in the called SConstruct:</p>

<pre><code>Import('my_variable')
</code></pre>

<p>The problem is that when I call the SConstruct from the C library directly from the command line, 'my_variabled' does not exists and scons raises an error:</p>

<pre><code>scons: *** Import of non-existent variable ''my_variable''
</code></pre>

<p>Should I fix this using a try/except block in the called SConstruct as a switch to get the variable from scons or get the default, or are there more elegant solutions to this? Any suggestions on different approaches are welcome.</p>

<p>My guess is that you're searching for the "<code>-u</code>" or the "<code>-U</code>" option. Please consult the <a href="http://scons.org/doc/production/HTML/scons-man.html" rel="nofollow">MAN page</a> and have a pick for your needs.</p>

python scons