Scons 似乎忽略了 CPPPATH 值
Scons appears to ignore CPPPATH value
我通过 ParseFlags 设置了 CPPPATH 变量:
env = Environment()
env["CXX"] = "clang++"
d = env.ParseFlags("-I. -I../utl")
print d
env.StaticLibrary(target="myLib",source = source_files)
d 的打印显示 CPPPATH 设置为正确的目录:
{'CPPFLAGS': [], 'FRAMEWORKPATH': [], 'LIBPATH': [], 'CXXFLAGS': [],
'LIBS': [], 'ASFLAGS': [], 'LINKFLAGS': [], 'RPATH': [], 'CPPDEFINES':
[], 'FRAMEWORKS': [], 'CCFLAGS': [], 'CFLAGS': [], 'CPPPATH': ['.',
'../utl']}
然而,编译输出没有-I选项:
clang++ -o ABC_Exception.o -c ABC_Exception.cpp
并且无法在 ../utl 中找到包含文件
./ABC_Exception.hpp:4:10: fatal error: 'Exception.hpp' file not found
ParseFlags 后应跟 MergeFlags 以将变量添加到环境中,如 SCons documentation 中所述。
ParseFlags returns a dictionary containing the options distributed
into their respective construction variables. Normally, this
dictionary would be passed to MergeFlags to merge the options into a
construction environment, but the dictionary can be edited if desired
to provide additional functionality. (Note that if the flags are not
going to be edited, calling MergeFlags with the options directly will
avoid an additional step.)
在您的示例中,您只需使用传递给 ParseFlags 的字符串调用 MergeFlags。
我通过 ParseFlags 设置了 CPPPATH 变量:
env = Environment()
env["CXX"] = "clang++"
d = env.ParseFlags("-I. -I../utl")
print d
env.StaticLibrary(target="myLib",source = source_files)
d 的打印显示 CPPPATH 设置为正确的目录:
{'CPPFLAGS': [], 'FRAMEWORKPATH': [], 'LIBPATH': [], 'CXXFLAGS': [], 'LIBS': [], 'ASFLAGS': [], 'LINKFLAGS': [], 'RPATH': [], 'CPPDEFINES': [], 'FRAMEWORKS': [], 'CCFLAGS': [], 'CFLAGS': [], 'CPPPATH': ['.', '../utl']}
然而,编译输出没有-I选项:
clang++ -o ABC_Exception.o -c ABC_Exception.cpp
并且无法在 ../utl 中找到包含文件
./ABC_Exception.hpp:4:10: fatal error: 'Exception.hpp' file not found
ParseFlags 后应跟 MergeFlags 以将变量添加到环境中,如 SCons documentation 中所述。
ParseFlags returns a dictionary containing the options distributed into their respective construction variables. Normally, this dictionary would be passed to MergeFlags to merge the options into a construction environment, but the dictionary can be edited if desired to provide additional functionality. (Note that if the flags are not going to be edited, calling MergeFlags with the options directly will avoid an additional step.)
在您的示例中,您只需使用传递给 ParseFlags 的字符串调用 MergeFlags。