Skip to content

Commit e3f6186

Browse files
authored
fix(variables): always build for GOHOSTOS (#161)
Signed-off-by: Ben Dronen <dronenb@users.noreply.github.com>
1 parent a161b9a commit e3f6186

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

pkg/bingo/variables.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ GOPATH ?= $(shell go env GOPATH)
1414
GOBIN ?= $(firstword $(subst :, ,${GOPATH}))/bin
1515
GO ?= $(shell which go)
1616
17+
# Ensure bingo-managed tools are always built for the host platform,
18+
# even when GOOS/GOARCH are set for cross-compilation of other targets.
19+
GOHOSTOS ?= $(shell $(GO) env GOHOSTOS)
20+
GOHOSTARCH ?= $(shell $(GO) env GOHOSTARCH)
21+
GOHOSTARM ?= $(shell $(GO) env GOHOSTARM)
22+
1723
# Below generated variables ensure that every time a tool under each variable is invoked, the correct version
1824
# will be used; reinstalling only if needed.
1925
# For example for {{ with (index .MainPackages 0) }}{{ .Name }}{{ end }} variable:
@@ -32,7 +38,7 @@ $({{ $p.EnvVarName }}):{{- range $p.Versions }} $(BINGO_DIR)/{{ .ModFile }}{{- e
3238
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.
3339
{{- range $p.Versions }}
3440
@echo "(re)installing $(GOBIN)/{{ $p.Name }}-{{ .Version }}"
35-
@cd $(BINGO_DIR) && GOWORK=off {{ range $p.BuildEnvVars }}{{ . }} {{ end }}$(GO) build {{ range $p.BuildFlags }}{{ . }} {{ end }}-mod=mod -modfile={{ .ModFile }} -o=$(GOBIN)/{{ $p.Name }}-{{ .Version }} "{{ $p.PackagePath }}"
41+
@cd $(BINGO_DIR) && GOWORK=off GOOS=$(GOHOSTOS) GOARCH=$(GOHOSTARCH) GOARM=$(GOHOSTARM) {{ range $p.BuildEnvVars }}{{ . }} {{ end }}$(GO) build {{ range $p.BuildFlags }}{{ . }} {{ end }}-mod=mod -modfile={{ .ModFile }} -o=$(GOBIN)/{{ $p.Name }}-{{ .Version }} "{{ $p.PackagePath }}"
3642
{{- end }}
3743
{{ end}}
3844
`,

0 commit comments

Comments
 (0)