SCons:需要解释为什么安装没有被 scons -u 调用 [英] SCons : Need an explanation why Install not being call with scons -u

查看:72
本文介绍了SCons:需要解释为什么安装没有被 scons -u 调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一点我不明白.请参阅以下 SConscript :

导入('common_env')导入操作系统#获取一份顶层环境的副本(SConstruct文件发送的那个)common_env = common_env.Clone()#因为这个组件是在win32和win64下编译的.如果 (common_env['ENV']['CONFIG'] == "win32") 或 (common_env['ENV']['CONFIG'] == "win64"):#获取库名,名字应该像libpath_of_current_component-(debug/opt)libName = common_env.libName()common_env.USE_BOOST()#获取当前目录中的所有源.来源 = Glob('*.cpp')#创建库myLib = common_env.Library(libName, 来源)#在LINK/lib/winX中安装(复制)库common_env.Install('#/LINK/lib/' + common_env['ENV']['CONFIG'], myLib)

如果这个脚本是从他的子文件夹中调用的,我有以下输出:

scons:进入目录`C:\svn\products\faa_mx\scons-test-speed3'scons:读取 SConscript 文件...scons:完成读取 SConscript 文件.scons:建立目标......scons:构建关联的 VariantDir 目标:build\debug\sr\speech\ASRNetworkLayer\ThinProtocol\win64cl/Fobuild\debug\sr\speech\ASRNetworkLayer\ThinProtocol\win64\ThinProtocol.obj/c sr\speech\ASRNetworkLayer\ThinProtocol\ThinProtocol.cpp/TP/nologo -Od -D_DEBUG -RTC1 -MDd -Z7_SYSTEM_DBOOSTION-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 -wd49995 -wd499950-wd499950-wd499950000000000000000000000000000\simulation_fwk\utils/ILINK\include/Ibuild\debug\sr\speech\ASRNetworkLayer\ThinProtocol\win64/Isr\speech\ASRNetworkLayer\ThinProtocol/IC:\svn\3rdParty\3rdPartyPackages\boost-1.47.0_include_vs201瘦协议文件cl/Fobuild\debug\sr\speech\ASRNetworkLayer\ThinProtocol\win64\ThinProtocolMessageDefinitions.obj/c sr\speech\ASRNetworkLayer\ThinProtocol\ThinProtocolMessageDefinitions.cpp/TP/nologo -Od -D_DEBUG -RTC72D_DEBUG -RTC72D-BOOSTS-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 -wd49995 -wd499950-wd499950-wd499950000000000000000000000000000\simulation_fwk\utils/ILINK\include/Ibuild\debug\sr\speech\ASRNetworkLayer\ThinProtocol\win64/Isr\speech\ASRNetworkLayer\ThinProtocol/IC:\svn\3rdParty\3rdPartyPackages\boost-1.47.0_include_vs201ThinProtocolMessageDefinitions.cppcl/Fobuild\debug\sr\speech\ASRNetworkLayer\ThinProtocol\win64\ThinProtocolMessaging.obj/c sr\speech\ASRNetworkLayer\ThinProtocol\ThinProtocolMessaging.cpp/TP/nologo -Od -D_DEBUG -RTC72D_DEBUG -RTC72DSYSTEMS_SYSTEMS-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 -wd49995 -wd499950-wd499950-wd499950000000000000000000000000000\simulation_fwk\utils/ILINK\include/Ibuild\debug\sr\speech\ASRNetworkLayer\ThinProtocol\win64/Isr\speech\ASRNetworkLayer\ThinProtocol/IC:\svn\3rdParty\3rdPartyPackages\boost-1.47.0_include_vs201ThinProtocolMessaging.cpplib/nologo/OUT:build\debug\sr\speech\ASRNetworkLayer\ThinProtocol\win64\win64\libsr_speech_ASRNetworkLayer_ThinProtocol-debug.lib build\debug\sr\speech\ASRNetworkLayer\ThinProtocol\win64\ThinProtocol\win64\ThinProtocol\语音\ASRNetworkLayer\ThinProtocol\win64\ThinProtocolMessageDefinitions.obj build\debug\sr\speech\ASRNetworkLayer\ThinProtocol\win64\ThinProtocolMessaging.objscons: `sr\speech\ASRNetworkLayer\ThinProtocol' 是最新的.scons:完成构建目标.

如您所见,Install 根本没有被 scons 调用.

如果不是从子文件夹调用 scons -u 我从根调用 scons ,那么,我有这个:

安装文件:build\debug\sr\speech\ASRNetworkLayer\ThinProtocol\win64\libsr_speech_ASRNetworkLayer_ThinProtocol-debug.lib"为LINK\lib\win64\libsr_speech_ASRNetworkLayer_ThinProtocol-debug.lib"

我的问题是:为什么会有这种差异?是不是因为 scons 构建系统,在 scons -u 的情况下,知道没有人需要 .lib,所以 Install 没有被调用?

谢谢!

解决方案

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

您可以在手册页中查看有关此信息:http://scons.org/doc/production/HTML/scons-man.html

<块引用>

一个层次树的子集可以通过保留在顶级目录(SConstruct 文件所在的位置)并指定子目录作为要构建的目标:

scons src/subdir

或通过更改目录并使用 -u 选项调用 scons,向上遍历目录层次结构,直到找到 SConstruct文件,然后相对于当前子目录构建目标:

cd src/子目录scons -u .

另见本节:

<块引用>

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

遍历目录结构,直到找到 SConstruct 、 Sconstruct 或 sconstruct 文件,并将其用作目录的顶部树.如果在命令行上未指定目标,则仅目标位于或低于当前目录将被构建.

-U

除了处理默认目标的方式外,与 -u 选项的工作方式完全相同.当使用此选项且没有目标时在命令行上指定,所有默认目标都是在当前目录中的 SConscript(s) 中定义的被构建,无论结果目标最终位于哪个目录.

因此,您可以安装 Default() 目标,也可以将其指定为当前工作目录中其他目标的依赖项.

There is something that I don`t understand. See following 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)

If this script is invoke from his sub-folder, I have the following output :

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.

As you can see, Install is not being call by scons at all.

If instead of calling scons -u from a sub-folder I call scons from the root, then, I have this :

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"

My question is : Why this difference? Is it because scons build system, in case of scons -u, knows that nobody needs the .lib, so Install not being called?

Thx!

解决方案

The default set of files to be built is from the current working directory down.

You can see info on this in the manpage: 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 .

See also this section:

-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.

So you can either make that install a Default() target, or specify it as a dependency of some other target in the current working directory.

这篇关于SCons:需要解释为什么安装没有被 scons -u 调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆