makefile:第二个依赖项不执行 [英] makefile: second dependency not execute

查看:99
本文介绍了makefile:第二个依赖项不执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目标首次部署中的第二个依赖项未执行.

Second dependency in goal first-deploy not executed.

如果我执行 make first-deploy,make 只执行第一个依赖 - build-proxy-base,结果成功并退出.

if I execute make first-deploy, make execute only first dependence - build-proxy-base with success result and exit.

Makefile:


UID=`id -u`
GID=`id -g`

NODE_N=node
PROXY_N=proxy
PY_N=py

DOCKER_D=docker
PROXY_D=skif-proxy
NODE_D=skif
PY_D=skif-proxy/template-service

# first is default
default: first-deploy docker-compose-up

docker-compose-up:
    cd $(DOCKER_D) && \
        docker-compose up --build && \
        cd ..

build-docker-base:
    docker build \
        --build-arg UID=${UID} \
        --build-arg GID=${GID} \
        -f ${D}/Dockerfile.base \
        --rm \
        -t skif-${SERV_N}-base ${D}

build-node-base: D := ${NODE_D}
build-node-base: SERV_N := ${NODE_N}
build-node-base: build-docker-base

build-proxy-base:D=${PROXY_D}
build-proxy-base:SERV_N=${PROXY_N}
build-proxy-base: build-docker-base

build-py-base: D=${PY_D}
build-py-base: SERV_N=${PY_N}
build-py-base: build-docker-base

first-deploy: build-proxy-base build-py-base build-node-base

UPD 我知道 build-docker-base 只能构建一次,但是我如何在2个目标中与其他参数一起重用它?

UPD I understand that build-docker-base build only once, but how I can reuse it code in 2 goals with other paramethers?

推荐答案

一定要考虑第二个依赖项.如果它没有执行",则意味着需要做出决定而无需执行任何操作.

Make definitely considered the second dependency. If it didn't "execute" then it means make decided nothing needed to be done to execute it.

我可以看到这个:

build-proxy-base: build-docker-base
  ...
build-node-base: build-docker-base

这两个目标都将相同的目标作为先决条件列出,并且它们不执行其他任何操作.在make中,给定的目标(例如 build-docker-base )每次调用只能通过make构建一次.一旦make构建一次,无论依赖多少其他目标,它都将被视为最新版本.

Both of these targets list the same target as a prerequisite, and they don't do anything else. In make, a given target (like build-docker-base) will only ever be built one time by make per invocation. Once make builds it once, it will be considered up to date no matter how many other targets may depend on it.

因此make考虑 build-node-base ,发现由于 build-proxy-base 而已将其更新,并决定没有其他事情可做

So make considers build-node-base, sees that it was already brought up to date due to build-proxy-base, and decides there's nothing else to do.

由于您实际上并未向我们展示 build-node-base 规则或解释您要执行的操作,因此我们可以肯定地说的话不多.

Since you don't actually show us to build-node-base rule or explain what you're trying to do, there's not much more we can say for sure.

ETA 根据更新的makefile,似乎您正在尝试将目标视为函数,可以通过将它们列出为先决条件来调用它们.他们不是,他们不能.

ETA Based on your updated makefile, it seems like you're trying to think of targets as if they were functions, that can be called by listing them as prerequisites. They are not, and they cannot.

在我看来,您只是想使用不同的参数多次运行相同的配方.我认为您应该这样写:

It looks to me like you just want to run the same recipe multiple times with different parameters. I think you should just write it like this:

build-node-base build-proxy-base build-py-base:
        docker build \
            --build-arg UID=${UID} \
            --build-arg GID=${GID} \
            -f ${D}/Dockerfile.base \
            --rm \
            -t skif-${SERV_N}-base ${D}

build-node-base: D := ${NODE_D}
build-node-base: SERV_N := ${NODE_N}

build-proxy-base:D=${PROXY_D}
build-proxy-base:SERV_N=${PROXY_N}

build-py-base: D=${PY_D}
build-py-base: SERV_N=${PY_N}

这篇关于makefile:第二个依赖项不执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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