mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-16 10:43:29 +00:00
builder: add support for -x flag
Print commands as they are executed with the -x flag. This is not yet complete: library builds don't print commands yet. But it's a step closer.
This commit is contained in:
committed by
Ron Evans
parent
fb03787b73
commit
896a848001
@@ -476,6 +476,9 @@ func Build(pkgName, outpath string, config *compileopts.Config, action func(Buil
|
|||||||
}
|
}
|
||||||
ldflags = append(ldflags, dependency.result)
|
ldflags = append(ldflags, dependency.result)
|
||||||
}
|
}
|
||||||
|
if config.Options.PrintCommands {
|
||||||
|
fmt.Printf("%s %s\n", config.Target.Linker, strings.Join(ldflags, " "))
|
||||||
|
}
|
||||||
err = link(config.Target.Linker, ldflags...)
|
err = link(config.Target.Linker, ldflags...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return &commandError{"failed to link", executable, err}
|
return &commandError{"failed to link", executable, err}
|
||||||
|
|||||||
@@ -124,6 +124,9 @@ func compileAndCacheCFile(abspath, tmpdir string, config *compileopts.Config) (s
|
|||||||
flags := config.CFlags()
|
flags := config.CFlags()
|
||||||
flags = append(flags, "-MD", "-MV", "-MTdeps", "-MF", depTmpFile.Name()) // autogenerate dependencies
|
flags = append(flags, "-MD", "-MV", "-MTdeps", "-MF", depTmpFile.Name()) // autogenerate dependencies
|
||||||
flags = append(flags, "-c", "-o", objTmpFile.Name(), abspath)
|
flags = append(flags, "-c", "-o", objTmpFile.Name(), abspath)
|
||||||
|
if config.Options.PrintCommands {
|
||||||
|
fmt.Printf("%s %s\n", config.Target.Compiler, strings.Join(flags, " "))
|
||||||
|
}
|
||||||
err = runCCompiler(config.Target.Compiler, flags...)
|
err = runCCompiler(config.Target.Compiler, flags...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", &commandError{"failed to build", abspath, err}
|
return "", &commandError{"failed to build", abspath, err}
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ func copyFile(src, dst string) error {
|
|||||||
// executeCommand is a simple wrapper to exec.Cmd
|
// executeCommand is a simple wrapper to exec.Cmd
|
||||||
func executeCommand(options *compileopts.Options, name string, arg ...string) *exec.Cmd {
|
func executeCommand(options *compileopts.Options, name string, arg ...string) *exec.Cmd {
|
||||||
if options.PrintCommands {
|
if options.PrintCommands {
|
||||||
fmt.Printf("%s %s\n ", name, strings.Join(arg, " "))
|
fmt.Printf("%s %s\n", name, strings.Join(arg, " "))
|
||||||
}
|
}
|
||||||
return exec.Command(name, arg...)
|
return exec.Command(name, arg...)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user