1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-07-01 00:54:57 +02:00
Files
Carlos Alexandro Becker d43f84aa3f refactor(build): preparing to support multiple languages (#5307)
This starts laying the foundation for supporting more languages, the
first of which will probably be Zig, and then Rust.

I already have a zig prototype working in another branch, just raw
dogged it to see if it would work, and since it does, now I'll do it
piece by piece but with hopefully slightly better code.
2024-11-25 23:00:28 -03:00

64 lines
1.3 KiB
Go

package golang
import (
"github.com/goreleaser/goreleaser/v2/internal/tmpl"
"github.com/goreleaser/goreleaser/v2/pkg/config"
)
func formatTarget(o config.BuildDetailsOverride) string {
target := o.Goos + "_" + o.Goarch
if extra := o.Goamd64 + o.Go386 + o.Goarm + o.Goarm64 + o.Gomips + o.Goppc64 + o.Goriscv64; extra != "" {
target += "_" + extra
}
return target
}
// Target is a Go build target.
type Target struct {
Target string
Goos string
Goarch string
Goamd64 string
Go386 string
Goarm string
Goarm64 string
Gomips string
Goppc64 string
Goriscv64 string
}
// Fields implements build.Target.
func (t Target) Fields() map[string]string {
return map[string]string{
tmpl.KeyOS: t.Goos,
tmpl.KeyArch: t.Goarch,
tmpl.KeyAmd64: t.Goamd64,
tmpl.Key386: t.Go386,
tmpl.KeyArm: t.Goarm,
tmpl.KeyArm64: t.Goarm64,
tmpl.KeyMips: t.Gomips,
tmpl.KeyPpc64: t.Goppc64,
tmpl.KeyRiscv64: t.Goriscv64,
}
}
// String implements fmt.Stringer.
func (t Target) String() string {
return t.Target
}
func (t Target) env() []string {
return []string{
"GOOS=" + t.Goos,
"GOARCH=" + t.Goarch,
"GOAMD64=" + t.Goamd64,
"GO386=" + t.Go386,
"GOARM=" + t.Goarm,
"GOARM64=" + t.Goarm64,
"GOMIPS=" + t.Gomips,
"GOMIPS64=" + t.Gomips,
"GOPPC64=" + t.Goppc64,
"GORISCV64=" + t.Goriscv64,
}
}