定义变量时触发 ifndef 变量
ifndef variable triggers when variable is defined
为什么,当我运行 make run-e2e-docker
是ifndef 激活?该变量应该被设置,但 make 决定它不是。 运行 的 echo 命令可用。如果我删除 ifndef,并且 运行 make 它会打印变量。
run-e2e:
ifndef environment
$(error "You can't run run-e2e directly, choose one of the run-e2e-* tasks ${environment}")
endif
@echo extra_profiles=${extra_profiles}
@echo environment=${environment}
run-e2e-docker: override extra_profiles = docker-e2e,dev-performance
run-e2e-docker: override environment = docker
run-e2e-docker: run-e2e
您不能在上下文中使用 make 条件语句。当您显然在思考时,它们不会被评估。但是您可以使用 shell 条件,而不是:
run-e2e:
@if [ -z "$(environment)" ]; then \
echo "You can't run run-e2e directly, choose one of the run-e2e-* tasks"; \
exit 1; \
fi
@echo extra_profiles=${extra_profiles}
@echo environment=${environment}
GNU Make 手册说...
Conditionals control what make actually “sees” in the makefile, so
they cannot be used to control recipes at the time of execution.
https://www.gnu.org/software/make/manual/html_node/Conditionals.html
为什么,当我运行 make run-e2e-docker
是ifndef 激活?该变量应该被设置,但 make 决定它不是。 运行 的 echo 命令可用。如果我删除 ifndef,并且 运行 make 它会打印变量。
run-e2e:
ifndef environment
$(error "You can't run run-e2e directly, choose one of the run-e2e-* tasks ${environment}")
endif
@echo extra_profiles=${extra_profiles}
@echo environment=${environment}
run-e2e-docker: override extra_profiles = docker-e2e,dev-performance
run-e2e-docker: override environment = docker
run-e2e-docker: run-e2e
您不能在上下文中使用 make 条件语句。当您显然在思考时,它们不会被评估。但是您可以使用 shell 条件,而不是:
run-e2e:
@if [ -z "$(environment)" ]; then \
echo "You can't run run-e2e directly, choose one of the run-e2e-* tasks"; \
exit 1; \
fi
@echo extra_profiles=${extra_profiles}
@echo environment=${environment}
GNU Make 手册说...
Conditionals control what make actually “sees” in the makefile, so they cannot be used to control recipes at the time of execution.
https://www.gnu.org/software/make/manual/html_node/Conditionals.html