From 6736eb27eceff9e2994be18465563a6a1771b928 Mon Sep 17 00:00:00 2001 From: Filip Czaplicki Date: Tue, 3 Sep 2024 18:04:28 +0200 Subject: [PATCH 1/2] Use echo -e for generating version.go Flag -e is to "enable interpretation of backslash escapes" Which might be a default, depends on a shell. sh -c 'echo "a\nb"' on my OS prints "a\nb" (no newline) --- desktop/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/desktop/Makefile b/desktop/Makefile index d7984937..650efab6 100644 --- a/desktop/Makefile +++ b/desktop/Makefile @@ -26,8 +26,8 @@ $(GOBIN)/rice: # Embed the current version numbers in the executable by writing version.go .PHONY: version.go version.go: - @echo "// DO NOT EDIT: Autogenerated by Makefile\n" > version.go - @echo "package main\n" >> version.go + @echo -e "// DO NOT EDIT: Autogenerated by Makefile\n" > version.go + @echo -e "package main\n" >> version.go @echo "const DesktopVersion = \"$(DESKTOP_VERSION)\"" >> version.go @echo "const EditorVersion = \"$(EDITOR_VERSION)\"" >> version.go From e52935c7f3bc996b339862f92f557ca80ca3ff07 Mon Sep 17 00:00:00 2001 From: Filip Czaplicki Date: Fri, 6 Sep 2024 18:38:55 +0200 Subject: [PATCH 2/2] Use printf instead of echo Using is not portable: https://unix.stackexchange.com/questions/700675/why-is-echo-e-behaving-weird-in-a-makefile --- desktop/Makefile | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/desktop/Makefile b/desktop/Makefile index 650efab6..bba1a274 100644 --- a/desktop/Makefile +++ b/desktop/Makefile @@ -1,8 +1,7 @@ SOURCEDIR=. SOURCES := $(shell find $(SOURCEDIR) -name '*.go') BINARY=maputnik -DESKTOP_VERSION := 1.1.1 -EDITOR_VERSION := $(shell node -p "require('../package.json').version") +VERSION := $(shell node -p "require('../package.json').version") GOPATH := $(if $(GOPATH),$(GOPATH),$(HOME)/go) GOBIN := $(if $(GOBIN),$(GOBIN),$(HOME)/go/bin) @@ -26,10 +25,9 @@ $(GOBIN)/rice: # Embed the current version numbers in the executable by writing version.go .PHONY: version.go version.go: - @echo -e "// DO NOT EDIT: Autogenerated by Makefile\n" > version.go - @echo -e "package main\n" >> version.go - @echo "const DesktopVersion = \"$(DESKTOP_VERSION)\"" >> version.go - @echo "const EditorVersion = \"$(EDITOR_VERSION)\"" >> version.go + @printf "// DO NOT EDIT: Autogenerated by Makefile\n" > version.go + @printf "package main\n" >> version.go + @printf "const Version = \"$(VERSION)\"\n" >> version.go rice-box.go: $(GOBIN)/rice editor/pull_release $(GOBIN)/rice embed-go