使用 gnumake 和先决条件进行并行构建
我的第一个问题(是的!)是关于 gnumake 和并行构建的。这是一个简单的示例文件:
.PHONY: tool_1 tool_2 tool_3 tool_4 all tools
all: | tools
tools: | tool_2 tool_3 tool_4
tool_1:
# commands for tool 1
tool_2: | tool_1
# commands for tool 2
tool_3: | tool_1
# commands for tool 3
tool_4: | tool_1
# commands for tool 4
如果我对这个家伙执行 make -j
,我在这里所做的就是正确的,以确保 tool_1
的命令恰好执行一次,并且之前make
尝试构建任何 tool_[234]
?
我正在寻找的是让 make -j
导致首先构建 tool_1
,然后并行构建 tool_[234]
,但不执行 tool_1
的命令三次。我希望这是有道理的。感谢您的任何建议或想法!
My first question (yay!) is about gnumake and parallel builds. Here's a quick example file:
.PHONY: tool_1 tool_2 tool_3 tool_4 all tools
all: | tools
tools: | tool_2 tool_3 tool_4
tool_1:
# commands for tool 1
tool_2: | tool_1
# commands for tool 2
tool_3: | tool_1
# commands for tool 3
tool_4: | tool_1
# commands for tool 4
If I do make -j
on this guy, is what I have here correct to ensure that the commands for tool_1
are executed exactly once, and before make
tries to build any of tool_[234]
?
What I'm looking for is to have make -j
cause tool_1
to be built first, then tool_[234]
to be built in parallel, but without executing the commands for tool_1
three times. I hope that makes sense. Thanks for any suggestions or ideas!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
make -j
的行为与您在问题中所期望的完全一样。它不会多次产生依赖关系。管道符 (
|
) 在依赖项列表中起什么作用?make -j
behaves exactly as you expect in your question. It does not make dependencies multiple times.What does that pipe (
|
) character do in your dependency list?