SCons:需要解释为什么不使用 scons -u 调用 Install

SCons : Need an explanation why Install not being call with scons -u

有些事情我不明白。请参阅以下 SConscript:

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:\svnrdPartyrdPartyPackages\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:\svnrdPartyrdPartyPackages\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:\svnrdPartyrdPartyPackages\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 -u,而是从根目录调用 scons,那么,我有这个:

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 没有被调用?

谢谢!

要构建的默认文件集是从当前工作目录向下。

您可以在联机帮助页中查看相关信息:http://scons.org/doc/production/HTML/scons-man.html

A subset of a hierarchical tree may be built by remaining at the top-level directory (where the SConstruct file lives) and specifying the subdirectory as the target to be built:

scons src/subdir

or by changing directory and invoking scons with the -u option, which traverses up the directory hierarchy until it finds the SConstruct file, and then builds targets relatively to the current subdirectory:

cd src/subdir
scons -u .

另请参阅此部分:

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

Walks up the directory structure until an SConstruct , Sconstruct or sconstruct file is found, and uses that as the top of the directory tree. If no targets are specified on the command line, only targets at or below the current directory will be built.

-U

Works exactly the same way as the -u option except for the way default targets are handled. When this option is used and no targets are specified on the command line, all default targets that are defined in the SConscript(s) in the current directory are built, regardless of what directory the resultant targets end up in.

因此您可以使该安装成为 Default() 目标,或者将其指定为当前工作目录中某个其他目标的依赖项。