ccache.mk revision d78cba12fe17c2c4406bb7e12c4110518c5c6859
1#
2# Copyright (C) 2015 The Android Open Source Project
3#
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
7#
8#      http://www.apache.org/licenses/LICENSE-2.0
9#
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.
15#
16
17ifneq ($(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
21
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
27
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
32  # on a workstation.
33  export CCACHE_BASEDIR := /
34
35  # Workaround for ccache with clang.
36  # See http://petereisentraut.blogspot.com/2011/09/ccache-and-clang-part-2.html
37  export CCACHE_CPP2 := true
38
39  CCACHE_HOST_TAG := $(HOST_PREBUILT_TAG)
40  ccache := prebuilts/misc/$(CCACHE_HOST_TAG)/ccache/ccache
41  # Check that the executable is here.
42  ccache := $(strip $(wildcard $(ccache)))
43  ifdef ccache
44    ifndef CC_WRAPPER
45      CC_WRAPPER := $(ccache)
46    endif
47    ifndef CXX_WRAPPER
48      CXX_WRAPPER := $(ccache)
49    endif
50    ccache =
51  endif
52endif
53