|
|
|
|
|
by jgrahamc
765 days ago
|
|
I think this post is well intentioned but misses the point entirely. GOOS=darwin GOARCH=arm64 go build -ldflags="-X 'main.Version=v1.2.3'"
Executing this with variables for os/arch/version is not straightforward in a makefile. You might argue that it's a flaw with the `go build` command, but replace go with cargo/dotnet/maven and you have the same problem.What makes that hard? I think the following works correctly: $ cat Makefile
goos := FOO
goarch := BAR
mainversion := BAZ
.PHONY: build
build: ; @GOOS=$(goos) GOARCH=$(goarch) go build -ldflags="-X 'main.Version=v$(mainversion)'"*
$ make -n
GOOS=FOO GOARCH=BAR go build -ldflags="-X 'main.Version=vBAZ'"
|
|