github.com/tiagovtristao/plz@v13.4.0+incompatible/src/core/subrepo.go (about)

     1  package core
     2  
     3  import (
     4  	"github.com/thought-machine/please/src/cli"
     5  	"path"
     6  )
     7  
     8  // A Subrepo stores information about a registered subrepository, typically one
     9  // that we have downloaded somehow to bring in third-party deps.
    10  type Subrepo struct {
    11  	// The name of the subrepo.
    12  	Name string
    13  	// The root directory to load it from.
    14  	Root string
    15  	// If this repo is output by a target, this is the target that creates it. Can be nil.
    16  	Target *BuildTarget
    17  	// The build state instance that tracks this subrepo (it's different from the host one if
    18  	// this subrepo is for a different architecture)
    19  	State *BuildState
    20  	// True if this subrepo was created for a different architecture
    21  	IsCrossCompile bool
    22  }
    23  
    24  // SubrepoForArch creates a new subrepo for the given architecture.
    25  func SubrepoForArch(state *BuildState, arch cli.Arch) *Subrepo {
    26  	return &Subrepo{
    27  		Name:           arch.String(),
    28  		State:          state.ForArch(arch),
    29  		IsCrossCompile: true,
    30  	}
    31  }
    32  
    33  // Dir returns the directory for a package of this name.
    34  func (s *Subrepo) Dir(dir string) string {
    35  	return path.Join(s.Root, dir)
    36  }