1- plugins {
2- id " org.openbakery.xcode-plugin" version " 0.21.0"
3- }
1+ // see https://github.com/TheInfiniteKind/appbundler
42
53apply plugin : ' java'
64
7- task prepareXCodeBuild () {
5+ task getXCrun (type : Exec ) {
6+ commandLine " xcrun"
7+ args " --show-sdk-path"
8+ standardOutput = new ByteArrayOutputStream ()
9+ ext. run = { return standardOutput. toString(). trim() }
10+ }
11+
12+ task compileNativeStarter (type : Exec ) {
13+
14+ dependsOn getXCrun
15+ def outputFile = new File ( " ${ buildDir} " , " JavaAppLauncher" )
16+ doFirst {
817
9- doLast {
1018 def javahome = System . getProperty( " java.home" )
1119 def javahomeJRE = javahome;
1220
@@ -22,31 +30,41 @@ task prepareXCodeBuild() {
2230 println " JAVA_HOME: ${ javahome} " ;
2331 println " JAVA_HOME_JRE: ${ javahomeJRE} " ;
2432 println " LIBJLI_DY_LIB: ${ LIBJLI_DY_LIB} " ;
25-
26- xcodebuild. environment = [
27- " JAVA_HOME_PATH" : new String (" ${ javahomeJRE} " ),
28- " LIBJLI_DYLIB" : new String (" ${ LIBJLI_DY_LIB} " )
29- ]
30- }
31- }
3233
33- task finalizeXCodeBuild () {
34- doLast {
35- def outputFile = new File ( " ${ buildDir} /sym/Release" , " JavaAppLauncher" )
34+ args " -v"
35+ args " -arch"
36+ args " x86_64"
37+ args " -I"
38+ args " ${ javahome} /include"
39+ args " -I"
40+ args " ${ javahome} /include/darwin"
41+ args " -DLIBJLI_DYLIB=\" ${ LIBJLI_DY_LIB} \" "
42+ args " -framework"
43+ args " Cocoa"
44+ args " -F"
45+ args " ${ javahome} /../.."
46+ args " -isysroot"
47+ args " ${ getXCrun.run()} "
48+ args " -mmacosx-version-min=10.7"
49+ args " -fobjc-exceptions"
50+ args " -std=c99"
51+ args " -o"
52+ args outputFile
53+ args " main.m"
54+ }
55+
56+ doLast {
3657 outputFile. setExecutable( true , false )
3758 copy {
3859 from( outputFile )
3960 into(' ../src/com/oracle/appbundler' )
4061 }
41- }
42- }
62+ }
63+
64+ workingDir " ."
65+ outputs. file( outputFile )
4366
44- xcodebuild {
45- scheme = ' JavaAppLauncher'
46- target = ' JavaAppLauncher'
47- configuration = ' Release'
48- type = ' macOS'
49- destination = " ${ buildDir} "
67+ commandLine " /usr/bin/gcc"
5068}
5169
52- defaultTasks = [ " prepareXCodeBuild " , " xcodebuild " , " finalizeXCodeBuild " , " clean" ]
70+ defaultTasks = [" compileNativeStarter " , " clean" ]
0 commit comments