SCons: directory dependency in a parallel build

血红的双手。 提交于 2020-01-05 15:15:47

问题


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

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.

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

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

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.

So, my questions are:

  • 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?

Thank you very much,

BugoK.


回答1:


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)


来源:https://stackoverflow.com/questions/14939588/scons-directory-dependency-in-a-parallel-build

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!