带有gnumake和先决条件的并行构建 [英] Parallel building with gnumake and prerequisites

查看:58
本文介绍了带有gnumake和先决条件的并行构建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的第一个问题(是!)是关于gnumake和并行构建的.这是一个简单的示例文件:

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

如果我对这个人执行make -j,我在这里要确保在make尝试构建tool_[234]中的任何内容之前,恰好一次执行tool_1的命令吗?

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

我正在寻找的是让make -j首先构建tool_1,然后并行构建tool_[234],但不执行三次tool_1的命令.我希望这是有道理的.感谢您的任何建议或想法!

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!

推荐答案

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?

这篇关于带有gnumake和先决条件的并行构建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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