From 36fc7d4b6f9944e42574ffaa62d6d5af5d920544 Mon Sep 17 00:00:00 2001 From: Roger Standridge <9526806+archie2x@users.noreply.github.com> Date: Wed, 7 Aug 2024 05:10:22 -0700 Subject: [PATCH 1/2] duplicate big-go version tags functionality --- builder/config.go | 4 ++++ compileopts/config.go | 14 ++++++++++++++ goenv/version.go | 14 ++++++++++---- main.go | 11 ++++++++++- 4 files changed, 38 insertions(+), 5 deletions(-) diff --git a/builder/config.go b/builder/config.go index a82450a638..e7d878265f 100644 --- a/builder/config.go +++ b/builder/config.go @@ -38,5 +38,9 @@ func NewConfig(options *compileopts.Options) (*compileopts.Config, error) { Target: spec, GoMinorVersion: minor, TestConfig: options.TestConfig, + + // tinygo version + VersionMajor: goenv.VersionMajor, + VersionMinor: goenv.VersionMinor, }, nil } diff --git a/compileopts/config.go b/compileopts/config.go index a5ab7cd8f9..504b7d1ac0 100644 --- a/compileopts/config.go +++ b/compileopts/config.go @@ -20,6 +20,10 @@ type Config struct { Target *TargetSpec GoMinorVersion int TestConfig TestConfig + + // tinygo versions + VersionMajor int + VersionMinor int } // Triple returns the LLVM target triple, like armv6m-unknown-unknown-eabi. @@ -81,9 +85,19 @@ func (c *Config) BuildTags() []string { "math_big_pure_go", // to get math/big to work "gc." + c.GC(), "scheduler." + c.Scheduler(), // used inside the runtime package "serial." + c.Serial()}...) // used inside the machine package + + // Go Version tags for i := 1; i <= c.GoMinorVersion; i++ { tags = append(tags, fmt.Sprintf("go1.%d", i)) } + + // tinygo Version tags + for i := 0; i <= c.VersionMajor; i++ { + for j := 1; j <= c.VersionMinor; j++ { + tags = append(tags, fmt.Sprintf("tinygo%d.%d", i, j)) + } + } + tags = append(tags, c.Options.Tags...) return tags } diff --git a/goenv/version.go b/goenv/version.go index bed4e26f34..fdc05d4d5d 100644 --- a/goenv/version.go +++ b/goenv/version.go @@ -8,8 +8,11 @@ import ( ) // Version of TinyGo. -// Update this value before release of new version of software. -const version = "0.33.0-dev" +// Update these value before release of new version of software. +const VersionMajor = 0 +const VersionMinor = 33 +const VersionPatch = 0 +const VersionDev = "-dev" // "" for release var ( // This variable is set at build time using -ldflags parameters. @@ -20,10 +23,13 @@ var ( // Return TinyGo version, either in the form 0.30.0 or as a development version // (like 0.30.0-dev-abcd012). func Version() string { - v := version - if strings.HasSuffix(version, "-dev") && GitSha1 != "" { + + v := fmt.Sprintf("%v.%v.%v%v", VersionMajor, VersionMinor, VersionPatch, VersionDev) + + if strings.HasSuffix(v, "-dev") && GitSha1 != "" { v += "-" + GitSha1 } + return v } diff --git a/main.go b/main.go index c90bf7e69a..95b40a3cef 100644 --- a/main.go +++ b/main.go @@ -1428,7 +1428,7 @@ func main() { // development it can be useful to not emit debug information at all. skipDwarf := flag.Bool("internal-nodwarf", false, "internal flag, use -no-debug instead") - var flagJSON, flagDeps, flagTest bool + var flagJSON, flagDeps, flagTest, flagFull bool if command == "help" || command == "list" || command == "info" || command == "build" { flag.BoolVar(&flagJSON, "json", false, "print data in JSON format") } @@ -1440,6 +1440,9 @@ func main() { if command == "help" || command == "build" || command == "test" { flag.StringVar(&outpath, "o", "", "output filename") } + if command == "info" { + flag.BoolVar(&flagFull, "full", false, "output all tinygo version build-tags") + } var witPackage, witWorld string if command == "help" || command == "build" || command == "test" || command == "run" { @@ -1720,6 +1723,12 @@ func main() { os.Exit(1) } config.GoMinorVersion = 0 // this avoids creating the list of Go1.x build tags. + if !flagFull { + // avoid creating tinygoX.X build tags + config.VersionMinor = 0 + config.VersionMajor = 0 + } + if err != nil { fmt.Fprintln(os.Stderr, err) os.Exit(1) From e40c3530e5e1be59cd0d5c0971a73bf8de323c1b Mon Sep 17 00:00:00 2001 From: Roger Standridge <9526806+archie2x@users.noreply.github.com> Date: Thu, 8 Aug 2024 11:07:04 -0700 Subject: [PATCH 2/2] refactor / fix deb pkg build --- builder/config.go | 9 +++++---- goenv/version.go | 21 +++++++++++---------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/builder/config.go b/builder/config.go index e7d878265f..5cb0bad86f 100644 --- a/builder/config.go +++ b/builder/config.go @@ -33,14 +33,15 @@ func NewConfig(options *compileopts.Options) (*compileopts.Config, error) { return nil, fmt.Errorf("requires go version 1.19 through 1.22, got go%d.%d", major, minor) } + // tinygo major / minor version + tgMajor, tgMinor := goenv.GetVersion() + return &compileopts.Config{ Options: options, Target: spec, GoMinorVersion: minor, TestConfig: options.TestConfig, - - // tinygo version - VersionMajor: goenv.VersionMajor, - VersionMinor: goenv.VersionMinor, + VersionMajor: tgMajor, + VersionMinor: tgMinor, }, nil } diff --git a/goenv/version.go b/goenv/version.go index fdc05d4d5d..b54c146256 100644 --- a/goenv/version.go +++ b/goenv/version.go @@ -8,11 +8,8 @@ import ( ) // Version of TinyGo. -// Update these value before release of new version of software. -const VersionMajor = 0 -const VersionMinor = 33 -const VersionPatch = 0 -const VersionDev = "-dev" // "" for release +// Update this value before release of new version of software. +const version = "0.33.0-dev" var ( // This variable is set at build time using -ldflags parameters. @@ -23,16 +20,20 @@ var ( // Return TinyGo version, either in the form 0.30.0 or as a development version // (like 0.30.0-dev-abcd012). func Version() string { - - v := fmt.Sprintf("%v.%v.%v%v", VersionMajor, VersionMinor, VersionPatch, VersionDev) - - if strings.HasSuffix(v, "-dev") && GitSha1 != "" { + v := version + if strings.HasSuffix(version, "-dev") && GitSha1 != "" { v += "-" + GitSha1 } - return v } +// Return version as major / minor +func GetVersion() (major, minor int) { + // version must be + fmt.Sscanf(version, "%d.%d", &major, &minor) + return +} + // GetGorootVersion returns the major and minor version for a given GOROOT path. // If the goroot cannot be determined, (0, 0) is returned. func GetGorootVersion() (major, minor int, err error) {