2 # Copyright (C) 2015 The Android Open Source Project
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
17 ifneq ($(filter-out false,$(USE_CCACHE)),)
18 # The default check uses size and modification time, causing false misses
19 # since the mtime depends when the repo was checked out
20 export CCACHE_COMPILERCHECK := content
22 # See man page, optimizations to get more cache hits
23 # implies that __DATE__ and __TIME__ are not critical for functionality.
24 # Ignore include file modification time since it will depend on when
25 # the repo was checked out
26 export CCACHE_SLOPPINESS := time_macros,include_file_mtime,file_macro
28 # Turn all preprocessor absolute paths into relative paths.
29 # Fixes absolute paths in preprocessed source due to use of -g.
30 # We don't really use system headers much so the rootdir is
31 # fine; ensures these paths are relative for all Android trees
33 ifeq ($(CCACHE_BASEDIR),)
34 export CCACHE_BASEDIR := $(ANDROID_BUILD_TOP)
37 # Workaround for ccache with clang.
38 # See http://petereisentraut.blogspot.com/2011/09/ccache-and-clang-part-2.html
39 export CCACHE_CPP2 := true
41 # Detect if the system already has ccache installed to use instead of the prebuilt
42 ccache := $(shell which ccache)
45 CCACHE_HOST_TAG := $(HOST_PREBUILT_TAG)
46 ccache := prebuilts/misc/$(CCACHE_HOST_TAG)/ccache/ccache
49 # Check that the executable is here.
50 ccache := $(strip $(wildcard $(ccache)))
53 CC_WRAPPER := $(ccache)
56 CXX_WRAPPER := $(ccache)