@@ -61,28 +61,37 @@ setupTools("mac_tools",
6161 } else if (! file(defaultSdkPath). isDirectory()) {
6262 // Get list of all macosx sdks
6363 ByteArrayOutputStream results = new ByteArrayOutputStream ();
64- exec {
64+ def xcodeBuildResult = exec {
6565 commandLine(" xcodebuild" , " -version" , " -showsdks" );
6666 setStandardOutput(results);
67+ ignoreExitValue(true );
6768 }
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+ }
7981 }
80- }
8182
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+ }
8695 }
8796 String sdkPath = results. toString(). trim();
8897 propFile << " MACOSX_SDK_PATH=" << sdkPath << " \n " ;
@@ -97,7 +106,12 @@ println "MACOSX_MIN_VERSION = $MACOSX_MIN_VERSION"
97106println " MACOSX_SDK_PATH = $MACOSX_SDK_PATH "
98107
99108if (! 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+ );
101115}
102116
103117// NOTE: There is no space between -iframework and the specified path
@@ -169,7 +183,7 @@ MAC.prism = [:]
169183MAC . prism. javahInclude = [" com/sun/prism/impl/**/*" , " com/sun/prism/PresentableState*" ]
170184MAC . prism. nativeSource = file(" ${ project("graphics").projectDir} /src/main/native-prism" )
171185MAC . 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()
173187MAC . prism. linker = linker
174188MAC . prism. linkFlags = linkFlagsAlt
175189MAC . prism. lib = " prism_common"
0 commit comments