diff options
Diffstat (limited to 'vendor/modernc.org/ccgo/v3/lib/util.go')
-rw-r--r-- | vendor/modernc.org/ccgo/v3/lib/util.go | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/vendor/modernc.org/ccgo/v3/lib/util.go b/vendor/modernc.org/ccgo/v3/lib/util.go index aeef2055f..f11e439ca 100644 --- a/vendor/modernc.org/ccgo/v3/lib/util.go +++ b/vendor/modernc.org/ccgo/v3/lib/util.go @@ -375,7 +375,7 @@ func Shell(cmd string, args ...string) ([]byte, error) { func MustShell(stackTrace bool, cmd string, args ...string) []byte { b, err := Shell(cmd, args...) if err != nil { - Fatalf(stackTrace, "%s\n%s", b, err) + Fatalf(stackTrace, "%v %s\noutput: %s\nerr: %s", cmd, args, b, err) } return b @@ -389,6 +389,26 @@ func MustCompile(stackTrace bool, args ...string) []byte { return MustShell(stackTrace, "ccgo", args...) } +// Run is like Compile, but executes in-process. +func Run(args ...string) ([]byte, error) { + var b bytes.Buffer + t := NewTask(append([]string{"ccgo"}, args...), &b, &b) + err := t.Main() + return b.Bytes(), err +} + +// MustRun is like Run but if executes Fatal(stackTrace, err) if it fails. +func MustRun(stackTrace bool, args ...string) []byte { + var b bytes.Buffer + args = append([]string{"ccgo"}, args...) + t := NewTask(args, &b, &b) + if err := t.Main(); err != nil { + Fatalf(stackTrace, "%v\noutput: %s\nerr: %s", args, b.Bytes(), err) + } + + return b.Bytes() +} + // AbsCwd returns the absolute working directory. func AbsCwd() (string, error) { wd, err := os.Getwd() |