}
// runLog runs a process and returns the combined stdout/stderr,
-// as well as writing it to logfile (if specified).
-func runLog(envv []string, logfile, dir string, argv ...string) (output string, exitStatus int, err os.Error) {
+// as well as writing it to logfile (if specified). It returns
+// process combined stdout and stderr output, exit status and error.
+// The error returned is nil, if process is started successfully,
+// even if exit status is not 0.
+func runLog(envv []string, logfile, dir string, argv ...string) (string, int, os.Error) {
if *verbose {
log.Println("runLog", argv)
}
if logfile != "" {
f, err := os.OpenFile(logfile, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0666)
if err != nil {
- return
+ return "", 0, err
}
defer f.Close()
w = io.MultiWriter(f, b)
cmd.Stdout = w
cmd.Stderr = w
- err = cmd.Run()
- output = b.String()
+ err := cmd.Run()
if err != nil {
if ws, ok := err.(*os.Waitmsg); ok {
- exitStatus = ws.ExitStatus()
+ return b.String(), ws.ExitStatus(), nil
}
- return
}
- return
+ return b.String(), 0, nil
}
// useBash prefixes a list of args with 'bash' if the first argument
logfile := path.Join(workpath, "build.log")
buildLog, status, err := runLog(b.envv(), logfile, srcDir, *buildCmd)
if err != nil {
- return fmt.Errorf("all.bash: %s", err)
+ return fmt.Errorf("%s: %s", *buildCmd, err)
}
// if we're in external mode, build all packages and return