]> git.ipfire.org Git - pbs.git/commitdiff
jobs: Send ccache configuration to builders
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 28 Apr 2023 16:07:11 +0000 (16:07 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 28 Apr 2023 16:07:11 +0000 (16:07 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/buildservice/builders.py
src/buildservice/jobs.py

index 4417e50c9e5f4b81c20d393ac0219c23ea753784..1da651030811e4b2d47f06740a532f692f8f3a20 100644 (file)
@@ -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,
 
index 4872140902f3cae1efdd20a5e6e3f1545e6a2f01..5a4c63802237e23d7653c78a83ef82499a8c75cc 100644 (file)
@@ -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