2 ms·
"11. Alternative out-of-date determination Sometimes the modification time is not useful for deciding when a target and prerequisite are out of date. The P att
by yrro 12y ago
"11. Alternative out-of-date determination
Sometimes the modification time is not useful for deciding when a target and prerequisite are out of date. The P attribute replaces the default mechanism with the result of a command. The command immediately follows the attribute and is repeatedly executed with each target and each prerequisite as its arguments; if its exit status is non-zero, they are considered out of date and the recipe is executed."
When I want this in GNU Make I end up hacking together something resembling:
define test-exec
$(filter OK,$(shell if $1 >/dev/null; then echo OK; fi))
endef
define test-docker-image
$(if $(call test-exec,$(DOCKER) inspect $1,,docker_$1))
endef
target: $(call test-docker-image,foo)
$(DOCKER) run foo ...
docker_%:
$(DOCKER) build --force-rm -t project/$* $*
It seems this can be replaced with:
docker_%:VPdocker inspect: %
$DOCKER build --fore-rm -t project/$stem $stem