Commit 2767c4e2 authored by Daniel Martí's avatar Daniel Martí

cmd/go: remove some unused parameters

Change-Id: I441b3045e76afc1c561914926c14efc8a116c8a7
Reviewed-on: https://go-review.googlesource.com/101195
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent b30bf958
...@@ -220,7 +220,7 @@ func TestRespectSetgidDir(t *testing.T) { ...@@ -220,7 +220,7 @@ func TestRespectSetgidDir(t *testing.T) {
defer pkgfile.Close() defer pkgfile.Close()
dirGIDFile := filepath.Join(setgiddir, "setgid") dirGIDFile := filepath.Join(setgiddir, "setgid")
if err := b.moveOrCopyFile(nil, dirGIDFile, pkgfile.Name(), 0666, true); err != nil { if err := b.moveOrCopyFile(dirGIDFile, pkgfile.Name(), 0666, true); err != nil {
t.Fatalf("moveOrCopyFile: %v", err) t.Fatalf("moveOrCopyFile: %v", err)
} }
......
...@@ -432,7 +432,7 @@ func (b *Builder) build(a *Action) (err error) { ...@@ -432,7 +432,7 @@ func (b *Builder) build(a *Action) (err error) {
// Not covering this file. // Not covering this file.
continue continue
} }
if err := b.cover(a, coverFile, sourceFile, 0666, cover.Var); err != nil { if err := b.cover(a, coverFile, sourceFile, cover.Var); err != nil {
return err return err
} }
if i < len(gofiles) { if i < len(gofiles) {
...@@ -596,17 +596,17 @@ func (b *Builder) build(a *Action) (err error) { ...@@ -596,17 +596,17 @@ func (b *Builder) build(a *Action) (err error) {
switch { switch {
case strings.HasSuffix(name, _goos_goarch): case strings.HasSuffix(name, _goos_goarch):
targ := file[:len(name)-len(_goos_goarch)] + "_GOOS_GOARCH." + ext targ := file[:len(name)-len(_goos_goarch)] + "_GOOS_GOARCH." + ext
if err := b.copyFile(a, objdir+targ, filepath.Join(a.Package.Dir, file), 0666, true); err != nil { if err := b.copyFile(objdir+targ, filepath.Join(a.Package.Dir, file), 0666, true); err != nil {
return err return err
} }
case strings.HasSuffix(name, _goarch): case strings.HasSuffix(name, _goarch):
targ := file[:len(name)-len(_goarch)] + "_GOARCH." + ext targ := file[:len(name)-len(_goarch)] + "_GOARCH." + ext
if err := b.copyFile(a, objdir+targ, filepath.Join(a.Package.Dir, file), 0666, true); err != nil { if err := b.copyFile(objdir+targ, filepath.Join(a.Package.Dir, file), 0666, true); err != nil {
return err return err
} }
case strings.HasSuffix(name, _goos): case strings.HasSuffix(name, _goos):
targ := file[:len(name)-len(_goos)] + "_GOOS." + ext targ := file[:len(name)-len(_goos)] + "_GOOS." + ext
if err := b.copyFile(a, objdir+targ, filepath.Join(a.Package.Dir, file), 0666, true); err != nil { if err := b.copyFile(objdir+targ, filepath.Join(a.Package.Dir, file), 0666, true); err != nil {
return err return err
} }
} }
...@@ -954,7 +954,7 @@ func (b *Builder) getPkgConfigFlags(p *load.Package) (cflags, ldflags []string, ...@@ -954,7 +954,7 @@ func (b *Builder) getPkgConfigFlags(p *load.Package) (cflags, ldflags []string,
} }
} }
var out []byte var out []byte
out, err = b.runOut(p.Dir, p.ImportPath, nil, b.PkgconfigCmd(), "--cflags", pcflags, "--", pkgs) out, err = b.runOut(p.Dir, nil, b.PkgconfigCmd(), "--cflags", pcflags, "--", pkgs)
if err != nil { if err != nil {
b.showOutput(nil, p.Dir, b.PkgconfigCmd()+" --cflags "+strings.Join(pcflags, " ")+strings.Join(pkgs, " "), string(out)) b.showOutput(nil, p.Dir, b.PkgconfigCmd()+" --cflags "+strings.Join(pcflags, " ")+strings.Join(pkgs, " "), string(out))
b.Print(err.Error() + "\n") b.Print(err.Error() + "\n")
...@@ -966,7 +966,7 @@ func (b *Builder) getPkgConfigFlags(p *load.Package) (cflags, ldflags []string, ...@@ -966,7 +966,7 @@ func (b *Builder) getPkgConfigFlags(p *load.Package) (cflags, ldflags []string,
return nil, nil, err return nil, nil, err
} }
} }
out, err = b.runOut(p.Dir, p.ImportPath, nil, b.PkgconfigCmd(), "--libs", pcflags, "--", pkgs) out, err = b.runOut(p.Dir, nil, b.PkgconfigCmd(), "--libs", pcflags, "--", pkgs)
if err != nil { if err != nil {
b.showOutput(nil, p.Dir, b.PkgconfigCmd()+" --libs "+strings.Join(pcflags, " ")+strings.Join(pkgs, " "), string(out)) b.showOutput(nil, p.Dir, b.PkgconfigCmd()+" --libs "+strings.Join(pcflags, " ")+strings.Join(pkgs, " "), string(out))
b.Print(err.Error() + "\n") b.Print(err.Error() + "\n")
...@@ -1126,7 +1126,7 @@ func BuildInstallFunc(b *Builder, a *Action) (err error) { ...@@ -1126,7 +1126,7 @@ func BuildInstallFunc(b *Builder, a *Action) (err error) {
defer b.cleanup(a1) defer b.cleanup(a1)
return b.moveOrCopyFile(a, a.Target, a1.built, perm, false) return b.moveOrCopyFile(a.Target, a1.built, perm, false)
} }
// cleanup removes a's object dir to keep the amount of // cleanup removes a's object dir to keep the amount of
...@@ -1143,7 +1143,7 @@ func (b *Builder) cleanup(a *Action) { ...@@ -1143,7 +1143,7 @@ func (b *Builder) cleanup(a *Action) {
} }
// moveOrCopyFile is like 'mv src dst' or 'cp src dst'. // moveOrCopyFile is like 'mv src dst' or 'cp src dst'.
func (b *Builder) moveOrCopyFile(a *Action, dst, src string, perm os.FileMode, force bool) error { func (b *Builder) moveOrCopyFile(dst, src string, perm os.FileMode, force bool) error {
if cfg.BuildN { if cfg.BuildN {
b.Showcmd("", "mv %s %s", src, dst) b.Showcmd("", "mv %s %s", src, dst)
return nil return nil
...@@ -1154,7 +1154,7 @@ func (b *Builder) moveOrCopyFile(a *Action, dst, src string, perm os.FileMode, f ...@@ -1154,7 +1154,7 @@ func (b *Builder) moveOrCopyFile(a *Action, dst, src string, perm os.FileMode, f
// If the source is in the build cache, we need to copy it. // If the source is in the build cache, we need to copy it.
if strings.HasPrefix(src, cache.DefaultDir()) { if strings.HasPrefix(src, cache.DefaultDir()) {
return b.copyFile(a, dst, src, perm, force) return b.copyFile(dst, src, perm, force)
} }
// On Windows, always copy the file, so that we respect the NTFS // On Windows, always copy the file, so that we respect the NTFS
...@@ -1162,7 +1162,7 @@ func (b *Builder) moveOrCopyFile(a *Action, dst, src string, perm os.FileMode, f ...@@ -1162,7 +1162,7 @@ func (b *Builder) moveOrCopyFile(a *Action, dst, src string, perm os.FileMode, f
// What matters here is not cfg.Goos (the system we are building // What matters here is not cfg.Goos (the system we are building
// for) but runtime.GOOS (the system we are building on). // for) but runtime.GOOS (the system we are building on).
if runtime.GOOS == "windows" { if runtime.GOOS == "windows" {
return b.copyFile(a, dst, src, perm, force) return b.copyFile(dst, src, perm, force)
} }
// If the destination directory has the group sticky bit set, // If the destination directory has the group sticky bit set,
...@@ -1170,7 +1170,7 @@ func (b *Builder) moveOrCopyFile(a *Action, dst, src string, perm os.FileMode, f ...@@ -1170,7 +1170,7 @@ func (b *Builder) moveOrCopyFile(a *Action, dst, src string, perm os.FileMode, f
// https://golang.org/issue/18878 // https://golang.org/issue/18878
if fi, err := os.Stat(filepath.Dir(dst)); err == nil { if fi, err := os.Stat(filepath.Dir(dst)); err == nil {
if fi.IsDir() && (fi.Mode()&os.ModeSetgid) != 0 { if fi.IsDir() && (fi.Mode()&os.ModeSetgid) != 0 {
return b.copyFile(a, dst, src, perm, force) return b.copyFile(dst, src, perm, force)
} }
} }
...@@ -1200,11 +1200,11 @@ func (b *Builder) moveOrCopyFile(a *Action, dst, src string, perm os.FileMode, f ...@@ -1200,11 +1200,11 @@ func (b *Builder) moveOrCopyFile(a *Action, dst, src string, perm os.FileMode, f
} }
} }
return b.copyFile(a, dst, src, perm, force) return b.copyFile(dst, src, perm, force)
} }
// copyFile is like 'cp src dst'. // copyFile is like 'cp src dst'.
func (b *Builder) copyFile(a *Action, dst, src string, perm os.FileMode, force bool) error { func (b *Builder) copyFile(dst, src string, perm os.FileMode, force bool) error {
if cfg.BuildN || cfg.BuildX { if cfg.BuildN || cfg.BuildX {
b.Showcmd("", "cp %s %s", src, dst) b.Showcmd("", "cp %s %s", src, dst)
if cfg.BuildN { if cfg.BuildN {
...@@ -1295,12 +1295,12 @@ func (b *Builder) installHeader(a *Action) error { ...@@ -1295,12 +1295,12 @@ func (b *Builder) installHeader(a *Action) error {
} }
} }
return b.moveOrCopyFile(a, a.Target, src, 0666, true) return b.moveOrCopyFile(a.Target, src, 0666, true)
} }
// cover runs, in effect, // cover runs, in effect,
// go tool cover -mode=b.coverMode -var="varName" -o dst.go src.go // go tool cover -mode=b.coverMode -var="varName" -o dst.go src.go
func (b *Builder) cover(a *Action, dst, src string, perm os.FileMode, varName string) error { func (b *Builder) cover(a *Action, dst, src string, varName string) error {
return b.run(a, a.Objdir, "cover "+a.Package.ImportPath, nil, return b.run(a, a.Objdir, "cover "+a.Package.ImportPath, nil,
cfg.BuildToolexec, cfg.BuildToolexec,
base.Tool("cover"), base.Tool("cover"),
...@@ -1447,7 +1447,7 @@ var cgoTypeSigRe = regexp.MustCompile(`\b_C2?(type|func|var|macro)_\B`) ...@@ -1447,7 +1447,7 @@ var cgoTypeSigRe = regexp.MustCompile(`\b_C2?(type|func|var|macro)_\B`)
// If the command fails, run prints information about the failure // If the command fails, run prints information about the failure
// and returns a non-nil error. // and returns a non-nil error.
func (b *Builder) run(a *Action, dir string, desc string, env []string, cmdargs ...interface{}) error { func (b *Builder) run(a *Action, dir string, desc string, env []string, cmdargs ...interface{}) error {
out, err := b.runOut(dir, desc, env, cmdargs...) out, err := b.runOut(dir, env, cmdargs...)
if len(out) > 0 { if len(out) > 0 {
if desc == "" { if desc == "" {
desc = b.fmtcmd(dir, "%s", strings.Join(str.StringList(cmdargs...), " ")) desc = b.fmtcmd(dir, "%s", strings.Join(str.StringList(cmdargs...), " "))
...@@ -1479,7 +1479,7 @@ func (b *Builder) processOutput(out []byte) string { ...@@ -1479,7 +1479,7 @@ func (b *Builder) processOutput(out []byte) string {
// runOut runs the command given by cmdline in the directory dir. // runOut runs the command given by cmdline in the directory dir.
// It returns the command output and any errors that occurred. // It returns the command output and any errors that occurred.
func (b *Builder) runOut(dir string, desc string, env []string, cmdargs ...interface{}) ([]byte, error) { func (b *Builder) runOut(dir string, env []string, cmdargs ...interface{}) ([]byte, error) {
cmdline := str.StringList(cmdargs...) cmdline := str.StringList(cmdargs...)
for _, arg := range cmdline { for _, arg := range cmdline {
...@@ -1691,7 +1691,7 @@ func (b *Builder) ccompile(a *Action, p *load.Package, outfile string, flags []s ...@@ -1691,7 +1691,7 @@ func (b *Builder) ccompile(a *Action, p *load.Package, outfile string, flags []s
if !filepath.IsAbs(outfile) { if !filepath.IsAbs(outfile) {
outfile = filepath.Join(p.Dir, outfile) outfile = filepath.Join(p.Dir, outfile)
} }
output, err := b.runOut(filepath.Dir(file), desc, nil, compiler, flags, "-o", outfile, "-c", filepath.Base(file)) output, err := b.runOut(filepath.Dir(file), nil, compiler, flags, "-o", outfile, "-c", filepath.Base(file))
if len(output) > 0 { if len(output) > 0 {
// On FreeBSD 11, when we pass -g to clang 3.8 it // On FreeBSD 11, when we pass -g to clang 3.8 it
// invokes its internal assembler with -dwarf-version=2. // invokes its internal assembler with -dwarf-version=2.
...@@ -2215,7 +2215,7 @@ var ( ...@@ -2215,7 +2215,7 @@ var (
) )
func (b *Builder) swigDoVersionCheck() error { func (b *Builder) swigDoVersionCheck() error {
out, err := b.runOut("", "", nil, "swig", "-version") out, err := b.runOut("", nil, "swig", "-version")
if err != nil { if err != nil {
return err return err
} }
...@@ -2370,7 +2370,7 @@ func (b *Builder) swigOne(a *Action, p *load.Package, file, objdir string, pcCFL ...@@ -2370,7 +2370,7 @@ func (b *Builder) swigOne(a *Action, p *load.Package, file, objdir string, pcCFL
args = append(args, "-c++") args = append(args, "-c++")
} }
out, err := b.runOut(p.Dir, p.ImportPath, nil, "swig", args, file) out, err := b.runOut(p.Dir, nil, "swig", args, file)
if err != nil { if err != nil {
if len(out) > 0 { if len(out) > 0 {
if bytes.Contains(out, []byte("-intgosize")) || bytes.Contains(out, []byte("-cgo")) { if bytes.Contains(out, []byte("-intgosize")) || bytes.Contains(out, []byte("-cgo")) {
......
...@@ -128,7 +128,7 @@ func (gcToolchain) gc(b *Builder, a *Action, archive string, importcfg []byte, a ...@@ -128,7 +128,7 @@ func (gcToolchain) gc(b *Builder, a *Action, archive string, importcfg []byte, a
args = append(args, mkAbs(p.Dir, f)) args = append(args, mkAbs(p.Dir, f))
} }
output, err = b.runOut(p.Dir, p.ImportPath, nil, args...) output, err = b.runOut(p.Dir, nil, args...)
return ofile, output, err return ofile, output, err
} }
...@@ -289,14 +289,14 @@ func (gcToolchain) pack(b *Builder, a *Action, afile string, ofiles []string) er ...@@ -289,14 +289,14 @@ func (gcToolchain) pack(b *Builder, a *Action, afile string, ofiles []string) er
if cfg.BuildN { if cfg.BuildN {
return nil return nil
} }
if err := packInternal(b, absAfile, absOfiles); err != nil { if err := packInternal(absAfile, absOfiles); err != nil {
b.showOutput(a, p.Dir, p.ImportPath, err.Error()+"\n") b.showOutput(a, p.Dir, p.ImportPath, err.Error()+"\n")
return errPrintedOutput return errPrintedOutput
} }
return nil return nil
} }
func packInternal(b *Builder, afile string, ofiles []string) error { func packInternal(afile string, ofiles []string) error {
dst, err := os.OpenFile(afile, os.O_WRONLY|os.O_APPEND, 0) dst, err := os.OpenFile(afile, os.O_WRONLY|os.O_APPEND, 0)
if err != nil { if err != nil {
return err return err
......
...@@ -85,7 +85,7 @@ func (tools gccgoToolchain) gc(b *Builder, a *Action, archive string, importcfg ...@@ -85,7 +85,7 @@ func (tools gccgoToolchain) gc(b *Builder, a *Action, archive string, importcfg
args = append(args, mkAbs(p.Dir, f)) args = append(args, mkAbs(p.Dir, f))
} }
output, err = b.runOut(p.Dir, p.ImportPath, nil, args) output, err = b.runOut(p.Dir, nil, args)
return ofile, output, err return ofile, output, err
} }
...@@ -232,7 +232,7 @@ func (tools gccgoToolchain) link(b *Builder, root *Action, out, importcfg string ...@@ -232,7 +232,7 @@ func (tools gccgoToolchain) link(b *Builder, root *Action, out, importcfg string
readAndRemoveCgoFlags := func(archive string) (string, error) { readAndRemoveCgoFlags := func(archive string) (string, error) {
newID++ newID++
newArchive := root.Objdir + fmt.Sprintf("_pkg%d_.a", newID) newArchive := root.Objdir + fmt.Sprintf("_pkg%d_.a", newID)
if err := b.copyFile(root, newArchive, archive, 0666, false); err != nil { if err := b.copyFile(newArchive, archive, 0666, false); err != nil {
return "", err return "", err
} }
if cfg.BuildN || cfg.BuildX { if cfg.BuildN || cfg.BuildX {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment