【问题标题】:Parallel building with gnumake and prerequisites使用 gnumake 和先决条件并行构建
【发布时间】:2010-01-23 01:07:45
【问题描述】:

我的第一个问题(耶!)是关于 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 的命令三次。我希望这是有道理的。感谢您的任何建议或想法!

【问题讨论】:

  • 它确实似乎按照我想要的方式工作,但是这种并行构建的东西有一种根据系统负载或机器到机器等来改变行为的方法。

标签: makefile parallel-processing gnu-make


【解决方案1】:

make -j 的行为与您在问题中所期望的完全一样。它不会多次产生依赖关系。

管道 (|) 字符在您的依赖项列表中有何作用?

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-12-24
  • 1970-01-01
  • 2013-04-17
  • 2014-03-08
  • 1970-01-01
相关资源
最近更新 更多