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"
|
|
|
|
|
2024-05-26 20:02:57 +02:00
|
|
|
"github.com/goreleaser/goreleaser/v2/pkg/config"
|
|
|
|
"github.com/goreleaser/goreleaser/v2/pkg/context"
|
2018-01-21 18:31:08 +02:00
|
|
|
)
|
|
|
|
|
2024-05-12 19:11:11 +02:00
|
|
|
//nolint:gochecknoglobals
|
2018-01-21 18:31:08 +02:00
|
|
|
var (
|
|
|
|
builders = map[string]Builder{}
|
|
|
|
lock sync.Mutex
|
|
|
|
)
|
|
|
|
|
2021-09-11 18:01:57 +02:00
|
|
|
// Register registers a builder to a given name.
|
|
|
|
func Register(name string, builder Builder) {
|
2018-01-21 18:31:08 +02:00
|
|
|
lock.Lock()
|
2021-09-11 18:01:57 +02:00
|
|
|
builders[name] = builder
|
2018-01-21 18:31:08 +02:00
|
|
|
lock.Unlock()
|
|
|
|
}
|
|
|
|
|
2021-09-11 18:01:57 +02:00
|
|
|
// For gets the previously registered builder for the given name.
|
|
|
|
func For(name string) Builder {
|
|
|
|
return builders[name]
|
2018-01-21 18:31:08 +02:00
|
|
|
}
|
|
|
|
|
2020-05-26 05:48:10 +02:00
|
|
|
// Options to be passed down to a builder.
|
2018-01-21 18:31:08 +02:00
|
|
|
type Options struct {
|
2024-10-14 14:40:10 +02:00
|
|
|
Name string
|
|
|
|
Path string
|
2024-10-15 19:57:27 +02:00
|
|
|
Ext string // with the leading `.`.
|
2024-10-14 14:40:10 +02:00
|
|
|
Target string
|
|
|
|
Goos string
|
|
|
|
Goarch string
|
|
|
|
Goamd64 string
|
|
|
|
Go386 string
|
|
|
|
Goarm string
|
|
|
|
Goarm64 string
|
|
|
|
Gomips string
|
|
|
|
Goppc64 string
|
|
|
|
Goriscv64 string
|
2018-01-21 18:31:08 +02:00
|
|
|
}
|
|
|
|
|
2020-05-26 05:48:10 +02:00
|
|
|
// Builder defines a builder.
|
2018-01-21 18:31:08 +02:00
|
|
|
type Builder interface {
|
2020-11-05 09:20:14 +02:00
|
|
|
WithDefaults(build config.Build) (config.Build, error)
|
2018-01-21 18:31:08 +02:00
|
|
|
Build(ctx *context.Context, build config.Build, options Options) error
|
|
|
|
}
|