[Notes] [Git][BuildStream/buildstream][master] 4 commits: source.py: Add optional _get_local_path() method



Title: GitLab

Jürg Billeter pushed to branch master at BuildStream / buildstream

Commits:

3 changed files:

Changes:

  • buildstream/_loader/loader.py
    ... ... @@ -563,17 +563,23 @@ class Loader():
    563 563
                                     "Subproject has no ref for junction: {}".format(filename),
    
    564 564
                                     detail=detail)
    
    565 565
     
    
    566
    -        # Stage sources
    
    567
    -        os.makedirs(self._context.builddir, exist_ok=True)
    
    568
    -        basedir = tempfile.mkdtemp(prefix="{}-".format(element.normal_name), dir=self._context.builddir)
    
    569
    -        element._stage_sources_at(basedir, mount_workspaces=False)
    
    566
    +        if len(sources) == 1 and sources[0]._get_local_path():
    
    567
    +            # Optimization for junctions with a single local source
    
    568
    +            basedir = sources[0]._get_local_path()
    
    569
    +            tempdir = None
    
    570
    +        else:
    
    571
    +            # Stage sources
    
    572
    +            os.makedirs(self._context.builddir, exist_ok=True)
    
    573
    +            basedir = tempfile.mkdtemp(prefix="{}-".format(element.normal_name), dir=self._context.builddir)
    
    574
    +            element._stage_sources_at(basedir, mount_workspaces=False)
    
    575
    +            tempdir = basedir
    
    570 576
     
    
    571 577
             # Load the project
    
    572 578
             project_dir = os.path.join(basedir, element.path)
    
    573 579
             try:
    
    574 580
                 from .._project import Project
    
    575 581
                 project = Project(project_dir, self._context, junction=element,
    
    576
    -                              parent_loader=self, tempdir=basedir)
    
    582
    +                              parent_loader=self, tempdir=tempdir)
    
    577 583
             except LoadError as e:
    
    578 584
                 if e.reason == LoadErrorReason.MISSING_PROJECT_CONF:
    
    579 585
                     raise LoadError(reason=LoadErrorReason.INVALID_JUNCTION,
    

  • buildstream/plugins/sources/local.py
    ... ... @@ -124,6 +124,9 @@ class LocalSource(Source):
    124 124
                         else:
    
    125 125
                             os.chmod(path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IROTH)
    
    126 126
     
    
    127
    +    def _get_local_path(self):
    
    128
    +        return self.fullpath
    
    129
    +
    
    127 130
     
    
    128 131
     # Create a unique key for a file
    
    129 132
     def unique_key(filename):
    

  • buildstream/source.py
    ... ... @@ -615,6 +615,23 @@ class Source(Plugin):
    615 615
             with utils._tempdir(dir=mirrordir) as tempdir:
    
    616 616
                 yield tempdir
    
    617 617
     
    
    618
    +    #############################################################
    
    619
    +    #       Private Abstract Methods used in BuildStream        #
    
    620
    +    #############################################################
    
    621
    +
    
    622
    +    # Returns the local path to the source
    
    623
    +    #
    
    624
    +    # If the source is locally available, this method returns the absolute
    
    625
    +    # path. Otherwise, the return value is None.
    
    626
    +    #
    
    627
    +    # This is an optimization for local sources and optional to implement.
    
    628
    +    #
    
    629
    +    # Returns:
    
    630
    +    #    (str): The local absolute path, or None
    
    631
    +    #
    
    632
    +    def _get_local_path(self):
    
    633
    +        return None
    
    634
    +
    
    618 635
         #############################################################
    
    619 636
         #            Private Methods used in BuildStream            #
    
    620 637
         #############################################################
    



  • [Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]