// Compile Go.
objpkg := objdir + "_pkg_.a"
ofile, out, err := BuildToolchain.gc(b, a, objpkg, icfg.Bytes(), embedcfg, symabis, len(sfiles) > 0, gofiles)
- if err := b.reportCmd(a, nil, "", "", out, err); err != nil {
+ if err := b.reportCmd(a, "", "", out, err); err != nil {
return err
}
if ofile != objpkg {
// path, but the content of the error doesn't matter because msg is
// non-empty.
err := errors.New("invalid directive")
- return b.reportCmd(a, nil, "", "", msg.Bytes(), err)
+ return b.reportCmd(a, "", "", msg.Bytes(), err)
}
return nil
}
out, err = b.runOut(nil, p.Dir, nil, b.PkgconfigCmd(), "--cflags", pcflags, "--", pkgs)
if err != nil {
desc := b.PkgconfigCmd() + " --cflags " + strings.Join(pcflags, " ") + " -- " + strings.Join(pkgs, " ")
- return nil, nil, b.reportCmd(a, nil, desc, "", out, err)
+ return nil, nil, b.reportCmd(a, desc, "", out, err)
}
if len(out) > 0 {
cflags, err = splitPkgConfigOutput(bytes.TrimSpace(out))
out, err = b.runOut(nil, p.Dir, nil, b.PkgconfigCmd(), "--libs", pcflags, "--", pkgs)
if err != nil {
desc := b.PkgconfigCmd() + " --libs " + strings.Join(pcflags, " ") + " -- " + strings.Join(pkgs, " ")
- return nil, nil, b.reportCmd(a, nil, desc, "", out, err)
+ return nil, nil, b.reportCmd(a, desc, "", out, err)
}
if len(out) > 0 {
// We need to handle path with spaces so that C:/Program\ Files can pass
// cgo file paths with the original file path, and replaces cgo-mangled names
// with "C.name".
//
-// p is optional. If nil, a.Package is used.
+// desc is optional. If "", a.Package.Desc() is used.
//
-// desc is optional. If "", p.Desc() is used.
-//
-// dir is optional. If "", p.Dir is used.
-func (b *Builder) reportCmd(a *Action, p *load.Package, desc, dir string, cmdOut []byte, cmdErr error) error {
- // TODO: It seems we can always get p from a.Package, so it should be
- // possible to drop the "p" argument. However, a lot of callers take both
- // Action and Package, so we'd want to drop the Package argument from those,
- // too.
+// dir is optional. If "", a.Package.Dir is used.
+func (b *Builder) reportCmd(a *Action, desc, dir string, cmdOut []byte, cmdErr error) error {
if len(cmdOut) == 0 && cmdErr == nil {
// Common case
return nil
}
// Fetch defaults from the package.
- if a != nil && p == nil {
+ var p *load.Package
+ if a != nil {
p = a.Package
}
var importPath string
if desc == "" {
desc = b.fmtcmd(dir, "%s", strings.Join(str.StringList(cmdargs...), " "))
}
- return b.reportCmd(a, nil, desc, dir, out, err)
+ return b.reportCmd(a, desc, dir, out, err)
}
// runOut runs the command given by cmdline in the directory dir.
err = errors.New("warning promoted to error")
}
- return b.reportCmd(a, nil, "", "", output, err)
+ return b.reportCmd(a, "", "", output, err)
}
// gccld runs the gcc linker to create an executable from a set of object files.
// Note that failure is an expected outcome here, so we report output only
// in debug mode and don't report the error.
if cfg.BuildN || cfg.BuildX {
- b.reportCmd(a, nil, "", "", out, nil)
+ b.reportCmd(a, "", "", out, nil)
}
return err
}
if err != nil && (bytes.Contains(out, []byte("-intgosize")) || bytes.Contains(out, []byte("-cgo"))) {
return "", "", errors.New("must have SWIG version >= 3.0.6")
}
- if err := b.reportCmd(a, nil, "", "", out, err); err != nil {
+ if err := b.reportCmd(a, "", "", out, err); err != nil {
return "", "", err
}