【发布时间】:2023-03-06 19:35:01
【问题描述】:
我在proj 根目录下有一个makefile。
文件夹proj是主文件夹,其下有ws-led或tools-ext等文件夹,其中包含docker文件。
另外,还有Makefile在root下,需要运行所有的命令。
这是文件夹结构
proj
- ws-led
— Dockerfile
- tools-ext
— Dockerfile
- Makefile
我需要的是 cd 到 rot 下的每个文件夹(我们还有更多)并运行:
docker build <folder name> .
示例:(与手动运行以下命令完全一样)
cd ws-led
docker build -t ws-led .
cd tools-ext
docker build -t tools-ext .
我尝试以下方法(也许我在 Makefile 同一级别的所有文件夹上运行而不是 repo 参数)
喜欢(CURDIR)……
all: pre docker-build
.PHONY: pre docker-build
repos := ws-led tools-ext
pre:
$(patsubst %,docker-build,$(repos))
docker-build:pre
cd $*; docker build -t $* . >&2 | tee docker-build
使用此即时消息时出现错误:
invalid argument "." for "-t, --tag" flag: invalid reference format
知道这里有什么问题吗?或者我可以做得更好?
由于我有很多存储库/文件夹,我想使用 make 来处理它
【问题讨论】:
-
在执行 bash 子 shell 之前,您需要注意 make 如何使用引号和特殊字符。我忘记了所有的规则.....
-
$s 是魔法;所以$?可能需要 $$?.
标签: linux bash shell makefile gnu-make