Этот коммит содержится в:
Ayke van Laethem 2020-09-17 19:27:27 +02:00 коммит произвёл Ron Evans
родитель b713001313
коммит c10dcd429c

22
main.go
Просмотреть файл

@ -781,7 +781,6 @@ func main() {
} }
command := os.Args[1] command := os.Args[1]
outpath := flag.String("o", "", "output filename")
opt := flag.String("opt", "z", "optimization level: 0, 1, 2, s, z") opt := flag.String("opt", "z", "optimization level: 0, 1, 2, s, z")
gc := flag.String("gc", "", "garbage collector to use (none, leaking, extalloc, conservative)") gc := flag.String("gc", "", "garbage collector to use (none, leaking, extalloc, conservative)")
panicStrategy := flag.String("panic", "print", "panic strategy (print, trap)") panicStrategy := flag.String("panic", "print", "panic strategy (print, trap)")
@ -803,10 +802,14 @@ func main() {
heapSize := flag.String("heap-size", "1M", "default heap size in bytes (only supported by WebAssembly)") heapSize := flag.String("heap-size", "1M", "default heap size in bytes (only supported by WebAssembly)")
var flagJSON, flagDeps *bool var flagJSON, flagDeps *bool
if command == "list" { if command == "help" || command == "list" {
flagJSON = flag.Bool("json", false, "print data in JSON format") flagJSON = flag.Bool("json", false, "print data in JSON format")
flagDeps = flag.Bool("deps", false, "") flagDeps = flag.Bool("deps", false, "")
} }
var outpath string
if command == "help" || command == "build" || command == "build-library" {
flag.StringVar(&outpath, "o", "", "output filename")
}
// Early command processing, before commands are interpreted by the Go flag // Early command processing, before commands are interpreted by the Go flag
// library. // library.
@ -864,7 +867,7 @@ func main() {
switch command { switch command {
case "build": case "build":
if *outpath == "" { if outpath == "" {
fmt.Fprintln(os.Stderr, "No output filename supplied (-o).") fmt.Fprintln(os.Stderr, "No output filename supplied (-o).")
usage() usage()
os.Exit(1) os.Exit(1)
@ -877,15 +880,15 @@ func main() {
usage() usage()
os.Exit(1) os.Exit(1)
} }
if options.Target == "" && filepath.Ext(*outpath) == ".wasm" { if options.Target == "" && filepath.Ext(outpath) == ".wasm" {
options.Target = "wasm" options.Target = "wasm"
} }
err := Build(pkgName, *outpath, options) err := Build(pkgName, outpath, options)
handleCompilerError(err) handleCompilerError(err)
case "build-library": case "build-library":
// Note: this command is only meant to be used while making a release! // Note: this command is only meant to be used while making a release!
if *outpath == "" { if outpath == "" {
fmt.Fprintln(os.Stderr, "No output filename supplied (-o).") fmt.Fprintln(os.Stderr, "No output filename supplied (-o).")
usage() usage()
os.Exit(1) os.Exit(1)
@ -910,13 +913,8 @@ func main() {
} }
path, err := lib.Load(*target) path, err := lib.Load(*target)
handleCompilerError(err) handleCompilerError(err)
copyFile(path, *outpath) copyFile(path, outpath)
case "flash", "gdb": case "flash", "gdb":
if *outpath != "" {
fmt.Fprintln(os.Stderr, "Output cannot be specified with the flash command.")
usage()
os.Exit(1)
}
pkgName := filepath.ToSlash(flag.Arg(0)) pkgName := filepath.ToSlash(flag.Arg(0))
if command == "flash" { if command == "flash" {
err := Flash(pkgName, *port, options) err := Flash(pkgName, *port, options)