@@ -868,7 +868,7 @@ OverlayLoop:
868
868
// Compile Go.
869
869
objpkg := objdir + "_pkg_.a"
870
870
ofile , out , err := BuildToolchain .gc (b , a , objpkg , icfg .Bytes (), embedcfg , symabis , len (sfiles ) > 0 , gofiles )
871
- if err := b .reportCmd (a , nil , "" , "" , out , err ); err != nil {
871
+ if err := b .reportCmd (a , "" , "" , out , err ); err != nil {
872
872
return err
873
873
}
874
874
if ofile != objpkg {
@@ -996,7 +996,7 @@ func (b *Builder) checkDirectives(a *Action) error {
996
996
// path, but the content of the error doesn't matter because msg is
997
997
// non-empty.
998
998
err := errors .New ("invalid directive" )
999
- return b .reportCmd (a , nil , "" , "" , msg .Bytes (), err )
999
+ return b .reportCmd (a , "" , "" , msg .Bytes (), err )
1000
1000
}
1001
1001
return nil
1002
1002
}
@@ -1637,7 +1637,7 @@ func (b *Builder) getPkgConfigFlags(a *Action) (cflags, ldflags []string, err er
1637
1637
out , err = b .runOut (nil , p .Dir , nil , b .PkgconfigCmd (), "--cflags" , pcflags , "--" , pkgs )
1638
1638
if err != nil {
1639
1639
desc := b .PkgconfigCmd () + " --cflags " + strings .Join (pcflags , " " ) + " -- " + strings .Join (pkgs , " " )
1640
- return nil , nil , b .reportCmd (a , nil , desc , "" , out , err )
1640
+ return nil , nil , b .reportCmd (a , desc , "" , out , err )
1641
1641
}
1642
1642
if len (out ) > 0 {
1643
1643
cflags , err = splitPkgConfigOutput (bytes .TrimSpace (out ))
@@ -1651,7 +1651,7 @@ func (b *Builder) getPkgConfigFlags(a *Action) (cflags, ldflags []string, err er
1651
1651
out , err = b .runOut (nil , p .Dir , nil , b .PkgconfigCmd (), "--libs" , pcflags , "--" , pkgs )
1652
1652
if err != nil {
1653
1653
desc := b .PkgconfigCmd () + " --libs " + strings .Join (pcflags , " " ) + " -- " + strings .Join (pkgs , " " )
1654
- return nil , nil , b .reportCmd (a , nil , desc , "" , out , err )
1654
+ return nil , nil , b .reportCmd (a , desc , "" , out , err )
1655
1655
}
1656
1656
if len (out ) > 0 {
1657
1657
// We need to handle path with spaces so that C:/Program\ Files can pass
@@ -2241,16 +2241,10 @@ func (b *Builder) Showcmd(dir string, format string, args ...any) {
2241
2241
// cgo file paths with the original file path, and replaces cgo-mangled names
2242
2242
// with "C.name".
2243
2243
//
2244
- // p is optional. If nil , a.Package is used.
2244
+ // desc is optional. If "" , a.Package.Desc() is used.
2245
2245
//
2246
- // desc is optional. If "", p.Desc() is used.
2247
- //
2248
- // dir is optional. If "", p.Dir is used.
2249
- func (b * Builder ) reportCmd (a * Action , p * load.Package , desc , dir string , cmdOut []byte , cmdErr error ) error {
2250
- // TODO: It seems we can always get p from a.Package, so it should be
2251
- // possible to drop the "p" argument. However, a lot of callers take both
2252
- // Action and Package, so we'd want to drop the Package argument from those,
2253
- // too.
2246
+ // dir is optional. If "", a.Package.Dir is used.
2247
+ func (b * Builder ) reportCmd (a * Action , desc , dir string , cmdOut []byte , cmdErr error ) error {
2254
2248
if len (cmdOut ) == 0 && cmdErr == nil {
2255
2249
// Common case
2256
2250
return nil
@@ -2267,7 +2261,8 @@ func (b *Builder) reportCmd(a *Action, p *load.Package, desc, dir string, cmdOut
2267
2261
}
2268
2262
2269
2263
// Fetch defaults from the package.
2270
- if a != nil && p == nil {
2264
+ var p * load.Package
2265
+ if a != nil {
2271
2266
p = a .Package
2272
2267
}
2273
2268
var importPath string
@@ -2397,7 +2392,7 @@ func (b *Builder) run(a *Action, dir string, desc string, env []string, cmdargs
2397
2392
if desc == "" {
2398
2393
desc = b .fmtcmd (dir , "%s" , strings .Join (str .StringList (cmdargs ... ), " " ))
2399
2394
}
2400
- return b .reportCmd (a , nil , desc , dir , out , err )
2395
+ return b .reportCmd (a , desc , dir , out , err )
2401
2396
}
2402
2397
2403
2398
// runOut runs the command given by cmdline in the directory dir.
@@ -2759,7 +2754,7 @@ func (b *Builder) ccompile(a *Action, outfile string, flags []string, file strin
2759
2754
err = errors .New ("warning promoted to error" )
2760
2755
}
2761
2756
2762
- return b .reportCmd (a , nil , "" , "" , output , err )
2757
+ return b .reportCmd (a , "" , "" , output , err )
2763
2758
}
2764
2759
2765
2760
// gccld runs the gcc linker to create an executable from a set of object files.
@@ -2813,7 +2808,7 @@ func (b *Builder) gccld(a *Action, objdir, outfile string, flags []string, objs
2813
2808
// Note that failure is an expected outcome here, so we report output only
2814
2809
// in debug mode and don't report the error.
2815
2810
if cfg .BuildN || cfg .BuildX {
2816
- b .reportCmd (a , nil , "" , "" , out , nil )
2811
+ b .reportCmd (a , "" , "" , out , nil )
2817
2812
}
2818
2813
return err
2819
2814
}
@@ -3848,7 +3843,7 @@ func (b *Builder) swigOne(a *Action, file, objdir string, pcCFLAGS []string, cxx
3848
3843
if err != nil && (bytes .Contains (out , []byte ("-intgosize" )) || bytes .Contains (out , []byte ("-cgo" ))) {
3849
3844
return "" , "" , errors .New ("must have SWIG version >= 3.0.6" )
3850
3845
}
3851
- if err := b .reportCmd (a , nil , "" , "" , out , err ); err != nil {
3846
+ if err := b .reportCmd (a , "" , "" , out , err ); err != nil {
3852
3847
return "" , "" , err
3853
3848
}
3854
3849
0 commit comments