Makefile依赖关系可重用现有工件以重新构建通用目标 [英] Makefile dependency to reuse existing artifacts to remake common target

查看:242
本文介绍了Makefile依赖关系可重用现有工件以重新构建通用目标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能很简单,但我找不到答案.我正在为嵌入式平台开发一个gmake系统,该系统具有两个处理元素,每个处理元素都有自己的固件,分别称为CoreA.bin和CoreB,每个都有自己的依赖关系树. CoreB的make系统来自第三方,必须将其视为黑盒PHONY目标.引导程序会从一个二进制文件中对它们进行更新,将其称为BinFile.bin,其中包含一起滚动的CoreA.bin和CoreB二进制文件.

This may be simple but I've not been able to find the answer. I'm developing a gmake system for an embedded platform that has two processing elements, each with their own firmwares, call them CoreA.bin and CoreB, each with their own tree of dependencies. CoreB's make system is from a third party and has to be treated as a black box PHONY target. The bootloader updates them both from a single binary file, call it BinFile.bin which contains CoreA.bin and CoreB binaries rolled together.

因此,make依赖项如下所示:

Thus the make dependencies look like this:

.PHONY CoreB
CoreA.bin: Some Targets
CoreB    : Yet More
BinFile.bin: CoreA.bin CoreB
all: BinFile.bin

又好又简单.但是,构建需要花费很长时间,而CoreA的开发人员会先构建全部"以获取CoreB二进制文件,然后获得BinFile,然后只需重建CoreA. make依赖项需要花很长时间才能解决,因此他们不想重新制作CoreB,但确实需要重新制作BinFile.

Nice and simple. However the builds take a long time and the guys working on CoreA build 'all' once to get a CoreB binary and then the BinFile, then only need to rebuild CoreA. The make dependencies take quite a while to resolve so they don't want to remake CoreB, but they do need BinFile to be remade.

这看起来像这样:

BinFileSubsequent : CoreA
BinFileSubsequent :
     # Remake CoreA
     # Remake the BinFile rollup without duplicating the makefile code

问题是动摇了CoreB依赖关系,但仍然使用现有的工件来重新制作BinFile.有什么想法吗?

The problem is shaking the CoreB dependency but still remaking the BinFile with existing artifacts. Any ideas?

推荐答案

实际目标不应依赖.PHONY目标.这就是您遇到的问题.

Real targets should not depend on .PHONY targets. That's causing the problem you are having.

来自 4.6个Phony目标:

假冒目标不应成为真实目标文件的前提;如果是这样,则每次make更新该文件时都会运行其配方.只要伪造目标永远不是真实目标的先决条件,那么只有当伪造目标是指定目标时,才会执行伪造目标配方(请参阅指定目标的参数).

A phony target should not be a prerequisite of a real target file; if it is, its recipe will be run every time make goes to update that file. As long as a phony target is never a prerequisite of a real target, the phony target recipe will be executed only when the phony target is a specified goal (see Arguments to Specify the Goals).

CoreB构建系统是否可以告诉您是否有工作要做?如果确实如此,则使用印章文件代替伪造目标可能是最简单的解决方案.

Does the CoreB build system have a way to tell you if it has work to do? If it does then using a stamp file instead of the phony target is likely the simplest solution.

如果没有,并且可以接受手动解决方案",那么类似的方法可能会起作用.

If not, and a manual "solution" is acceptable then something like this might work.

.PHONY CoreB
CoreA.bin: Some Targets
CoreB    : Yet More
ifeq (,$(PARTIAL_BUILD))
BinFile.bin: CoreB
endif
BinFile.bin: CoreA.bin
all: BinFile.bin

然后运行make将完成完整的构建,并且运行make PARTIAL_BUILD=1时将不会列出CoreB作为BinFile.bin的先决条件.

And then running make will do the full build and running make PARTIAL_BUILD=1 will run without listing CoreB as a prerequisite of BinFile.bin.

当然,这假定BinFile.bin规则知道如何在不使用CoreB必备项的情况下找到CoreB的内置输出.

This assumes, of course, that the BinFile.bin rule knows how to find the built output of CoreB without using the CoreB prerequisite entry.

这篇关于Makefile依赖关系可重用现有工件以重新构建通用目标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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