Build SCons:清理失败后重建
我试着举一个例子: 我修改了Build SCons:清理失败后重建,build,scons,Build,Scons,我试着举一个例子: 我修改了sconstuct文件以设置生成目录: SConscript( 'statlib/SConscript', variant_dir='build/statlib', duplicate=0 ) SConscript( 'dynlib/SConscript', variant_dir='build/dynlib', duplicate=0 ) SConscript( 'executable/SConscript',
sconstuct
文件以设置生成目录:
SConscript(
'statlib/SConscript',
variant_dir='build/statlib',
duplicate=0
)
SConscript(
'dynlib/SConscript',
variant_dir='build/dynlib',
duplicate=0
)
SConscript(
'executable/SConscript',
variant_dir='build/executable',
duplicate=0
)
第一次构建成功
但是,在scons之后生成--clean
和使用scons进行生成--no cache
失败,因为scons使用了文件tablegen.py
的错误路径
修改后的示例:如果将示例文件statlib/SConscript更改为:
import os
# This is needed so we get the python from PATH
env = Environment(ENV = os.environ)
env.Append (CPPPATH='#')
pyexec = 'python' if os.name == 'nt' else 'python3'
env.Command ('table.cpp', 'tablegen.py', '{} $SOURCE > $TARGET'.format (pyexec))
env.StaticLibrary('statlib', [
# This adds fPIC in a portable way
SharedObject ('StaticLibrarySource.cpp'),
SharedObject ('table.cpp')])
它应该会起作用
注:我已针对您指定的回购协议提交了一份文件。
为什么要在statlib/SConscript中执行“p=os.path.abspath('./tablegen.py')?