diff options
Diffstat (limited to 'fuel/build/cache.mk')
-rw-r--r-- | fuel/build/cache.mk | 111 |
1 files changed, 36 insertions, 75 deletions
diff --git a/fuel/build/cache.mk b/fuel/build/cache.mk index b88ac2fc4..f6db01797 100644 --- a/fuel/build/cache.mk +++ b/fuel/build/cache.mk @@ -1,4 +1,4 @@ -############################################################################# +############################################################################## # Copyright (c) 2015 Ericsson AB and others. # stefan.k.berg@ericsson.com # jonas.bjurel@ericsson.com @@ -8,87 +8,48 @@ # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## -SHELL = /bin/bash -CACHEVALIDATE := $(addsuffix .validate,$(SUBDIRS)) -CACHECLEAN := $(addsuffix .clean,$(CACHEFILES) $(CACHEDIRS)) - -############################################################################ -# BEGIN of variables to customize -# -#CACHEDIRS := foo/bar - -CACHEFILES += .versions -CACHEFILES += $(shell basename $(ISOSRC)) +############################################################################# +# Cache operations - only used when building through ci/build.sh # -# END of variables to customize -############################################################################ - -.PHONY: prepare-cache -prepare-cache: make-cache-dir $(CACHEDIRS) $(CACHEFILES) +# This is the global cache implementation, providing the main target "cache" +# which is called from ci/build.sh, and recursively calling the cache +# operations clean-cache, get-cache and put-cache on all $(SUBDIRS). +############################################################################# -.PHONY: make-cache-dir -make-cache-dir: - @rm -rf ${CACHE_DIR} - @mkdir ${CACHE_DIR} -.PHONY: clean-cache -clean-cache: $(CACHECLEAN) - @rm -rf ${CACHE_DIR} +export CACHETOOL := $(BUILD_BASE)/cache.sh -.PHONY: $(CACHEDIRS) -$(CACHEDIRS): - @mkdir -p $(dir $(CACHE_DIR)/$@) - @if [ ! -d $(BUILD_BASE)/$@ ]; then\ - mkdir -p $(BUILD_BASE)/$@;\ - fi - @ln -s $(BUILD_BASE)/$@ $(CACHE_DIR)/$@ +# Call sub caches +SUBGETCACHE = $(addsuffix .getcache,$(SUBDIRS)) +$(SUBGETCACHE): %.getcache: + $(MAKE) -C $* -f Makefile get-cache -.PHONY: $(CACHEFILES) -$(CACHEFILES): - @mkdir -p $(dir $(CACHE_DIR)/$@) - @if [ ! -d $(dir $(BUILD_BASE)/$@) ]; then\ - mkdir -p $(dir $(BUILD_BASE)/$@);\ - fi +SUBPUTCACHE = $(addsuffix .putcache,$(SUBDIRS)) +$(SUBPUTCACHE): %.putcache: + $(MAKE) -C $* -f Makefile put-cache - @if [ ! -f $(BUILD_BASE)/$@ ]; then\ - echo " " > $(BUILD_BASE)/$@;\ - ln -s $(BUILD_BASE)/$@ $(CACHE_DIR)/$@;\ - rm -f $(BUILD_BASE)/$@;\ - else\ - ln -s $(BUILD_BASE)/$@ $(CACHE_DIR)/$@;\ - fi +SUBCLEANCACHE = $(addsuffix .cleancache,$(SUBDIRS)) +$(SUBCLEANCACHE): %.cleancache: + $(MAKE) -C $* -f Makefile clean-cache -.PHONY: validate-cache -validate-cache: $(CACHEVALIDATE) - @if [ "$(shell md5sum $(BUILD_BASE)/config.mk | cut -f1 -d " ")" != "$(shell cat $(VERSION_FILE) | grep config.mk | awk '{print $$NF}')" ]; then\ - echo "Cache does not match current config.mk definition, cache must be rebuilt";\ - exit 1;\ - fi; +# Overlay implementation: +# - clean +# - clean cache identities +# - get caches +# - build iso +# - store caches +.PHONY: cached-all +cached-all: clean clean-cache $(SUBCLEANCACHE) get-cache $(SUBGETCACHE) iso put-cache $(SUBPUTCACHE) + @echo "Cached build is complete" - @if [ "$(shell md5sum $(BUILD_BASE)/cache.mk | cut -f1 -d " ")" != "$(shell cat $(VERSION_FILE) | grep cache.mk | awk '{print $$NF}')" ]; then\ - echo "Cache does not match current cache.mk definition, cache must be rebuilt";\ - exit 1;\ - fi; -# Once the Make structure is refactored, this should go in as a validate-cache -# taget in the fuel Makefile - - @REMOTE_ID=$(shell git ls-remote $(FUEL_MAIN_REPO) $(FUEL_MAIN_TAG)^{} | awk '{print $$(NF-1)}'); \ - if [ -z $$REMOTE_ID ] || [ $$REMOTE_ID = " " ]; \ - then \ - REMOTE_ID=$(shell git ls-remote $(FUEL_MAIN_REPO) $(FUEL_MAIN_TAG) | awk '{print $$(NF-1)}'); \ - fi; \ - if [[ $$REMOTE_ID != $(shell cat $(VERSION_FILE) | grep fuel | awk '{print $$NF}') ]]; \ - then \ - echo "Cache does not match upstream Fuel, cache must be rebuilt!"; \ - exit 1; \ +# cache: The target for ci/build.sh +.PHONY: cache +cache: + @if [ -z "${CACHEBASE}" ]; then \ + echo "CACHEBASE not set, are you really building through build.sh?"; \ + exit 1; \ fi - -.PHONY: $(CACHEVALIDATE) -$(CACHEVALIDATE): %.validate: - @echo VALIDATE $(CACHEVALIDATE) - $(MAKE) -C $* -f Makefile validate-cache - -.PHONY: $(CACHECLEAN) -$(CACHECLEAN): %.clean: - rm -rf ${CACHE_DIR}/$* + @docker version >/dev/null 2>&1 || (echo 'No Docker installation available'; exit 1) + @make -C docker + docker/runcontext $(DOCKERIMG) $(MAKE) $(MAKEFLAGS) cached-all |