diff options
Diffstat (limited to 'buildstream/_loader/loader.py')
-rw-r--r-- | buildstream/_loader/loader.py | 16 |
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, |