build: Create CCACHE_DIR if it doesn't exist and mount it.

Instead of the HOME dir, and only when ENABLE_CCACHE is set.
This commit is contained in:
Rémi Bernon 2021-04-19 14:43:01 +02:00
parent 8dd5db85dd
commit ecca62efa8
No known key found for this signature in database
GPG Key ID: 38D0E5827B54E5C9

View File

@ -49,14 +49,14 @@ CCACHE_ENV := $(patsubst %,-e %,$(shell env|cut -d= -f1|grep '^CCACHE_'))
ifeq ($(ENABLE_CCACHE),1) ifeq ($(ENABLE_CCACHE),1)
CCACHE_BIN := ccache CCACHE_BIN := ccache
export CCACHE_DIR := $(if $(CCACHE_DIR),$(CCACHE_DIR),$(HOME)/.ccache) export CCACHE_DIR := $(if $(CCACHE_DIR),$(CCACHE_DIR),$(HOME)/.ccache)
DOCKER_OPTS := $(CCACHE_ENV) -e CCACHE_DIR=$(CCACHE_DIR) $(DOCKER_OPTS) DOCKER_OPTS := -v $(CCACHE_DIR):$(CCACHE_DIR) $(CCACHE_ENV) -e CCACHE_DIR=$(CCACHE_DIR) $(DOCKER_OPTS)
else else
export CCACHE_DISABLE := 1 export CCACHE_DISABLE := 1
DOCKER_OPTS := $(CCACHE_ENV) -e CCACHE_DISABLE=1 $(DOCKER_OPTS) DOCKER_OPTS := $(CCACHE_ENV) -e CCACHE_DISABLE=1 $(DOCKER_OPTS)
endif endif
DOCKER_BASE = docker run --rm -e HOME -e USER -e USERID=$(shell id -u) -u $(shell id -u):$(shell id -g) \ DOCKER_BASE = docker run --rm -e HOME -e USER -e USERID=$(shell id -u) -u $(shell id -u):$(shell id -g) \
-v $(HOME):$(HOME) -v $(SRC):$(SRC) -v $(OBJ):$(OBJ) -w $(OBJ) -e MAKEFLAGS \ -v $(SRC):$(SRC) -v $(OBJ):$(OBJ) -w $(OBJ) -e MAKEFLAGS \
$(DOCKER_OPTS) $(STEAMRT_IMAGE) $(DOCKER_OPTS) $(STEAMRT_IMAGE)
STEAMRT_NAME ?= soldier STEAMRT_NAME ?= soldier
@ -90,6 +90,9 @@ all32 $(MAKECMDGOALS64):
ifeq ($(CONTAINER),) ifeq ($(CONTAINER),)
J := $(shell nproc) J := $(shell nproc)
ifeq ($(ENABLE_CCACHE),1)
container-build: $(shell mkdir -p $(CCACHE_DIR))
endif
container-build: private SHELL := $(CONTAINER_SHELL) container-build: private SHELL := $(CONTAINER_SHELL)
container-build: container-build:
+$(MAKE) -j$(J) $(filter -j%,$(MAKEFLAGS)) -f $(firstword $(MAKEFILE_LIST)) $(MFLAGS) $(MAKEOVERRIDES) CONTAINER=1 $(CONTAINERGOALS) +$(MAKE) -j$(J) $(filter -j%,$(MAKEFLAGS)) -f $(firstword $(MAKEFILE_LIST)) $(MFLAGS) $(MAKEOVERRIDES) CONTAINER=1 $(CONTAINERGOALS)