@@ -61,28 +61,37 @@ setupTools("mac_tools",
61
61
} else if (! file(defaultSdkPath). isDirectory()) {
62
62
// Get list of all macosx sdks
63
63
ByteArrayOutputStream results = new ByteArrayOutputStream ();
64
- exec {
64
+ def xcodeBuildResult = exec {
65
65
commandLine(" xcodebuild" , " -version" , " -showsdks" );
66
66
setStandardOutput(results);
67
+ ignoreExitValue(true );
67
68
}
68
-
69
- BufferedReader reader = new BufferedReader (new StringReader (results. toString(). trim()));
70
- // If our preferred SDK is in the list use it, else use the default
71
- String sdk = " macosx"
72
- String prefSdk = sdk + prefSdkVersion
73
- while (true ) {
74
- def line = reader. readLine();
75
- if (line == null ) break ;
76
- if (line. contains(" -sdk ${ prefSdk} " )) {
77
- sdk = prefSdk
78
- break ;
69
+ if (xcodeBuildResult. exitValue == 0 ) {
70
+ BufferedReader reader = new BufferedReader (new StringReader (results. toString(). trim()));
71
+ // If our preferred SDK is in the list use it, else use the default
72
+ String sdk = " macosx"
73
+ String prefSdk = sdk + prefSdkVersion
74
+ while (true ) {
75
+ def line = reader. readLine();
76
+ if (line == null ) break ;
77
+ if (line. contains(" -sdk ${ prefSdk} " )) {
78
+ sdk = prefSdk
79
+ break ;
80
+ }
79
81
}
80
- }
81
82
82
- results = new ByteArrayOutputStream ();
83
- exec {
84
- commandLine(" xcodebuild" , " -version" , " -sdk" , sdk, " Path" );
85
- setStandardOutput(results);
83
+ results = new ByteArrayOutputStream ();
84
+ exec {
85
+ commandLine(" xcodebuild" , " -version" , " -sdk" , sdk, " Path" );
86
+ setStandardOutput(results);
87
+ }
88
+ } else {
89
+ // try with command line developer tools
90
+ results = new ByteArrayOutputStream ();
91
+ exec {
92
+ commandLine(" xcrun" , " --show-sdk-path" );
93
+ setStandardOutput(results);
94
+ }
86
95
}
87
96
String sdkPath = results. toString(). trim();
88
97
propFile << " MACOSX_SDK_PATH=" << sdkPath << " \n " ;
@@ -97,7 +106,12 @@ println "MACOSX_MIN_VERSION = $MACOSX_MIN_VERSION"
97
106
println " MACOSX_SDK_PATH = $MACOSX_SDK_PATH "
98
107
99
108
if (! file(MACOSX_SDK_PATH ). isDirectory()) {
100
- throw new GradleException (" FAIL: Cannot find $MACOSX_SDK_PATH " )
109
+ throw new GradleException (
110
+ """
111
+ FAIL: Cannot find $MACOSX_SDK_PATH
112
+ Install Xcode or Command line developer tool using `xcode-select --install`
113
+ """
114
+ );
101
115
}
102
116
103
117
// NOTE: There is no space between -iframework and the specified path
@@ -169,7 +183,7 @@ MAC.prism = [:]
169
183
MAC . prism. javahInclude = [" com/sun/prism/impl/**/*" , " com/sun/prism/PresentableState*" ]
170
184
MAC . prism. nativeSource = file(" ${ project("graphics").projectDir} /src/main/native-prism" )
171
185
MAC . prism. compiler = compiler
172
- MAC . prism. ccFlags = [" -O3" , " -DINLINE=inline" , " -c" , ccBaseFlags]. flatten()
186
+ MAC . prism. ccFlags = [" -O3" , " -DINLINE=inline" , " -c" , IS_STATIC_BUILD ? " -DSTATIC_BUILD " : " " , ccBaseFlags]. flatten()
173
187
MAC . prism. linker = linker
174
188
MAC . prism. linkFlags = linkFlagsAlt
175
189
MAC . prism. lib = " prism_common"
0 commit comments