From d31deda1b509a96a43e4b8ea433fba8e65ef789d Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Tue, 5 Nov 2019 13:00:19 +0100 Subject: [PATCH] main: add 'info' subcommand It lists some information about the device that is useful for tools, in a way that can be parsed easily. --- main.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/main.go b/main.go index f2de471a..b448f6fd 100644 --- a/main.go +++ b/main.go @@ -822,6 +822,33 @@ func main() { } err := Test(pkgName, *target, options) handleCompilerError(err) + case "info": + target := *target + if flag.NArg() == 1 { + target = flag.Arg(0) + } else if flag.NArg() > 1 { + fmt.Fprintln(os.Stderr, "only one target name is accepted") + usage() + os.Exit(1) + } + spec, err := compileopts.LoadTarget(target) + config := &compileopts.Config{ + Options: options, + Target: spec, + GoMinorVersion: 0, // this avoids creating the list of Go1.x build tags. + ClangHeaders: getClangHeaderPath(goenv.Get("TINYGOROOT")), + TestConfig: options.TestConfig, + } + if err != nil { + fmt.Fprintln(os.Stderr, err) + os.Exit(1) + } + fmt.Printf("LLVM triple: %s\n", config.Triple()) + fmt.Printf("GOOS: %s\n", config.GOOS()) + fmt.Printf("GOARCH: %s\n", config.GOARCH()) + fmt.Printf("build tags: %s\n", strings.Join(config.BuildTags(), " ")) + fmt.Printf("garbage collector: %s\n", config.GC()) + fmt.Printf("scheduler: %s\n", config.Scheduler()) case "clean": // remove cache directory err := os.RemoveAll(goenv.Get("GOCACHE"))