2016-10-08 22 views
0

有一些我不明白。請參閱以下SConscript:SCons:需要一個解釋爲什麼安裝不與scons -u電話

Import('common_env') 
import os 
#Grab a copy of the top environment (the one sent by the SConstruct file) 
common_env = common_env.Clone() 
#Because this component is compiled in both win32 and win64. 
if (common_env['ENV']['CONFIG'] == "win32") or (common_env['ENV']['CONFIG'] == "win64"): 
    #Grabs the library name, the name should look like libpath_of_current_component-(debug/opt) 
    libName = common_env.libName() 
    common_env.USE_BOOST() 

    #Grab all the sources in current dir. 
    sources = Glob('*.cpp') 
    #Creates the library 
    myLib = common_env.Library(libName, sources) 
    #Install (copy) the library in LINK/lib/winX 
    common_env.Install('#/LINK/lib/' + common_env['ENV']['CONFIG'], myLib) 

如果這個腳本是從他的子文件夾中調用,我有以下的輸出:

scons: Entering directory `C:\svn\products\faa_mx\scons-test-speed3' 
scons: Reading SConscript files ... 
scons: done reading SConscript files. 
scons: Building targets ... 
scons: building associated VariantDir targets: build\debug\sr\speech\ASRNetworkLayer\ThinProtocol\win64 
cl /Fobuild\debug\sr\speech\ASRNetworkLayer\ThinProtocol\win64\ThinProtocol.obj /c sr\speech\ASRNetworkLayer\ThinProtocol\ThinProtocol.cpp /TP /nologo -Od -D_DEBUG -RTC1 -MDd -Z7 -DBOOST_FILESYSTEM_VERSION=2 -DWIN32 -D_WIN32 -DWINDOWS -D_MBCS -DNOMINMAX -D_MSC_VER=1600 -D_WIN32_WINNT=0x0501 -D_CRT_SECURE_NO_WARNINGS -W3 -nologo -GS -GR -EHa -wd4290 -wd4996 -wd4995 -TP -DBOOST_FILESYSTEM_VERSION=2 /Iinterface\asom\api /Ifwk\simulation_fwk\utils /ILINK\include /Ibuild\debug\sr\speech\ASRNetworkLayer\ThinProtocol\win64 /Isr\speech\ASRNetworkLayer\ThinProtocol /IC:\svn\3rdParty\3rdPartyPackages\boost-1.47.0_vs2010_x64\include /Z7 
ThinProtocol.cpp 
cl /Fobuild\debug\sr\speech\ASRNetworkLayer\ThinProtocol\win64\ThinProtocolMessageDefinitions.obj /c sr\speech\ASRNetworkLayer\ThinProtocol\ThinProtocolMessageDefinitions.cpp /TP /nologo -Od -D_DEBUG -RTC1 -MDd -Z7 -DBOOST_FILESYSTEM_VERSION=2 -DWIN32 -D_WIN32 -DWINDOWS -D_MBCS -DNOMINMAX -D_MSC_VER=1600 -D_WIN32_WINNT=0x0501 -D_CRT_SECURE_NO_WARNINGS -W3 -nologo -GS -GR -EHa -wd4290 -wd4996 -wd4995 -TP -DBOOST_FILESYSTEM_VERSION=2 /Iinterface\asom\api /Ifwk\simulation_fwk\utils /ILINK\include /Ibuild\debug\sr\speech\ASRNetworkLayer\ThinProtocol\win64 /Isr\speech\ASRNetworkLayer\ThinProtocol /IC:\svn\3rdParty\3rdPartyPackages\boost-1.47.0_vs2010_x64\include /Z7 
ThinProtocolMessageDefinitions.cpp 
cl /Fobuild\debug\sr\speech\ASRNetworkLayer\ThinProtocol\win64\ThinProtocolMessaging.obj /c sr\speech\ASRNetworkLayer\ThinProtocol\ThinProtocolMessaging.cpp /TP /nologo -Od -D_DEBUG -RTC1 -MDd -Z7 -DBOOST_FILESYSTEM_VERSION=2 -DWIN32 -D_WIN32 -DWINDOWS -D_MBCS -DNOMINMAX -D_MSC_VER=1600 -D_WIN32_WINNT=0x0501 -D_CRT_SECURE_NO_WARNINGS -W3 -nologo -GS -GR -EHa -wd4290 -wd4996 -wd4995 -TP -DBOOST_FILESYSTEM_VERSION=2 /Iinterface\asom\api /Ifwk\simulation_fwk\utils /ILINK\include /Ibuild\debug\sr\speech\ASRNetworkLayer\ThinProtocol\win64 /Isr\speech\ASRNetworkLayer\ThinProtocol /IC:\svn\3rdParty\3rdPartyPackages\boost-1.47.0_vs2010_x64\include /Z7 
ThinProtocolMessaging.cpp 
lib /nologo /OUT:build\debug\sr\speech\ASRNetworkLayer\ThinProtocol\win64\win64\libsr_speech_ASRNetworkLayer_ThinProtocol-debug.lib build\debug\sr\speech\ASRNetworkLayer\ThinProtocol\win64\ThinProtocol.obj build\debug\sr\speech\ASRNetworkLayer\ThinProtocol\win64\ThinProtocolMessageDefinitions.obj build\debug\sr\speech\ASRNetworkLayer\ThinProtocol\win64\ThinProtocolMessaging.obj 
scons: `sr\speech\ASRNetworkLayer\ThinProtocol' is up to date. 
scons: done building targets. 

正如你所看到的,Install沒有被scons的電話都沒有。

如果不是從一個子文件夾我打電話scons從根調用scons -u的話,我有這樣的:

Install file: "build\debug\sr\speech\ASRNetworkLayer\ThinProtocol\win64\libsr_speech_ASRNetworkLayer_ThinProtocol-debug.lib" as "LINK\lib\win64\libsr_speech_ASRNetworkLayer_ThinProtocol-debug.lib" 

我的問題是:爲什麼這種差異?是否因爲scons構建系統,在scons -u的情況下,知道沒有人需要.lib,因此Install未被調用?

Thx!

回答

1

要構建的默認文件集是從當前工作目錄向下。

可以在手冊頁上看到此信息:http://scons.org/doc/production/HTML/scons-man.html

層次樹的子集可以通過在 頂級目錄剩餘的(在SConstruct文件的生活在那裏),並指定 的建子目錄作爲目標就可以了:

scons src/subdir 

或改變目錄,並與-u選項,該選項 遍歷了目錄層次結構調用scons的,直到它找到SConstruct 文件,然後建立目標相對當前的子目錄:

cd src/subdir 
scons -u . 

參見本節:

-u, --up, --search-up 

自助遊的目錄結構,直到SConstruct,Sconstruct或sconstruct文件找到並將其用作目錄 樹的頂部。如果在命令行上未指定目標,則只會構建目標爲 或當前目錄下的目標。

-U 

除了處理默認目標的方式之外,其工作方式與-u選項完全相同。當使用此選項並沒有 在命令行上指定的目標,所有默認的目標是在當前目錄下的SConscript(S)定義 建成, 無論最終目標的到底是什麼目錄了。

因此,您可以使其安裝Default()目標,或將其指定爲當前工作目錄中某個其他目標的依賴項。