summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2018-02-25 17:10:08 +0100
committerJürg Billeter <j@bitron.ch>2018-11-22 17:22:19 +0100
commit4ad911369fdf1c66d08fd611e3355ba89d949c7f (patch)
tree7d569ba94e6b9f48b93682d2026f2b4c8fe73d6a
parent823f693c6d42e9ad6b52cbd8a2bae1f3497b1fc3 (diff)
downloadbuildstream-juerg/local-junctions.tar.gz
_loader.py: Use Source._get_local_path() for subprojectsjuerg/local-junctions
This eliminates unneeded copies of the project directory for junctions with a single local source.
-rw-r--r--buildstream/_loader/loader.py16
1 files changed, 11 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,