问题
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 thedist/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