Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: dont remove duplicated flags #265

Merged
merged 1 commit into from
Dec 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions test/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ func TestBuildProject(t *testing.T) {
const AppName = "build"
UseApp(AppName)
RunGoBuild(t, "go", "build", "-o", "default", "cmd/foo.go")
RunGoBuild(t, "go", "build", "-o", "./cmd", "./cmd")
RunGoBuild(t, "go", "build", "cmd/foo.go")
RunGoBuild(t, "go", "build", "cmd/foo.go", "cmd/bar.go")
RunGoBuild(t, "go", "build", "cmd")
Expand Down
5 changes: 2 additions & 3 deletions tool/preprocess/preprocess.go
Original file line number Diff line number Diff line change
Expand Up @@ -458,11 +458,11 @@ func runDryBuild(goBuildCmd []string) error {
}
// The full build command is: "go build -a -x -n {...}"
args := []string{"go", "build", "-a", "-x", "-n"}
args = append(args, goBuildCmd...)
args = util.StringDedup(args)
args = append(args, goBuildCmd[2:]...)
shared.AssertGoBuild(args)

// Run the dry build
util.Log("Run dry build %v", args)
cmd := exec.Command(args[0], args[1:]...)
cmd.Stdout = dryRunLog
cmd.Stderr = dryRunLog
Expand Down Expand Up @@ -545,7 +545,6 @@ func runBuildWithToolexec(goBuildCmd []string) error {
if config.GetConf().Verbose {
util.Log("Run go build with args %v in toolexec mode", args)
}
args = util.StringDedup(args)
shared.AssertGoBuild(args)
out, err := util.RunCmdOutput(args...)
util.Log("Run go build with toolexec: %v", out)
Expand Down
14 changes: 0 additions & 14 deletions tool/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,20 +300,6 @@ func PhaseTimer(name string) func() {
}
}

// StringDedup removes duplicate strings in a slice and returns a new slice
// in original order.
func StringDedup(s []string) []string {
m := make(map[string]struct{})
var r []string
for _, v := range s {
if _, ok := m[v]; !ok {
m[v] = struct{}{}
r = append(r, v)
}
}
return r
}

func GetToolName() string {
// Get the path of the current executable
ex, err := os.Executable()
Expand Down
Loading