From ab2a81cc5202e6fe130badf4ee4806614b21cba3 Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Thu, 21 May 2020 00:34:01 +0200 Subject: [PATCH] main: move TinyGo version to goenv This is needed to make it available to more packages, for caching purposes. For caching, the version itself may not be enough during development. But for regular releases, the version provides some protection against accidentally using a cache entry that is invalid in a newer version. --- Makefile | 2 +- goenv/version.go | 4 ++++ main.go | 4 ++-- version.go | 5 ----- 4 files changed, 7 insertions(+), 8 deletions(-) delete mode 100644 version.go diff --git a/Makefile b/Makefile index 02ca2605..02d6a099 100644 --- a/Makefile +++ b/Makefile @@ -359,4 +359,4 @@ deb: build/release @mkdir -p build/release-deb/usr/local/lib cp -ar build/release/tinygo build/release-deb/usr/local/lib/tinygo ln -sf ../lib/tinygo/bin/tinygo build/release-deb/usr/local/bin/tinygo - fpm -f -s dir -t deb -n tinygo -v $(shell grep "version = " version.go | awk '{print $$NF}') -m '@tinygo-org' --description='TinyGo is a Go compiler for small places.' --license='BSD 3-Clause' --url=https://tinygo.org/ --deb-changelog CHANGELOG.md -p build/release.deb -C ./build/release-deb + fpm -f -s dir -t deb -n tinygo -v $(shell grep "const Version = " goenv/version.go | awk '{print $$NF}') -m '@tinygo-org' --description='TinyGo is a Go compiler for small places.' --license='BSD 3-Clause' --url=https://tinygo.org/ --deb-changelog CHANGELOG.md -p build/release.deb -C ./build/release-deb diff --git a/goenv/version.go b/goenv/version.go index 7c0d10f6..51144705 100644 --- a/goenv/version.go +++ b/goenv/version.go @@ -10,6 +10,10 @@ import ( "strings" ) +// Version of TinyGo. +// Update this value before release of new version of software. +const Version = "0.14.0-dev" + // GetGorootVersion returns the major and minor version for a given GOROOT path. // If the goroot cannot be determined, (0, 0) is returned. func GetGorootVersion(goroot string) (major, minor int, err error) { diff --git a/main.go b/main.go index 27836d1a..9fe0b240 100644 --- a/main.go +++ b/main.go @@ -632,7 +632,7 @@ func getDefaultPort() (port string, err error) { func usage() { fmt.Fprintln(os.Stderr, "TinyGo is a Go compiler for small places.") - fmt.Fprintln(os.Stderr, "version:", version) + fmt.Fprintln(os.Stderr, "version:", goenv.Version) fmt.Fprintf(os.Stderr, "usage: %s command [-printir] [-target=] -o \n", os.Args[0]) fmt.Fprintln(os.Stderr, "\ncommands:") fmt.Fprintln(os.Stderr, " build: compile packages and dependencies") @@ -900,7 +900,7 @@ func main() { if s, err := goenv.GorootVersionString(goenv.Get("GOROOT")); err == nil { goversion = s } - fmt.Printf("tinygo version %s %s/%s (using go version %s and LLVM version %s)\n", version, runtime.GOOS, runtime.GOARCH, goversion, llvm.Version) + fmt.Printf("tinygo version %s %s/%s (using go version %s and LLVM version %s)\n", goenv.Version, runtime.GOOS, runtime.GOARCH, goversion, llvm.Version) case "env": if flag.NArg() == 0 { // Show all environment variables. diff --git a/version.go b/version.go deleted file mode 100644 index 0d35efa1..00000000 --- a/version.go +++ /dev/null @@ -1,5 +0,0 @@ -package main - -// version of this package. -// Update this value before release of new version of software. -const version = "0.14.0-dev"