From 0ac7193c4ddc66e69af25018d982ed790377dddb Mon Sep 17 00:00:00 2001 From: Zachary Yedidia Date: Fri, 15 Jul 2022 11:40:32 -0700 Subject: [PATCH] Fix cross compilation from macOS --- Makefile | 2 +- tools/info-plist.go | 44 ++++++++++++++++++++++---------------------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/Makefile b/Makefile index af3fc987..0034173a 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ DATE = $(shell GOOS=$(shell go env GOHOSTOS) GOARCH=$(shell go env GOHOSTARCH) \ go run tools/build-date.go) ADDITIONAL_GO_LINKER_FLAGS = $(shell GOOS=$(shell go env GOHOSTOS) \ GOARCH=$(shell go env GOHOSTARCH) \ - go run tools/info-plist.go "$(VERSION)") + go run tools/info-plist.go "$(GOOS)" "$(VERSION)") GOBIN ?= $(shell go env GOPATH)/bin GOVARS = -X github.com/zyedidia/micro/v2/internal/util.Version=$(VERSION) -X github.com/zyedidia/micro/v2/internal/util.CommitHash=$(HASH) -X 'github.com/zyedidia/micro/v2/internal/util.CompileDate=$(DATE)' DEBUGVAR = -X github.com/zyedidia/micro/v2/internal/util.Debug=ON diff --git a/tools/info-plist.go b/tools/info-plist.go index b2beee78..d57a7b24 100644 --- a/tools/info-plist.go +++ b/tools/info-plist.go @@ -1,4 +1,5 @@ -//+build ignore +//go:build ignore +// +build ignore package main @@ -6,7 +7,6 @@ import ( "fmt" "io/ioutil" "os" - "runtime" ) func check(e error) { @@ -16,32 +16,32 @@ func check(e error) { } func main() { - if runtime.GOOS == "darwin" { - if len(os.Args) == 2 { + if len(os.Args) == 3 { + if os.Args[1] == "darwin" { rawInfoPlistString := ` - - - - CFBundleIdentifier - io.github.micro-editor - CFBundleName - micro - CFBundleInfoDictionaryVersion - 6.0 - CFBundlePackageType - APPL - CFBundleShortVersionString - ` + os.Args[1] + ` - - -` + + + + CFBundleIdentifier + io.github.micro-editor + CFBundleName + micro + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + APPL + CFBundleShortVersionString + ` + os.Args[2] + ` + + + ` infoPlistData := []byte(rawInfoPlistString) err := ioutil.WriteFile("/tmp/micro-info.plist", infoPlistData, 0644) check(err) fmt.Println("-linkmode external -extldflags -Wl,-sectcreate,__TEXT,__info_plist,/tmp/micro-info.plist") - } else { - panic("missing argument for version number!") } + } else { + panic("missing arguments") } } -- 2.44.0