Skip to content

Commit cb11d59

Browse files
committed
Compile an Intel only app launcher
1 parent c99be39 commit cb11d59

File tree

3 files changed

+50
-34
lines changed

3 files changed

+50
-34
lines changed

native/build.gradle

Lines changed: 50 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -9,33 +9,20 @@ task getXCrun(type: Exec) {
99
ext.run = { return standardOutput.toString().trim() }
1010
}
1111

12-
task compileNativeStarter(type: Exec) {
12+
def compileNativeStarter = { LIBJLI_DY_LIB, javahome, outputFile, List architectures ->
1313

14-
dependsOn getXCrun
15-
def outputFile = new File( "${buildDir}", "JavaAppLauncher" )
16-
doFirst {
17-
18-
def javahome = System.getProperty( "java.home" )
19-
def javahomeJRE = javahome;
20-
21-
if ( file("${javahomeJRE}/../jre").exists() ) {
22-
javahomeJRE += "/../jre";
23-
}
24-
25-
def LIBJLI_DY_LIB="${javahomeJRE}/lib/libjli.dylib"
26-
if ( !file(LIBJLI_DY_LIB).exists() ) {
27-
LIBJLI_DY_LIB="${javahomeJRE}/lib/jli/libjli.dylib"
28-
}
29-
30-
println "JAVA_HOME: ${javahome}";
31-
println "JAVA_HOME_JRE: ${javahomeJRE}";
32-
println "LIBJLI_DY_LIB: ${LIBJLI_DY_LIB}";
14+
def compileNative = project.tasks.create( [name: "compileNative-" + UUID.randomUUID(), type: Exec ] ) {
15+
workingDir "."
16+
commandLine "/usr/bin/gcc"
17+
outputs.file( outputFile )
3318

3419
args "-v"
35-
args "-arch"
36-
args "x86_64"
37-
args "-arch"
38-
args "arm64"
20+
21+
for( String arch : architectures ) {
22+
args "-arch"
23+
args arch
24+
}
25+
3926
args "-I"
4027
args "${javahome}/include"
4128
args "-I"
@@ -53,20 +40,49 @@ task compileNativeStarter(type: Exec) {
5340
args "-o"
5441
args outputFile
5542
args "main.m"
56-
}
43+
}
44+
45+
compileNative.exec()
46+
outputFile.setExecutable( true, false)
47+
println "Copying '${outputFile}' to destination"
48+
copy {
49+
from( outputFile )
50+
into('../src/com/oracle/appbundler')
51+
}
52+
}
53+
54+
task createNativeStarter {
55+
56+
dependsOn getXCrun
5757

5858
doLast {
59-
outputFile.setExecutable( true, false)
60-
copy {
61-
from( outputFile )
62-
into('../src/com/oracle/appbundler')
59+
60+
file("${buildDir}").mkdirs()
61+
62+
def javahome = System.getProperty( "java.home" )
63+
def javahomeJRE = javahome;
64+
65+
if ( file("${javahomeJRE}/../jre").exists() ) {
66+
javahomeJRE += "/../jre";
67+
}
68+
69+
def LIBJLI_DY_LIB="${javahomeJRE}/lib/libjli.dylib"
70+
if ( !file(LIBJLI_DY_LIB).exists() ) {
71+
LIBJLI_DY_LIB="${javahomeJRE}/lib/jli/libjli.dylib"
6372
}
64-
}
6573

66-
workingDir "."
67-
outputs.file( outputFile )
74+
println "JAVA_HOME: ${javahome}";
75+
println "JAVA_HOME_JRE: ${javahomeJRE}";
76+
println "LIBJLI_DY_LIB: ${LIBJLI_DY_LIB}";
6877

69-
commandLine "/usr/bin/gcc"
78+
println "Creating JavaAppLauncher"
79+
def outputFile = new File( "${buildDir}", "JavaAppLauncher" )
80+
compileNativeStarter LIBJLI_DY_LIB, javahome, outputFile, [ 'x86_64', 'arm64' ]
81+
82+
println "Creating JavaAppLauncher_x86_64"
83+
def outputFileX86 = new File( "${buildDir}", "JavaAppLauncher_x86_64" )
84+
compileNativeStarter LIBJLI_DY_LIB, javahome, outputFileX86, [ 'x86_64' ]
85+
}
7086
}
7187

72-
defaultTasks = ["compileNativeStarter", "clean"]
88+
defaultTasks = ["clean", "createNativeStarter"]
0 Bytes
Binary file not shown.
52.7 KB
Binary file not shown.

0 commit comments

Comments
 (0)