问题描述
有三个源文件。每个源文件都是对应的目标。例如,a.cpp的目标是a,b.cpp是b,c.cpp是c。
truffle deploy --reset
我可以使用src/a.cpp
b.cpp
c.cpp
build/
选项并行构建目标。
例如,
-j
目标a,b和c并行构建。
是否可以指定一些目标并进行并行构建?
例如
cd build
make -j3
不幸的是,它可以按顺序工作。首先,构建make -j2 a b
,然后构建a
。
我只想并行构建b
和a
。
我尝试了以下方法。
b
但是,make a&
make b&
wait
的返回码是最后一个完成的等待目标。这意味着如果wait
失败完成,然后make a&
成功完成,则make b&
的返回码为0。
如果有任何make失败,我想停止构建过程。
有什么好方法吗?
解决方法
不幸的是,它可以按顺序工作
这是不正确的,正如您通过编写一个小测试可以看到的那样:
$ cat Makefile
all: one two
one two:
@echo start $@
@sleep 2
@echo stop $@
$ make
start one
stop one
start two
stop two
$ make -j2
start one
start two
stop one
stop two
$ make -j2 one two
start one
start two
stop one
stop two
如您所见,即使在命令行上提供特定目标时,它们也是并行运行的。如果您没有看到这种现象,那么说明您的makefile中有一些与您在问题中所描述的内容大不相同的东西。