summaryrefslogtreecommitdiff
path: root/buildstream/_loader
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-27 12:11:24 +0000
commiteb5b10f7dd07b77910b2719c07b24ec466fd7cd5 (patch)
tree6fe157b84993a7eebea3ccd67ab8649b52ffd284 /buildstream/_loader
parent42809933d03d87aa6928d213233ec80ae3a8b3f1 (diff)
downloadbuildstream-eb5b10f7dd07b77910b2719c07b24ec466fd7cd5.tar.gz
_loader.py: Use Source._get_local_path() for subprojects
This eliminates unneeded copies of the project directory for junctions with a single local source.
Diffstat (limited to 'buildstream/_loader')
-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,