Note that there are some explanatory texts on larger screens.

plurals
  1. POscons dependency problems in a hierarchical build with variant dirs
    primarykey
    data
    text
    <p>Im new to scons and am having problems with scons dependancies in a hierarchichal build with a variant directory.</p> <p>Im able to reproduce the problem in a reduced environment that consists of 2 subdirs under the SConscript directory (moduleA and moduleB) as follows:</p> <pre><code>. |-- SConstruct |-- file.conf |-- moduleA | |-- SConscript | `-- conf2cc `-- moduleB |-- SConscript `-- fileB.cc </code></pre> <p>Here is the flow of what needs to be done:</p> <ol> <li>moduleA executes a shell script: conf2cc, input: $projRootDir/file.conf, output: moduleA/$variantDir/source.cc</li> <li>moduleA compiles source.cc and creates moduleA/$variantDir/libmoduleA.a</li> <li>moduleB needs to copy moduleA/$variantDir/source.cc to moduleB/source.cc</li> <li>moduleB needs to compile moduleB/source.cc and moduleB/fileB.cc into its library libmoduleB.a</li> </ol> <p>Its entirely possible that Im doing several things wrong here. For example, I know Im not using $TARGET/$SOURCE in moduleA Command(), but thats on purpose, since the script needs the absolute path names, and scons doesnt remove the leading '#'</p> <p>The problem I have is the Command() builder in moduleB (step 3 above) never executes.</p> <p>Here are the SConstruct and SConscript files:</p> <p>Sconstruct</p> <pre><code>import os env = Environment() env['variantDir'] = 'linux' # for this example, just make variantDir = linux modules = ['moduleA', 'moduleB'] for dir in modules: SConscript( os.path.join(dir, 'SConscript'), variant_dir = os.path.join(dir, env['variantDir']), exports = ['env'], duplicate = 0) </code></pre> <p>moduleA/Sconscript</p> <pre><code>import os Import('env') scriptInput = '#file.conf' sourceFile = os.path.join('#moduleA', env['variantDir'], 'source.cc') conf2ccScript = File('#moduleA/conf2cc').abspath # The script needs abspaths for input and output, not the scons '#' prepended # the script syntax is: script &lt;inputFile&gt; &lt;outputFile&gt; cmd = '%s %s %s' % (conf2ccScript, File(scriptInput).abspath, File(sourceFile).abspath) # Generate source.cc file based on file.conf conf2ccNode = env.Command(target = sourceFile, source = scriptInput, action = cmd) libNode = env.Library(target = 'moduleA', source = sourceFile) env.Depends(libNode, conf2ccNode) </code></pre> <p>moduleB/Sconscript</p> <pre><code>import os Import('env') sourceFiles = ['fileB.cc', 'source.cc'] # Get the source.cc file externalSourceFile = os.path.join('#moduleA', env['variantDir'], 'source.cc') sourceTarget = os.path.join('#moduleB', 'source.cc') cmdNode = env.Command(target = sourceTarget, source = externalSourceFile, action = Copy('$TARGET', '$SOURCE')) libNode = env.Library(target = 'moduleB', source = sourceFiles) env.Depends(libNode, cmdNode) </code></pre> <p>Here is the output when I execute scons:</p> <p>Any help would be greatly appreciated!</p> <p>Brady</p> <pre><code>notroot@ubuntu:~/projects/sconsTest/sconsTestHierDeps$ scons scons: Reading SConscript files ... scons: done reading SConscript files. scons: Building targets ... /home/notroot/projects/sconsTest/sconsTestHierDeps/moduleA/conf2cc /home/notroot/projects/sconsTest/sconsTestHierDeps/file.conf /home/notroot/projects/sconsTest/sconsTestHierDeps/moduleA/linux/source.cc g++ -o moduleA/linux/source.o -c moduleA/linux/source.cc ar rc moduleA/linux/libmoduleA.a moduleA/linux/source.o ranlib moduleA/linux/libmoduleA.a g++ -o moduleB/linux/fileB.o -c moduleB/fileB.cc scons: *** [moduleB/linux/source.o] Source `moduleB/source.cc' not found, needed by target `moduleB/linux/source.o'. scons: building terminated because of errors. </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload