From f5d0974c1ae3e302aec7767228cb87b61767be5c Mon Sep 17 00:00:00 2001
From: =?utf8?q?Thibaut=20VAR=C3=88NE?= <hacks@slashdirt.org>
Date: Thu, 21 Jun 2018 20:16:42 +0200
Subject: [PATCH] phase1: report ccache stats at end of build
MIME-Version: 1.0
Content-Type: text/plain; charset=utf8
Content-Transfer-Encoding: 8bit

ccache.sh tries to report ccache statistics but at the time this
script is run, the ccache binary hasn't been built and is thus
unavailable.

This patch tries to run 'ccache -s' at the end of the build. It
will look for ccache in the staging_dir first then in the host PATH.

Signed-off-by: Thibaut VARÈNE <hacks@slashdirt.org>
---
 phase1/ccache.sh  |  2 --
 phase1/master.cfg | 12 ++++++++++++
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/phase1/ccache.sh b/phase1/ccache.sh
index 3c4c614..8756bc2 100755
--- a/phase1/ccache.sh
+++ b/phase1/ccache.sh
@@ -18,6 +18,4 @@ for dir in $(make --no-print-directory val.TOOLCHAIN_DIR val.STAGING_DIR val.STA
 	fi
 done
 
-./staging_dir/host/bin/ccache -s 2>/dev/null
-
 exit 0
diff --git a/phase1/master.cfg b/phase1/master.cfg
index b0e6422..b4da1ad 100644
--- a/phase1/master.cfg
+++ b/phase1/master.cfg
@@ -960,6 +960,18 @@ for target in targets:
 		alwaysRun = True
 	))
 
+	factory.addStep(ShellCommand(
+		name = "ccachestat",
+		description = "Reporting ccache stats",
+		command=["ccache", "-s"],
+		env = MakeEnv(overrides={ 'PATH': ["./staging_dir/host/bin", "${PATH}"] }),
+		want_stderr = False,
+		haltOnFailure = False,
+		flunkOnFailure = False,
+		warnOnFailure = False,
+		alwaysRun = True,
+	))
+
 	from buildbot.config import BuilderConfig
 
 	c['builders'].append(BuilderConfig(name=target, slavenames=slaveNames, factory=factory, nextBuild=GetNextBuild))
-- 
2.30.2