makefile - makefile 中的“变量”目标名称
问题描述
在makefile中有“非常量”目标的好/坏做法是什么?
我工作的公司生产嵌入式设备,我是一名固件工程师。
我工作的公司的编码规则要求构建生成的文件必须有一个带有版本标记的名称,以及来自 git 存储库的信息散列(用于测试和生产部门的需要)。另一个限制是使用单个命令生成构建。
这就是为什么我每天都会遇到生成文件,其目标的名称可以在构建之间更改。
我想知道这些是否是常见问题。
我想知道我写的例子是否是解决它的好习惯:
# This is just an example to (hopefully) help to understand.
define populate_variable_with_remote_file_content
$(if $(findstring $(origin $(1)),undefined), \
$(eval $(1) = $(shell git archive master --remote=git@gitserver:project.git $(2) | tar -x --to-stdout)) \
)
endef
.PHONY: clean populate_TAG
all: populate_TAG
$(eval TARGET = dummy_$(TAG))
$(eval export TAG TARGET)
$(MAKE) -f $(firstword $(MAKEFILE_LIST)) $(TARGET)
$(TARGET):
echo hallo > $@
populate_TAG:
$(eval $(call populate_variable_with_remote_file_content,TAG,somefile))
clean:
rm dummy_*
我想知道是否有其他(更好的)方法来解决这个问题。
解决方案
推荐阅读
- c# - 尝试插入数据时,Entity Framework Core 中的一对多关系出现错误
- javascript - 使用 JSON 数据制作 CanvasJS 图表
- r - 如何根据颜色的具体要求制作散点图?
- android - 查看寻呼机片段应加载 1 次以显示来自 firebase 的数据(异步任务)
- ios - 关闭 MMDrawer Controller 后,swift4 中会调用哪个视图控制器生命周期方法?
- java - 如何在netbeans平台的任务栏中显示登录页面
- jenkins - 使用 java 程序在 jenkins 中运行测试用例
- android - 如何自动化没有在 iOS 平台上编写的任何 UI 的库?
- angular - 如何让 Bootstrap 组件与 Angular 6 一起使用?
- java - Android Java 多数组初始化