summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2018-11-27 12:50:46 +0000
committerJürg Billeter <j@bitron.ch>2018-11-27 12:50:46 +0000
commitb2ea208c427dbda4969a4922657c9cd5437c46ca (patch)
tree6fe157b84993a7eebea3ccd67ab8649b52ffd284
parentd09a18b8522a528f7035302f97b3692fd5c8cddc (diff)
parenteb5b10f7dd07b77910b2719c07b24ec466fd7cd5 (diff)
downloadbuildstream-b2ea208c427dbda4969a4922657c9cd5437c46ca.tar.gz
Merge branch 'juerg/local-junctions' into 'master'
Optimization for local junctions See merge request BuildStream/buildstream!290
-rw-r--r--buildstream/_loader/loader.py16
-rw-r--r--buildstream/plugins/sources/local.py3
-rw-r--r--buildstream/source.py17
3 files changed, 31 insertions, 5 deletions
diff --git a/buildstream/_loader/loader.py b/buildstream/_loader/loader.py
index 22600b9e9..a3c4ea8f0 100644
--- a/buildstream/_loader/loader.py
+++ b/buildstream/_loader/loader.py
@@ -563,17 +563,23 @@ class Loader():
"Subproject has no ref for junction: {}".format(filename),
detail=detail)
- # Stage sources
- os.makedirs(self._context.builddir, exist_ok=True)
- basedir = tempfile.mkdtemp(prefix="{}-".format(element.normal_name), dir=self._context.builddir)
- element._stage_sources_at(basedir, mount_workspaces=False)
+ if len(sources) == 1 and sources[0]._get_local_path():
+ # Optimization for junctions with a single local source
+ basedir = sources[0]._get_local_path()
+ tempdir = None
+ else:
+ # Stage sources
+ os.makedirs(self._context.builddir, exist_ok=True)
+ basedir = tempfile.mkdtemp(prefix="{}-".format(element.normal_name), dir=self._context.builddir)
+ element._stage_sources_at(basedir, mount_workspaces=False)
+ tempdir = basedir
# Load the project
project_dir = os.path.join(basedir, element.path)
try:
from .._project import Project
project = Project(project_dir, self._context, junction=element,
- parent_loader=self, tempdir=basedir)
+ parent_loader=self, tempdir=tempdir)
except LoadError as e:
if e.reason == LoadErrorReason.MISSING_PROJECT_CONF:
raise LoadError(reason=LoadErrorReason.INVALID_JUNCTION,
diff --git a/buildstream/plugins/sources/local.py b/buildstream/plugins/sources/local.py
index bbb42d06a..55cdc14d3 100644
--- a/buildstream/plugins/sources/local.py
+++ b/buildstream/plugins/sources/local.py
@@ -124,6 +124,9 @@ class LocalSource(Source):
else:
os.chmod(path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IROTH)
+ def _get_local_path(self):
+ return self.fullpath
+
# Create a unique key for a file
def unique_key(filename):
diff --git a/buildstream/source.py b/buildstream/source.py
index f346fdf83..d6681b963 100644
--- a/buildstream/source.py
+++ b/buildstream/source.py
@@ -616,6 +616,23 @@ class Source(Plugin):
yield tempdir
#############################################################
+ # Private Abstract Methods used in BuildStream #
+ #############################################################
+
+ # Returns the local path to the source
+ #
+ # If the source is locally available, this method returns the absolute
+ # path. Otherwise, the return value is None.
+ #
+ # This is an optimization for local sources and optional to implement.
+ #
+ # Returns:
+ # (str): The local absolute path, or None
+ #
+ def _get_local_path(self):
+ return None
+
+ #############################################################
# Private Methods used in BuildStream #
#############################################################