首页 > 解决方案 > SCons:清理失败后重建

问题描述

我正在尝试这个例子:https ://bitbucket.org/Ateru/build-systems/src/default/scons/

我修改了SConstruct文件以设置构建目录:

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

修改后的例子:scons.zip

标签: buildscons

解决方案


如果您将示例文件 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')])

它应该工作。

注意:我已经针对您指定的回购提出了问题。 https://bitbucket.org/Ateru/build-systems/issues/2/youre-statlib-sconscript-has-issue-which


推荐阅读