2018-01-25 01:22:45 +02:00
|
|
|
// Package build provides the API for external builders
|
2018-01-21 18:31:08 +02:00
|
|
|
package build
|
|
|
|
|
|
|
|
import (
|
|
|
|
"sync"
|
|
|
|
|
|
|
|
"github.com/goreleaser/goreleaser/config"
|
|
|
|
"github.com/goreleaser/goreleaser/context"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
builders = map[string]Builder{}
|
|
|
|
lock sync.Mutex
|
|
|
|
)
|
|
|
|
|
2018-01-27 01:54:08 +02:00
|
|
|
// Register registers a builder to a given lang
|
2018-01-21 18:31:08 +02:00
|
|
|
func Register(lang string, builder Builder) {
|
|
|
|
lock.Lock()
|
|
|
|
builders[lang] = builder
|
|
|
|
lock.Unlock()
|
|
|
|
}
|
|
|
|
|
2018-01-27 01:54:08 +02:00
|
|
|
// For gets the previously registered builder for the given lang
|
2018-01-21 18:31:08 +02:00
|
|
|
func For(lang string) Builder {
|
|
|
|
return builders[lang]
|
|
|
|
}
|
|
|
|
|
2018-01-25 01:22:45 +02:00
|
|
|
// Options to be passed down to a builder
|
2018-01-21 18:31:08 +02:00
|
|
|
type Options struct {
|
2018-01-22 02:44:06 +02:00
|
|
|
Name, Path, Ext, Target string
|
2018-01-21 18:31:08 +02:00
|
|
|
}
|
|
|
|
|
2018-01-25 01:22:45 +02:00
|
|
|
// Builder defines a builder
|
2018-01-21 18:31:08 +02:00
|
|
|
type Builder interface {
|
2018-01-26 23:35:12 +02:00
|
|
|
WithDefaults(build config.Build) config.Build
|
2018-01-21 18:31:08 +02:00
|
|
|
Build(ctx *context.Context, build config.Build, options Options) error
|
|
|
|
}
|