mirror of
https://github.com/goreleaser/goreleaser.git
synced 2024-12-29 01:44:39 +02:00
24c6060050
historically this is kind of a mess, some places set the prefixed ext (e.g. `.exe`) others don't (e.g. `msi`) this standardize it to have the preceding `.` also makes `ByExt` works with or without it so it doesn't break anyone's config. Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
51 lines
1.0 KiB
Go
51 lines
1.0 KiB
Go
// Package build provides the API for external builders
|
|
package build
|
|
|
|
import (
|
|
"sync"
|
|
|
|
"github.com/goreleaser/goreleaser/v2/pkg/config"
|
|
"github.com/goreleaser/goreleaser/v2/pkg/context"
|
|
)
|
|
|
|
//nolint:gochecknoglobals
|
|
var (
|
|
builders = map[string]Builder{}
|
|
lock sync.Mutex
|
|
)
|
|
|
|
// Register registers a builder to a given name.
|
|
func Register(name string, builder Builder) {
|
|
lock.Lock()
|
|
builders[name] = builder
|
|
lock.Unlock()
|
|
}
|
|
|
|
// For gets the previously registered builder for the given name.
|
|
func For(name string) Builder {
|
|
return builders[name]
|
|
}
|
|
|
|
// Options to be passed down to a builder.
|
|
type Options struct {
|
|
Name string
|
|
Path string
|
|
Ext string // with the leading `.`.
|
|
Target string
|
|
Goos string
|
|
Goarch string
|
|
Goamd64 string
|
|
Go386 string
|
|
Goarm string
|
|
Goarm64 string
|
|
Gomips string
|
|
Goppc64 string
|
|
Goriscv64 string
|
|
}
|
|
|
|
// Builder defines a builder.
|
|
type Builder interface {
|
|
WithDefaults(build config.Build) (config.Build, error)
|
|
Build(ctx *context.Context, build config.Build, options Options) error
|
|
}
|