github.com/ahmet2mir/goreleaser@v0.180.3-0.20210927151101-8e5ee5a9b8c5/pkg/build/build.go (about)

     1  // Package build provides the API for external builders
     2  package build
     3  
     4  import (
     5  	"sync"
     6  
     7  	"github.com/goreleaser/goreleaser/pkg/config"
     8  	"github.com/goreleaser/goreleaser/pkg/context"
     9  )
    10  
    11  // nolint: gochecknoglobals
    12  var (
    13  	builders = map[string]Builder{}
    14  	lock     sync.Mutex
    15  )
    16  
    17  // Register registers a builder to a given name.
    18  func Register(name string, builder Builder) {
    19  	lock.Lock()
    20  	builders[name] = builder
    21  	lock.Unlock()
    22  }
    23  
    24  // For gets the previously registered builder for the given name.
    25  func For(name string) Builder {
    26  	return builders[name]
    27  }
    28  
    29  // Options to be passed down to a builder.
    30  type Options struct {
    31  	Name   string
    32  	Path   string
    33  	Ext    string
    34  	Target string
    35  	Goos   string
    36  	Goarch string
    37  	Goarm  string
    38  	Gomips string
    39  }
    40  
    41  // Builder defines a builder.
    42  type Builder interface {
    43  	WithDefaults(build config.Build) (config.Build, error)
    44  	Build(ctx *context.Context, build config.Build, options Options) error
    45  }