使用变体时,Scons无法安装目录

时间:2015-12-11 22:17:52

标签: scons

我可以使用Install()构建器来安装目录,前提是我不使用变体。

没有变体的示例(工作正常):

$ mkdir -p test/src/doc
$ cd test
$ echo "SConscript('src/SConscript', exports={'dst': '/tmp'})" > SConstruct
$ echo xyz > src/doc/file
$ echo "Import('dst')" > src/SConscript
$ echo "Install(dst, 'doc')" >> src/SConscript
$ scons /tmp
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
Install directory: "src/doc" as "/tmp/doc"
scons: done building targets.
$ scons --version
SCons by Steven Knight et al.:
    script: v2.1.0.r5357[MODIFIED], 2011/09/09 21:31:03, by bdeegan on ubuntu
    engine: v2.1.0.r5357[MODIFIED], 2011/09/09 21:31:03, by bdeegan on ubuntu
    engine path: ['/usr/lib/scons/SCons']
Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 The SCons Foundation

变体示例(不起作用):

$ echo "SConscript('src/SConscript', variant_dir='build', duplicate=0, exports={'dst': 'install'})" > SConstruct
$ scons build
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
Install file: "build/doc" as "build/install/doc"
scons: *** [build/install/doc] build/doc: No such file or directory
scons: building terminated because of errors.

这似乎是一种非常奇怪的行为......对于我当前的项目,我希望能够安装目录树(通常是文档),但是使用变体。

有人能帮帮我吗?非常感谢提前!

1 个答案:

答案 0 :(得分:0)

经过调查,似乎scons尝试使用相对于variant目录的给定路径安装目录,这显然指向一个不存在的文件夹。

我通过使用绝对路径解决了这个问题。使用我的玩具示例:

$ mkdir -p test/src/doc
$ cd test
$ echo "import os" > SConstruct
$ echo "SConscript('src/SConscript', variant_dir='build', duplicate=0, exports={'cwd': os.getcwd() + '/src', 'dst': '/tmp'})" >> SConstruct
$ echo xyz > src/doc/file
$ echo "Import('cwd dst')" > SConscript
$ echo "Install(dst, cwd + '/doc')" >> SConscript
$ scons /tmp
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
Install directory: "src/doc" as "/tmp/doc"
scons: done building targets.

问题解决了!希望这会有所帮助。