From: Thibaut VARÈNE Date: Thu, 21 Jun 2018 19:14:14 +0000 (+0200) Subject: phase1: opportunistic use of ccache X-Git-Tag: v1~145 X-Git-Url: http://git.openwrt.org/?a=commitdiff_plain;h=750174c0cee95925dd322f37c211577d0ebc0dc4;p=buildbot.git phase1: opportunistic use of ccache Assuming that CONFIG_CCACHE is disabled in the target config.seed, this patch tries to enable the use of ccache (if available from the host) for the 'dltar' and 'tools' steps, which are the only two steps where the build objects are shared by /all/ workers, and thus the two steps where caching makes the most sense and should provide the most benefits. Signed-off-by: Thibaut VARÈNE --- diff --git a/phase1/master.cfg b/phase1/master.cfg index 80955b5..b0e6422 100644 --- a/phase1/master.cfg +++ b/phase1/master.cfg @@ -203,6 +203,7 @@ from buildbot.process.factory import BuildFactory from buildbot.steps.source.git import Git from buildbot.steps.shell import ShellCommand from buildbot.steps.shell import SetProperty +from buildbot.steps.shell import SetPropertyFromCommand from buildbot.steps.transfer import FileUpload from buildbot.steps.transfer import FileDownload from buildbot.steps.master import MasterShellCommand @@ -299,17 +300,29 @@ def GetCwd(props): else: return "/" +def GetCCache(props): + if props.hasProperty("ccache_command") and "ccache" in props["ccache_command"]: + return props["ccache_command"] + " " + else: + return "" + def GetNextBuild(builder, requests): for r in requests: if r.properties and r.properties.hasProperty("tag"): return r return requests[0] -def MakeEnv(overrides=None): +def MakeEnv(overrides=None, tryccache=False): + if tryccache: + envcc = Interpolate("%(kw:ccache)s%(kw:cc)s", ccache=GetCCache, cc=GetCC) + envcxx = Interpolate("%(kw:ccache)s%(kw:cxx)s", ccache=GetCCache, cxx=GetCXX) + else: + envcc = Interpolate("%(kw:cc)s", cc=GetCC) + envcxx = Interpolate("%(kw:cxx)s", cxx=GetCXX) env = { - 'CC': WithProperties("%(cc)s", cc=GetCC), - 'CXX': WithProperties("%(cxx)s", cxx=GetCXX), - 'CCACHE_BASEDIR': WithProperties("%(cwd)s", cwd=GetCwd) + 'CC': envcc, + 'CXX': envcxx, + 'CCACHE_BASEDIR': Interpolate("%(kw:cwd)s", cwd=GetCwd) } if overrides is not None: env.update(overrides) @@ -430,6 +443,16 @@ for target in targets: command = ["../findbin.pl", "g++", cc_version[0], cc_version[1]], haltOnFailure = True)) + # see if ccache is available + factory.addStep(SetPropertyFromCommand( + property = "ccache_command", + command = ["which", "ccache"], + description = "Testing for ccache command", + haltOnFailure = False, + flunkOnFailure = False, + warnOnFailure = False, + )) + # expire tree if needed if tree_expire > 0: factory.addStep(FileDownload( @@ -623,7 +646,7 @@ for target in targets: name = "dltar", description = "Building and installing GNU tar", command = ["make", WithProperties("-j%(jobs)d", jobs=GetNumJobs), "tools/tar/compile", "V=s"], - env = MakeEnv(), + env = MakeEnv(tryccache=True), haltOnFailure = True )) @@ -648,7 +671,7 @@ for target in targets: name = "tools", description = "Building and installing tools", command = ["make", WithProperties("-j%(jobs)d", jobs=GetNumJobs), "tools/install", "V=s"], - env = MakeEnv(), + env = MakeEnv(tryccache=True), haltOnFailure = True ))