build: Support ccache.

This commit is contained in:
Zhiyi Zhang 2020-08-17 10:06:22 -05:00 committed by Andrew Eikum
parent 8828544db7
commit 24b944292e
3 changed files with 31 additions and 14 deletions

View file

@ -38,17 +38,22 @@ endif
# If CC is coming from make's defaults or nowhere, use our own default. Otherwise respect environment.
ifneq ($(filter default undefined,$(origin CC)),)
# CC = ccache gcc
CC = gcc
endif
ifneq ($(filter default undefined,$(origin CXX)),)
# CXX = ccache g++
CXX = g++
endif
export CC
export CXX
ifeq ($(ENABLE_CCACHE),1)
export PATH := /usr/lib/ccache:$(PATH)
else
export CCACHE_DISABLE = 1
DOCKER_CCACHE_FLAG = -e CCACHE_DISABLE=1
endif
CC32 := gcc -m32 -mstackrealign
CXX32 := g++ -m32 -mstackrealign
PKG_CONFIG32 := i686-linux-gnu-pkg-config
@ -61,7 +66,7 @@ cc-option = $(shell if test -z "`echo 'void*p=1;' | \
DOCKER_SHELL_BASE = docker run --rm --init --privileged --cap-add=SYS_ADMIN --security-opt apparmor:unconfined \
-v $(HOME):$(HOME) -v /tmp:/tmp \
-v /etc/passwd:/etc/passwd:ro -v /etc/group:/etc/group:ro -v /etc/shadow:/etc/shadow:ro \
-w $(CURDIR) -e HOME=$(HOME) -e PATH=$(PATH) -u $(shell id -u):$(shell id -g) -h $(shell hostname) \
-w $(CURDIR) -e HOME=$(HOME) -e PATH=$(PATH) $(DOCKER_CCACHE_FLAG) -u $(shell id -u):$(shell id -g) -h $(shell hostname) \
$(DOCKER_OPTS) \
$(SELECT_DOCKER_IMAGE) /sbin/docker-init -sg -- /bin/bash