cmd/gomobile: use Output instead of CombinedOutput at envClang

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 <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
This commit is contained in:
Hajime Hoshi 2024-10-15 17:38:47 +09:00
Родитель 08a83c5af9
Коммит 7ff83004ec
1 изменённых файлов: 8 добавлений и 2 удалений

Просмотреть файл

@ -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))