aboutsummaryrefslogtreecommitdiffhomepage
path: root/main.go
diff options
context:
space:
mode:
authorZauberNerd <[email protected]>2022-03-14 21:22:12 +0000
committerAyke <[email protected]>2022-03-19 15:36:44 +0100
commitd066b5c2323af9667a57897e0bf2e0778abf3e9e (patch)
tree4c40253dc3832697041167eab5d97fa24a2d49de /main.go
parent836ab95192348999271bef4b532fc062a8039361 (diff)
downloadtinygo-d066b5c2323af9667a57897e0bf2e0778abf3e9e.tar.gz
tinygo-d066b5c2323af9667a57897e0bf2e0778abf3e9e.zip
Move gitSha1 build time variable from main to goenv package
Moving and exporting this variable from the main to the goenv package allows us to use it from both the main and the builder package. This is done in preparation to include the value in `tinygo build` linker flags, so that we can embed the version and git sha into binaries built with tinygo.
Diffstat (limited to 'main.go')
-rw-r--r--main.go14
1 files changed, 4 insertions, 10 deletions
diff --git a/main.go b/main.go
index dde4c7613..4d0ed0434 100644
--- a/main.go
+++ b/main.go
@@ -36,12 +36,6 @@ import (
"go.bug.st/serial/enumerator"
)
-var (
- // This variable is set at build time using -ldflags parameters.
- // See: https://stackoverflow.com/a/11355611
- gitSha1 string
-)
-
// commandError is an error type to wrap os/exec.Command errors. This provides
// some more information regarding what went wrong while running a command.
type commandError struct {
@@ -1023,8 +1017,8 @@ func getBMPPorts() (gdbPort, uartPort string, err error) {
func usage(command string) {
version := goenv.Version
- if strings.HasSuffix(version, "-dev") && gitSha1 != "" {
- version += "-" + gitSha1
+ if strings.HasSuffix(version, "-dev") && goenv.GitSha1 != "" {
+ version += "-" + goenv.GitSha1
}
switch command {
@@ -1620,8 +1614,8 @@ func main() {
goversion = s
}
version := goenv.Version
- if strings.HasSuffix(goenv.Version, "-dev") && gitSha1 != "" {
- version += "-" + gitSha1
+ if strings.HasSuffix(goenv.Version, "-dev") && goenv.GitSha1 != "" {
+ version += "-" + goenv.GitSha1
}
fmt.Printf("tinygo version %s %s/%s (using go version %s and LLVM version %s)\n", version, runtime.GOOS, runtime.GOARCH, goversion, llvm.Version)
case "env":