[Scons-dev] SCons missing dependencies (not rebuilding files when they need to be)
Krzysztof Trzciński
christopher.trzcinski at gmail.com
Fri May 6 13:09:27 EDT 2016
New SConstruct:
env = Environment(tools=['default', 'textfile'])
prints = []
for num in (1,2):
printcc = env.Textfile(
'{0}/print.cc'.format(num),
[(
'#include <iostream>\n'
'#include <fstream>\n'
'int main(int argc, char **argv)\n'
'{{\n'
' std::cout << "Printing " << {0} << std::endl;\n'
' std::ofstream f(argv[2]);\n'
' f << {0} << "\\n";\n'
' return 0;\n'
'}}\n'
).format(num),],
)
prints.extend(env.Program(
'{0}/print'.format(num),
printcc
))
env['SHCXX'] = prints[int(ARGUMENTS['use_task'])]
result = env.SharedObject(printcc)
Default(prints+result)
Results:
$ scons use_task=0
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
Creating '1/print.cc'
g++ -o 1/print.o -c 1/print.cc
g++ -o 1/print 1/print.o
Creating '2/print.cc'
g++ -o 2/print.o -c 2/print.cc
g++ -o 2/print 2/print.o
1/print -o 2/print.os -c -fPIC 2/print.cc
Printing 1
scons: done building targets.
$ cat 2/print.os
1
# Build with different compiler
$ scons use_task=1
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
scons: `1/print' is up to date.
scons: `2/print' is up to date.
scons: `2/print.os' is up to date.
scons: done building targets.
$ cat 2/print.os
1
# Did not refresh!
# Just to double check from clean:
$ rm 2/print.os
$ scons use_task=1
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
scons: `1/print' is up to date.
scons: `2/print' is up to date.
2/print -o 2/print.os -c -fPIC 2/print.cc
Printing 2
scons: done building targets.
$ cat 2/print.os
2
I don't think I should be putting compiler as "source" in `SharedObject`.
Note that all Textfile/Program builders do here is make this self contained.
The actual issues is with last three lines.
In my case it was just that "prints" was populated using operating system
provided paths/binaries to compilers.
So I take this is a bug and it needs fixing? (if someone could point me in
right direction I could try that, but I am not quite sure where substitions
take place and why $SHXCC would behave differently to $SHCXX.path in a
command).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist2.pair.net/pipermail/scons-dev/attachments/20160506/ce8bc4f7/attachment.html>
More information about the Scons-dev
mailing list