SCons:并行构建中的目录依赖性 [英] SCons: directory dependency in a parallel build

查看:298
本文介绍了SCons:并行构建中的目录依赖性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在SCons的并行构建中遇到目录依赖性问题. 考虑以下(简化的)层次结构中具有单个SConstruct的两个项目:

I'm having trouble with a directory dependency in a parallel build in SCons. Consider two projects with a single SConstruct in the following (simplified) hierarchy:

- SConstruct
- project1
  - src
- project2
  - src
- build
  - project1
  - project2
- dist
  - project1
  - project2

应该分别在相关的构建目录(使用变体dir)下构建project1和project2,并且需要在相关的dist目录下安装多个目标.

Each of project1 and project2 are supposed to be built under the relevant build directory (using variant dir) and several targets needs to be installed under the relevant dist directory.

项目2取决于项目1的距离.我已经使用Depends()语句明确声明了这种依赖关系,如下所示:

Project 2 depends on Project 1's dist. I've states this dependency explicitly using the Depends() statement like so:

Depends('project2', 'dist/project1')

当我使用非并行构建时,没有问题.项目1已完全构建,目标安装在dist目录中,然后才构建项目2.但是,当我使用多个作业(4)时,正在为要在项目1的dist目录中安装的文件运行的Install()生成器同时构建项目2.

When I use a non-parallel build, there's no problem. Project 1 is fully built, targets are installed in the dist directory, and only then project 2 is built. However, when I use multiple jobs (4), project 2 is being built simultaneously to the Install() builder being run for the files needed to be installed in project 1's dist directory.

所以,我的问题是:

  • Depends(project2, dist/project1)语句是指创建dist/project1目录还是完成构建目录的所有子项?
  • 我应该如何解决这个问题?
  • Does the Depends(project2, dist/project1) statement refers to the creation of the dist/project1 directory or to the completion of building all the directory's children?
  • How should I solve this issue?

非常感谢您,

BugoK.

推荐答案

不要在Depends()函数中将实际目录指定为字符串,而是尝试指定SCons project1和project2构建器返回的实际目标.每个SCons构建器(或至少它们中的大多数)都将受影响的目标作为对象返回,并且最好使用该对象代替文件/目录名称,因为如果您不使用完全相同的文件/目录路径,则不会考虑使用该对象作为同一目标.

Instead of specifying the actual directories as strings in the Depends() function, try specifying the actual targets as returned by the SCons project1 and project2 builders. Every SCons builder (or at least most of them) returns the affected target as an object, and its better to use this object instead of the file/directoy name since if you dont use the exact same file/directory path, it wont be considered as the same target.

这里是一个示例,请相应地填写内容:

Here is an example, fill in content accordingly:

project2Target = Install()
# Im not sure how you're building project1, so replace the builder
project1Target = Proj1DistBuiler()

Depends(project2Target, project1Target)

这篇关于SCons:并行构建中的目录依赖性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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