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

cmd/gomobile: filter out xcrun warnings to get path #84

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
14 changes: 12 additions & 2 deletions cmd/gomobile/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,16 @@ func ndkRoot(targets ...targetInfo) (string, error) {
return ndkRoot, nil
}

// Necessary to filter out warnings about missing extensions.
func getAbsolutePath(output []byte) (path string) {
for _, line := range strings.Split(string(output), "\n") {
if strings.HasPrefix(line, "/") {
return line
}
}
return ""
}

func envClang(sdkName string) (clang, cflags string, err error) {
if buildN {
return sdkName + "-clang", "-isysroot " + sdkName, nil
Expand All @@ -440,14 +450,14 @@ func envClang(sdkName string) (clang, cflags string, err error) {
if err != nil {
return "", "", fmt.Errorf("xcrun --find: %v\n%s", err, out)
}
clang = strings.TrimSpace(string(out))
clang = getAbsolutePath(out)

cmd = exec.Command("xcrun", "--sdk", sdkName, "--show-sdk-path")
out, err = cmd.CombinedOutput()
if err != nil {
return "", "", fmt.Errorf("xcrun --show-sdk-path: %v\n%s", err, out)
}
sdk := strings.TrimSpace(string(out))
sdk := getAbsolutePath(out)
return clang, "-isysroot " + sdk, nil
}

Expand Down