Skip to content

Commit

Permalink
cmd/gomobile: use Output instead of CombinedOutput at envClang
Browse files Browse the repository at this point in the history
It dosen't make sense to parse stdout and stderr to get a necessary
information like clang command. Actually envClang sometimes didn't work
correctly due to this.

Fixes golang/go#53316

Change-Id: Ia2c518c44c0003b4f9b50dba85fb971c2ef4340d
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/620315
Reviewed-by: Dmitri Shuralyov <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
Reviewed-by: Dmitri Shuralyov <[email protected]>
Reviewed-by: Michael Knyszek <[email protected]>
  • Loading branch information
hajimehoshi committed Oct 16, 2024
1 parent 08a83c5 commit 7ff8300
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions cmd/gomobile/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -436,15 +436,21 @@ func envClang(sdkName string) (clang, cflags string, err error) {
return sdkName + "-clang", "-isysroot " + sdkName, nil
}
cmd := exec.Command("xcrun", "--sdk", sdkName, "--find", "clang")
out, err := cmd.CombinedOutput()
out, err := cmd.Output()
if err != nil {
if ee := (*exec.ExitError)(nil); errors.As(err, &ee) {
out = append(out, ee.Stderr...)
}
return "", "", fmt.Errorf("xcrun --find: %v\n%s", err, out)
}
clang = strings.TrimSpace(string(out))

cmd = exec.Command("xcrun", "--sdk", sdkName, "--show-sdk-path")
out, err = cmd.CombinedOutput()
out, err = cmd.Output()
if err != nil {
if ee := (*exec.ExitError)(nil); errors.As(err, &ee) {
out = append(out, ee.Stderr...)
}
return "", "", fmt.Errorf("xcrun --show-sdk-path: %v\n%s", err, out)
}
sdk := strings.TrimSpace(string(out))
Expand Down

0 comments on commit 7ff8300

Please sign in to comment.