【发布时间】:2013-08-02 19:57:16
【问题描述】:
我正在尝试让 SCons 检查我需要的 git 存储库(并希望使该存储库保持最新)。问题是我必须告诉它 git repo 包含哪些文件才能在构建中使用它们,如果我这样做,SCons 将在尝试克隆它之前创建 repo。
例如,假设我想克隆 GStreamer,并使用 create-uninstalled-setup.sh 脚本(这不是我实际在做的,但它是一个更简单/更快的脚本,会出现同样的问题):
Command(['gstreamer/.git', 'gstreamer/scripts/create-uninstalled-setup.sh'],
None, 'git clone git://anongit.freedesktop.org/git/gstreamer/gstreamer')
Command('~/gst/git', 'gstreamer/scripts/create-uninstalled-setup.sh',
'gstreamer/scripts/create-uninstalled-setup.sh')
但它失败了,因为 SCons 在尝试克隆 gstreamer 之前创建了 gstreamer/脚本:
$ scons
scons:读取 SConscript 文件 ...
scons:完成读取 SConscript 文件。
scons:建立目标 ...
git clone git://anongit.freedesktop.org/git/gstreamer/gstreamer
致命:目标路径“gstreamer”已存在且不是空目录。
scons: *** [gstreamer/.git] 错误 128
scons:建筑因错误而终止。
$ ls gstreamer/
脚本
如果我告诉第一个命令它创建了“gstreamer”文件夹,它会创建一个依赖循环:
Command(['gstreamer', 'gstreamer/scripts/create-uninstalled-setup.sh'],
None, 'git clone git://anongit.freedesktop.org/git/gstreamer/gstreamer')
Command('~/gst/git', 'gstreamer/scripts/create-uninstalled-setup.sh',
'gstreamer/scripts/create-uninstalled-setup.sh')
$ scons
scons:读取 SConscript 文件 ...
scons:完成读取 SConscript 文件。
scons:建立目标 ...
scons:完成构建目标。scons:*** 找到依赖循环:
gstreamer/scripts -> gstreamer/scripts/create-uninstalled-setup.sh -> gstreamer/scripts
gstreamer/scripts/create-uninstalled-setup.sh -> gstreamer/scripts -> gstreamer/scripts> /create-uninstalled-setup.sh文件“/usr/lib/scons/SCons/Taskmaster.py”,第 1019 行,在清理中
如果我不告诉第一个命令它创建“create-uninstalled-setup.sh”,它会因为它不存在而感到困惑:
Command(['gstreamer'],
None, 'git clone git://anongit.freedesktop.org/git/gstreamer/gstreamer')
Command('~/gst/git', 'gstreamer/scripts/create-uninstalled-setup.sh',
'gstreamer/scripts/create-uninstalled-setup.sh')
$ scons
scons:读取 SConscript 文件 ...
scons:完成读取 SConscript 文件。
scons:建立目标 ...
scons: *** [~/gst/git] 找不到源 `gstreamer/scripts/create-uninstalled-setup.sh',目标 `~/gst/git' 需要它。
scons:建筑因错误而终止。
作为一种解决方法,我可以在克隆之前rm -rf 文件夹,但这显然并不理想:
Command(['gstreamer/.git', 'gstreamer/scripts/create-uninstalled-setup.sh'], None,
'rm -rf gstreamer && git clone git://anongit.freedesktop.org/git/gstreamer/gstreamer')
Command('~/gst/git', 'gstreamer/scripts/create-uninstalled-setup.sh',
'gstreamer/scripts/create-uninstalled-setup.sh')
有没有更好的处理方法?
【问题讨论】:
标签: scons