[英]makefile increase argument value on each target call
Ive make file with the version that I want to increase automatically the patch value every time by one when I run make pr
当我运行make pr
时,我用我想要每次自动增加补丁值的版本制作文件
TAG = 0.0.1
pr:
docker build -t $(REGISTRY)/$(APP):$(TAG) .
I want to every time that I'll run make pr
it will increase the number, Its ok that only the last number will be increased我想每次运行make pr
它都会增加数字,没关系,只有最后一个数字会增加
Like make pr
喜欢make pr
TAG = 0.0.2
After another 8 times又过了8次
TAG = 0.0.10
Another 90另一个90
TAG = 0.0.100
With GNU make you can do:使用 GNU make 你可以:
TAG = 0.0.${PR}
-include .pr.mk
PR ?= 0
pr: FORCE
@echo ${TAG}
.pr.mk:
@rm -f $@
@echo "PR=$$(( ${PR} + 1 ))" > $@
FORCE:
.PHONY: FORCE .pr.mk
You could use a shell variable instead of a Make variable:您可以使用 shell 变量而不是 Make 变量:
pr:
read TAG < nnn; docker build -t $(REGISTRY)/$(APP):0.0.$$TAG; echo $$((TAG+1)) > nnn
EDIT: this assumes a file named nnn
that contains "1" initially.编辑:这假定一个名为nnn
的文件最初包含“1”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.