handle --long build flags properly

cmd/go treats "--foo=bar" juts like "-foo=bar",
just like any other program using the flag package.

However, we didn't support this longer form in filterForwardBuildFlags.
Because of it, "garble build -tags=foo" worked,
but "garble build --tags=foo" did not,
as we wouldn't forward "--tags=foo" as a build flag for "go list".

Fixes #429.
pull/457/head
Daniel Martí 3 years ago committed by Andrew LeFevre
parent d8e5351175
commit c506f02763

@ -1880,7 +1880,10 @@ func filterForwardBuildFlags(flags []string) (filtered []string, firstUnknown st
arg := flags[i]
name := arg
if i := strings.IndexByte(arg, '='); i > 0 {
name = arg[:i]
name = arg[:i] // "-name=value" to "-name"
}
if strings.HasPrefix(name, "--") {
name = name[1:] // "--name" to "-name"
}
buildFlag := forwardBuildFlags[name]

@ -36,8 +36,9 @@ go build -tags buildtag
exec ./main
cmp stdout main.stdout
# Also check that -literals doesn't break anything
garble -literals build -tags buildtag
# Check that -literals doesn't break anything.
# Also check that a different form of -tags still works.
garble -literals build --tags=buildtag
exec ./main
cmp stdout main.stdout

Loading…
Cancel
Save