Commit b2ea208c authored by Jürg Billeter's avatar Jürg Billeter
Browse files

Merge branch 'juerg/local-junctions' into 'master'

Optimization for local junctions

See merge request !290
parents d09a18b8 eb5b10f7
Loading
Loading
Loading
Loading
Loading
+11 −5
Original line number Diff line number Diff line
@@ -563,17 +563,23 @@ class Loader():
                                "Subproject has no ref for junction: {}".format(filename),
                                detail=detail)

        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,
+3 −0
Original line number Diff line number Diff line
@@ -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):
+17 −0
Original line number Diff line number Diff line
@@ -615,6 +615,23 @@ class Source(Plugin):
        with utils._tempdir(dir=mirrordir) as tempdir:
            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            #
    #############################################################