docker: only build dockerfile's on changes

This commit is contained in:
Tom Gallacher 2016-11-01 11:51:36 +00:00
parent a44c7c0bf8
commit 7581c0df8b

View File

@ -4,7 +4,7 @@ check:
-@./bin/setup -@./bin/setup
SUBDIRS := $(dir $(wildcard */Makefile)) SUBDIRS := $(dir $(wildcard */Makefile))
TARGETS := install clean test test-ci lint lint-ci build push # whatever else, but must not contain '/' TARGETS := install clean test test-ci lint lint-ci # whatever else, but must not contain '/'
# foo/.all bar/.all foo/.clean bar/.clean # foo/.all bar/.all foo/.clean bar/.clean
SUBDIRS_TARGETS := \ SUBDIRS_TARGETS := \
@ -23,3 +23,29 @@ $(TARGETS): %: $(addsuffix %,$(SUBDIRS))
# $(@F:.%=%) is just all # $(@F:.%=%) is just all
$(SUBDIRS_TARGETS): $(SUBDIRS_TARGETS):
$(MAKE) --no-print-directory -C $(@D) $(@F:.%=%) $(MAKE) --no-print-directory -C $(@D) $(@F:.%=%)
DIFF := $(lastword $(subst /, ,${CIRCLE_COMPARE_URL}))
CHANGES := $(filter $(dir $(shell git diff --name-only $(DIFF))), $(SUBDIRS))
.PHONY: diff
diff:
echo $(CHANGES)
BUILDS := build push
# foo/.all bar/.all foo/.clean bar/.clean
BUILDS_TARGETS := \
$(foreach t,$(BUILDS),$(addsuffix $t,$(CHANGES)))
.PHONY: $(BUILDS) $(BUILDS_TARGETS)
# static pattern rule, expands into:
# all clean: %: foo/.% bar/.%
$(BUILDS): %: $(addsuffix %,$(CHANGES))
@echo 'Done "$*" target'
# here, for foo/.all:
# $(@D) is foo
# $(@F) is .all, with leading period
# $(@F:.%=%) is just all
$(BUILDS_TARGETS):
$(MAKE) --no-print-directory -C $(@D) $(@F:.%=%)