build: better error messages

This commit is contained in:
xushiwei
2024-04-29 01:34:21 +08:00
parent 769b93a277
commit 286b520d83
2 changed files with 41 additions and 16 deletions

View File

@@ -17,6 +17,7 @@
package clang
import (
"io"
"os"
"os/exec"
)
@@ -26,6 +27,9 @@ import (
// Cmd represents a nm command.
type Cmd struct {
app string
Stdout io.Writer
Stderr io.Writer
}
// New creates a new nm command.
@@ -33,13 +37,13 @@ func New(app string) *Cmd {
if app == "" {
app = "clang"
}
return &Cmd{app}
return &Cmd{app, os.Stdout, os.Stderr}
}
func (p *Cmd) Exec(args ...string) error {
cmd := exec.Command(p.app, args...)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.Stdout = p.Stdout
cmd.Stderr = p.Stderr
return cmd.Run()
}