From 6cecd0ff955cc2e9033d4cacf99b2a7bd4779569 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Thibaut=20VAR=C3=88NE?= Date: Fri, 29 Jun 2018 12:39:01 +0200 Subject: [PATCH] phase1: use wrappers for ccache MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 750174c0cee95925dd322f37c211577d0ebc0dc4 attempted to inject ccache into the CC environment, but that doesn't work as the CC/CXX variables are processed by the build system, in order to extract the path to an executable file. This commit works around that situation by creating two simple wrapper scripts on the slave. The remaining logic is unchanged: When tryccache is False, CC/CXX point to the regular compilers and no ccache injection is performed. When tryccache is True, CC/CXX point to their respective wrapper, and CCACHE is set to the path to ccache (if it exists, empty otherwise), CCC/CCXX point to the original compilers, and the wrappers will execute '${CCACHE} ${CCC} "$@"' or '${CCACHE} ${CCXX} "$@"'. If ${CCACHE} is unset, this falls back to plain compilers. i.e. ccache is only used if tryccache=True AND ccache has been found on the slave. Use 'exec' to avoid lingering shell during execution. Signed-off-by: Thibaut VARÈNE --- phase1/master.cfg | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/phase1/master.cfg b/phase1/master.cfg index 118e867..0acf210 100644 --- a/phase1/master.cfg +++ b/phase1/master.cfg @@ -208,6 +208,7 @@ from buildbot.steps.shell import ShellCommand from buildbot.steps.shell import SetPropertyFromCommand from buildbot.steps.transfer import FileUpload from buildbot.steps.transfer import FileDownload +from buildbot.steps.transfer import StringDownload from buildbot.steps.master import MasterShellCommand from buildbot.process.properties import Interpolate from buildbot.process import properties @@ -320,7 +321,7 @@ def GetCwd(props): @properties.renderer def GetCCache(props): if props.hasProperty("ccache_command") and "ccache" in props["ccache_command"]: - return props["ccache_command"] + " " + return props["ccache_command"] else: return "" @@ -332,14 +333,23 @@ def GetNextBuild(builder, requests): 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) + envcc = Interpolate("%(kw:cwd)s/ccache_cc.sh", cwd=GetCwd) + envcxx = Interpolate("%(kw:cwd)s/ccache_cxx.sh", cwd=GetCwd) + envccache = Interpolate("%(kw:ccache)s", ccache=GetCCache) + envccc = Interpolate("%(kw:cc)s", cc=GetCC) + envccxx = Interpolate("%(kw:cxx)s", cxx=GetCXX) else: envcc = Interpolate("%(kw:cc)s", cc=GetCC) envcxx = Interpolate("%(kw:cxx)s", cxx=GetCXX) + envccache = "" + envccc = "" + envccxx = "" env = { 'CC': envcc, 'CXX': envcxx, + 'CCACHE': envccache, + 'CCC': envccc, + 'CCXX': envccxx, } if overrides is not None: env.update(overrides) @@ -660,6 +670,20 @@ for target in targets: want_stdout = False )) + factory.addStep(StringDownload( + name = "ccachecc", + s = '#!/bin/sh\nexec ${CCACHE} ${CCC} "$@"\n', + slavedest = "../ccache_cc.sh", + mode = 0755, + )) + + factory.addStep(StringDownload( + name = "ccachecxx", + s = '#!/bin/sh\nexec ${CCACHE} ${CCXX} "$@"\n', + slavedest = "../ccache_cxx.sh", + mode = 0755, + )) + # prepare tar factory.addStep(ShellCommand( name = "dltar", -- 2.30.2