From: Michael Tremer Date: Fri, 28 Apr 2023 16:07:11 +0000 (+0000) Subject: jobs: Send ccache configuration to builders X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b3b470326db06f32eee19eeffbf79b8c29c3b418;p=pbs.git jobs: Send ccache configuration to builders Signed-off-by: Michael Tremer --- diff --git a/src/buildservice/builders.py b/src/buildservice/builders.py index 4417e50c..1da65103 100644 --- a/src/buildservice/builders.py +++ b/src/buildservice/builders.py @@ -697,6 +697,12 @@ class Builder(base.DataObject): "name" : "%s" % job, "arch" : job.arch, + # ccache path + "ccache" : { + "enabled" : job.ccache_enabled, + "path" : job.ccache_path, + }, + # Is this a test job? "test" : job.test, diff --git a/src/buildservice/jobs.py b/src/buildservice/jobs.py index 48721409..5a4c6380 100644 --- a/src/buildservice/jobs.py +++ b/src/buildservice/jobs.py @@ -692,6 +692,45 @@ class Job(base.DataObject): if self.data.builder_id: return self.backend.builders.get_by_id(self.data.builder_id) + @property + def ccache_enabled(self): + """ + Should the ccache be enabled for this build? + """ + # Enable the cache for scratch builds + if self.build.owner: + return True + + # Enable the cache for test builds + if self.test: + return True + + # Otherwise disable the ccache + return False + + @property + def ccache_path(self): + """ + Returns the path to a private ccache + """ + # Return nothing if the ccache should not be used + if not self.ccache_enabled: + return + + # Include the name of the package and the architecture + path = os.path.join( + self.build.pkg.name, + self.arch, + ) + + if self.build.owner: + path = os.path.join( + "~%s" % self.build.owner.name, + path, + ) + + return path + @property def arch(self): return self.data.arch