我正在尝试让 SCons 查看我需要的 git 存储库(并希望使该存储库保持最新)。问题是我必须告诉它 git 存储库包含哪些文件才能在构建中使用它们,如果我这样做,SCons 将在尝试克隆存储库之前创建存储库。
例如,假设我想克隆 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/scripts:
$ scons
scons:读取 SConscript 文件...
scons:完成读取 SConscript 文件。
scons:建立目标...
git 克隆 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')
有更好的方法来处理这个问题吗?