diff options
author | Chandan Singh <csingh43@bloomberg.net> | 2017-10-26 15:05:40 +0100 |
---|---|---|
committer | Jürg Billeter <j@bitron.ch> | 2018-01-25 11:52:48 +0000 |
commit | 5f1be604603843bc266252cf5a3a91939d2c09f5 (patch) | |
tree | 612fd567b75ceb1214338c5bf857e7f21e38a87f /buildstream/sandbox | |
parent | a950b86fd577841fa9f7cfb1e0e87bf9dfc29582 (diff) | |
download | buildstream-5f1be604603843bc266252cf5a3a91939d2c09f5.tar.gz |
Add support for doing incremental builds
This functionality is only supported for sources which have an open
workspace. When such sources are present, the workspace directory will
be mounted directly inside the sandbox. As opposed to the default
behavior, which is to copy files inside the sandbox.
This will save time when building large projects as only those files
will need be re-compiled that have been modified during two consecutive
builds (assuming the underlying build system supports such behavior).
A few things to note regarding this behavior:
- If there are any `configure-commands` present, they will run only once
for each open workspace. If an element has multiple workspaces and any
one of them is opened/closed, they will be executed again on the next
run. But, modifying the contents of a workspace will not trigger the
`configure-commands` to be executed on the next run.
- Workspaced builds still leverage the cache. So, if no changes are made
to the workspace, i.e. no files are modified, then it will not force a
rebuild.
Fixes #192.
Diffstat (limited to 'buildstream/sandbox')
-rw-r--r-- | buildstream/sandbox/_sandboxbwrap.py | 6 | ||||
-rw-r--r-- | buildstream/sandbox/_sandboxchroot.py | 6 | ||||
-rw-r--r-- | buildstream/sandbox/sandbox.py | 20 |
3 files changed, 30 insertions, 2 deletions
diff --git a/buildstream/sandbox/_sandboxbwrap.py b/buildstream/sandbox/_sandboxbwrap.py index f926e3de2..71fd6951b 100644 --- a/buildstream/sandbox/_sandboxbwrap.py +++ b/buildstream/sandbox/_sandboxbwrap.py @@ -116,9 +116,13 @@ class SandboxBwrap(Sandbox): # Add bind mounts to any marked directories marked_directories = self._get_marked_directories() + mount_source_overrides = self._get_mount_sources() for mark in marked_directories: mount_point = mark['directory'] - mount_source = mount_map.get_mount_source(mount_point) + if mount_point in mount_source_overrides: + mount_source = mount_source_overrides[mount_point] + else: + mount_source = mount_map.get_mount_source(mount_point) bwrap_command += ['--bind', mount_source, mount_point] if flags & SandboxFlags.ROOT_READ_ONLY: diff --git a/buildstream/sandbox/_sandboxchroot.py b/buildstream/sandbox/_sandboxchroot.py index 0a6043692..584f0e116 100644 --- a/buildstream/sandbox/_sandboxchroot.py +++ b/buildstream/sandbox/_sandboxchroot.py @@ -246,7 +246,11 @@ class SandboxChroot(Sandbox): @contextmanager def mount_point(point, **kwargs): - mount_source = self.mount_map.get_mount_source(point) + mount_source_overrides = self._get_mount_sources() + if point in mount_source_overrides: + mount_source = mount_source_overrides[point] + else: + mount_source = self.mount_map.get_mount_source(point) mount_point = os.path.join(rootfs, point.lstrip(os.sep)) with Mounter.bind_mount(mount_point, src=mount_source, stdout=stdout, stderr=stderr, **kwargs): diff --git a/buildstream/sandbox/sandbox.py b/buildstream/sandbox/sandbox.py index 64352d623..00245309a 100644 --- a/buildstream/sandbox/sandbox.py +++ b/buildstream/sandbox/sandbox.py @@ -82,6 +82,7 @@ class Sandbox(): self.__directories = [] self.__cwd = None self.__env = None + self.__mount_sources = {} # Setup the directories self.__directory = directory @@ -195,6 +196,25 @@ class Sandbox(): def _get_marked_directories(self): return self.__directories + # _get_mount_source() + # + # Fetches the list of mount sources + # + # Returns: + # (dict): A dictionary where keys are mount points and values are the mount sources + def _get_mount_sources(self): + return self.__mount_sources + + # _set_mount_source() + # + # Sets the mount source for a given mountpoint + # + # Args: + # mountpoint (str): The absolute mountpoint path inside the sandbox + # mount_source (str): the host path to be mounted at the mount point + def _set_mount_source(self, mountpoint, mount_source): + self.__mount_sources[mountpoint] = mount_source + # _get_environment() # # Fetches the environment variables for running commands |