summaryrefslogtreecommitdiff
path: root/morphlib/builder2.py
diff options
context:
space:
mode:
authorJonathan Maw <jonathan.maw@codethink.co.uk>2012-12-10 17:55:23 +0000
committerJannis Pohlmann <jannis.pohlmann@codethink.co.uk>2012-12-17 12:08:55 +0000
commitf19efa182d0e53d97e163f980d6e221c55dd9c9b (patch)
tree0989586ca1ee444ceb538fcd1cf24e8eb8577dc9 /morphlib/builder2.py
parentac1cd545050a4aaa61e5b3f1dda5e278ba5e40b1 (diff)
downloadmorph-f19efa182d0e53d97e163f980d6e221c55dd9c9b.tar.gz
Add support for ccache
This is set up so that each individual project repository has its own ccache, all under one defined directory. The top-level ccache directory is added as the setting 'compiler-cache-dir', and defaults to $cachedir/ccache. When a build is performed, this will bind-mount a project's ccache into the /tmp/ccache of the staging-area and set up the environment variables so that ccache will be used (if appropriate executables are installed to /usr/lib/ccache in the staging-area). In addition, this removes code for ccache-remotedir, as it is unrelated to this implementation of ccache. Reviewed-by: Jannis Pohlmann <jannis.pohlmann@codethink.co.uk> Reviewed-by: Lars Wirzenius <lars.wirzenius@codethink.co.uk>
Diffstat (limited to 'morphlib/builder2.py')
-rw-r--r--morphlib/builder2.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/morphlib/builder2.py b/morphlib/builder2.py
index c7d25e1a..0c1acfde 100644
--- a/morphlib/builder2.py
+++ b/morphlib/builder2.py
@@ -289,6 +289,28 @@ class ChunkBuilder(BuilderBase):
('dev/shm', 'tmpfs', 'none'),
)
+ def mount_ccachedir(self): #pragma: no cover
+ ccache_dir = self.app.settings['compiler-cache-dir']
+ if not os.path.isdir(ccache_dir):
+ os.makedirs(ccache_dir)
+ # Get a path for the repo's ccache
+ ccache_repobase = os.path.basename(self.artifact.source.repo.path)
+ ccache_repodir = os.path.join(ccache_dir,
+ ccache_repobase)
+ # Make sure that directory exists
+ if not os.path.isdir(ccache_repodir):
+ os.mkdir(ccache_repodir)
+ # Get the destination path
+ ccache_destdir= os.path.join(self.staging_area.tempdir,
+ 'tmp', 'ccache')
+ # Make sure that the destination exists
+ if not os.path.isdir(ccache_destdir):
+ os.mkdir(ccache_destdir)
+ # Mount it into the staging-area
+ self.app.runcmd(['mount', '--bind', ccache_repodir,
+ ccache_destdir])
+ return ccache_destdir
+
def do_mounts(self): # pragma: no cover
mounted = []
if not self.setup_mounts:
@@ -300,6 +322,8 @@ class ChunkBuilder(BuilderBase):
os.makedirs(path)
self.app.runcmd(['mount', '-t', mount_type, source, path])
mounted.append(path)
+ if not self.app.settings['no-ccache']:
+ mounted.append(self.mount_ccachedir())
return mounted
def do_unmounts(self, mounted): # pragma: no cover