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

8232158: [macOS] Fallback to command line tools if xcode is missing #13

Closed
Closed
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -61,28 +61,37 @@ setupTools("mac_tools",
} else if (!file(defaultSdkPath).isDirectory()) {
// Get list of all macosx sdks
ByteArrayOutputStream results = new ByteArrayOutputStream();
exec {
def xcodeBuildResult = exec {
commandLine("xcodebuild", "-version", "-showsdks");
setStandardOutput(results);
ignoreExitValue(true);
}

BufferedReader reader = new BufferedReader(new StringReader(results.toString().trim()));
// If our preferred SDK is in the list use it, else use the default
String sdk = "macosx"
String prefSdk = sdk + prefSdkVersion
while (true) {
def line = reader.readLine();
if (line == null) break;
if (line.contains("-sdk ${prefSdk}")) {
sdk = prefSdk
break;
if (xcodeBuildResult.exitValue == 0) {
BufferedReader reader = new BufferedReader(new StringReader(results.toString().trim()));
// If our preferred SDK is in the list use it, else use the default
String sdk = "macosx"
String prefSdk = sdk + prefSdkVersion
while (true) {
def line = reader.readLine();
if (line == null) break;
if (line.contains("-sdk ${prefSdk}")) {
sdk = prefSdk
break;
}
}
}

results = new ByteArrayOutputStream();
exec {
commandLine("xcodebuild", "-version", "-sdk", sdk, "Path");
setStandardOutput(results);
results = new ByteArrayOutputStream();
exec {
commandLine("xcodebuild", "-version", "-sdk", sdk, "Path");
setStandardOutput(results);
}
} else {
// try with command line developer tools
results = new ByteArrayOutputStream();
exec {
commandLine("xcrun", "--show-sdk-path");
setStandardOutput(results);
}
}
String sdkPath = results.toString().trim();
propFile << "MACOSX_SDK_PATH=" << sdkPath << "\n";
@@ -97,7 +106,12 @@ println "MACOSX_MIN_VERSION = $MACOSX_MIN_VERSION"
println "MACOSX_SDK_PATH = $MACOSX_SDK_PATH"

if (!file(MACOSX_SDK_PATH).isDirectory()) {
throw new GradleException("FAIL: Cannot find $MACOSX_SDK_PATH")
throw new GradleException(
"""
FAIL: Cannot find $MACOSX_SDK_PATH
Install Xcode or Command line developer tool using `xcode-select --install`
"""
);
}

// NOTE: There is no space between -iframework and the specified path
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.