2017-03-02 59 views
0

我設置經由ParseFlags的CPPPATH變量:使用SCons似乎忽視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

回答

2

ParseFlags之後應MergeFlagsSCons 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.)

在您的示例中,您可以簡單地調用MergeFlags並將字符串傳遞給ParseFlags。