Merge pull request #185 from kived/ccache

add ccache support
This commit is contained in:
Mathieu Virbel 2016-04-17 23:34:16 +02:00
commit 90a6da48f9
3 changed files with 31 additions and 2 deletions

View file

@ -48,7 +48,8 @@ class HostpythonRecipe(Recipe):
def build_x86_64(self):
sdk_path = sh.xcrun("--sdk", "macosx", "--show-sdk-path").strip()
build_env = self.ctx.env.copy()
build_env["CC"] = "clang -Qunused-arguments -fcolor-diagnostics"
ccache = (build_env["CCACHE"] + ' ') if 'CCACHE' in build_env else ''
build_env["CC"] = ccache + "clang -Qunused-arguments -fcolor-diagnostics"
build_env["LDFLAGS"] = " ".join([
"-lsqlite3",
"-lffi",

View file

@ -19,9 +19,11 @@ class LibSDL2Recipe(Recipe):
self.set_marker("patched")
def build_arch(self, arch):
env = arch.get_env()
shprint(sh.xcodebuild,
"ONLY_ACTIVE_ARCH=NO",
"ARCHS={}".format(arch.arch),
"CC={}".format(env['CC']),
"-sdk", arch.sdk,
"-project", "Xcode-iOS/SDL/SDL.xcodeproj",
"-target", "libSDL",

View file

@ -122,6 +122,7 @@ class Arch(object):
def __init__(self, ctx):
super(Arch, self).__init__()
self.ctx = ctx
self._ccsh = None
def __str__(self):
return self.arch
@ -143,7 +144,32 @@ class Arch(object):
for d in self.ctx.include_dirs]
env = {}
env["CC"] = sh.xcrun("-find", "-sdk", self.sdk, "clang").strip()
ccache = sh.which('ccache').strip()
cc = sh.xcrun("-find", "-sdk", self.sdk, "clang").strip()
if ccache:
use_ccache = environ.get("USE_CCACHE", "1")
if use_ccache != '1':
env["CC"] = cc
else:
if not self._ccsh:
self._ccsh = ccsh = sh.mktemp().strip()
with open(ccsh, 'w') as f:
f.write('#!/bin/sh\n')
f.write(ccache + ' ' + cc + ' "$@"\n')
sh.chmod('+x', ccsh)
else:
ccsh = self._ccsh
env["USE_CCACHE"] = '1'
env["CCACHE"] = ccache
env["CC"] = ccsh
env.update({k: v for k, v in environ.items() if k.startswith('CCACHE_')})
env.setdefault('CCACHE_MAXSIZE', '10G')
env.setdefault('CCACHE_HARDLINK', 'true')
env.setdefault('CCACHE_SLOPPINESS', ('file_macro,time_macros,'
'include_file_mtime,include_file_ctime,file_stat_matches'))
else:
env["CC"] = cc
env["AR"] = sh.xcrun("-find", "-sdk", self.sdk, "ar").strip()
env["LD"] = sh.xcrun("-find", "-sdk", self.sdk, "ld").strip()
env["OTHER_CFLAGS"] = " ".join(include_dirs)