Add support for MacOsX

This commit is contained in:
SpaiR committed 2020-06-02 22:02:40 +03:00
1 parent f327038f3b
commit 99bb339eae
6 files changed
+24 -1

No files matched your search

+1
View File
@@ -8,3 +8,4 @@ You can change that by using 'imgui.library.name' VM option (ex: -Dimgui.library
- imgui-java64.dll << win64 - imgui-java64.dll << win64
- libimgui-java.so << linux32 - libimgui-java.so << linux32
- libimgui-java64.so << linux64 - libimgui-java64.so << linux64
- libimgui-java64.dylib << MacOs64
Binary file not shown.
@@ -38,6 +38,11 @@ class GenerateLibs extends DefaultTask {
def linux32 = BuildTarget.newDefaultTarget(BuildTarget.TargetOs.Linux, false) def linux32 = BuildTarget.newDefaultTarget(BuildTarget.TargetOs.Linux, false)
def linux64 = BuildTarget.newDefaultTarget(BuildTarget.TargetOs.Linux, true) def linux64 = BuildTarget.newDefaultTarget(BuildTarget.TargetOs.Linux, true)
def mac64 = BuildTarget.newDefaultTarget(BuildTarget.TargetOs.MacOsX, true)
mac64.cppFlags += " -stdlib=libc++"
mac64.cppFlags = mac64.cppFlags.replaceAll("10.5", "10.9")
mac64.linkerFlags = mac64.linkerFlags.replaceAll("10.5", "10.9")
// Freetype Deps Config // Freetype Deps Config
win32.cppFlags += " -fstack-protector -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include" win32.cppFlags += " -fstack-protector -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include"
win32.libraries += "-lfreetype -lbz2 -lssp" win32.libraries += "-lfreetype -lbz2 -lssp"
@@ -47,6 +52,8 @@ class GenerateLibs extends DefaultTask {
linux32.linkerFlags += " -lfreetype" linux32.linkerFlags += " -lfreetype"
linux64.cppFlags += " -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include" linux64.cppFlags += " -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include"
linux64.linkerFlags += " -lfreetype" linux64.linkerFlags += " -lfreetype"
mac64.cppFlags += " -I/usr/local/include/freetype2 -I/usr/local/include/libpng16 -I/usr/local/include/harfbuzz -I/usr/local/include/glib-2.0 -I/usr/local/lib/glib-2.0/include"
mac64.linkerFlags += " -lfreetype"
// End // End
new AntScriptGenerator().generate(buildConfig, win32, win64, linux32, linux64) new AntScriptGenerator().generate(buildConfig, win32, win64, linux32, linux64)
@@ -58,6 +65,7 @@ class GenerateLibs extends DefaultTask {
BuildExecutor.executeAnt(jniDir + '/build-windows64.xml', '-v', '-Dhas-compiler=true', '-Drelease=true', 'clean', 'postcompile') BuildExecutor.executeAnt(jniDir + '/build-windows64.xml', '-v', '-Dhas-compiler=true', '-Drelease=true', 'clean', 'postcompile')
BuildExecutor.executeAnt(jniDir + '/build-linux32.xml', '-v', '-Dhas-compiler=true', '-Drelease=true', 'clean', 'postcompile') BuildExecutor.executeAnt(jniDir + '/build-linux32.xml', '-v', '-Dhas-compiler=true', '-Drelease=true', 'clean', 'postcompile')
BuildExecutor.executeAnt(jniDir + '/build-linux64.xml', '-v', '-Dhas-compiler=true', '-Drelease=true', 'clean', 'postcompile') BuildExecutor.executeAnt(jniDir + '/build-linux64.xml', '-v', '-Dhas-compiler=true', '-Drelease=true', 'clean', 'postcompile')
BuildExecutor.executeAnt(jniDir + '/build-macosx64.xml', '-v', '-Dhas-compiler=true', '-Drelease=true', 'clean', 'postcompile')
BuildExecutor.executeAnt(jniDir + '/build.xml', '-v', 'pack-natives') BuildExecutor.executeAnt(jniDir + '/build.xml', '-v', 'pack-natives')
} }
} }
+3
View File
@@ -24,6 +24,9 @@ if (System.getProperty('deployWin32')) {
} else if (System.getProperty('deployLinux64')) { } else if (System.getProperty('deployLinux64')) {
packageName = 'natives-linux' packageName = 'natives-linux'
libName = 'libimgui-java64.so' libName = 'libimgui-java64.so'
} else if (System.getProperty('deployMacOs64')) {
packageName = 'natives-macos'
libName = 'libimgui-java64.dylib'
} }
jar { jar {
+5 -1
View File
@@ -56,13 +56,17 @@ public final class ImGui {
private static String resolveFullLibName() { private static String resolveFullLibName() {
final boolean isWin = System.getProperty("os.name").toLowerCase().contains("win"); final boolean isWin = System.getProperty("os.name").toLowerCase().contains("win");
final boolean isMac = System.getProperty("os.name").toLowerCase().contains("mac");
final String libPrefix; final String libPrefix;
final String libSuffix; final String libSuffix;
if (isWin) { if (isWin) {
libPrefix = ""; libPrefix = "";
libSuffix = ".dll"; libSuffix = ".dll";
} else { // Only linux as an alternative OS } else if (isMac) {
libPrefix = "lib";
libSuffix = ".dylib";
} else {
libPrefix = "lib"; libPrefix = "lib";
libSuffix = ".so"; libSuffix = ".so";
} }
+7
View File
@@ -16,6 +16,9 @@ switch (OperatingSystem.current()) {
case OperatingSystem.WINDOWS: case OperatingSystem.WINDOWS:
project.ext.lwjglNatives = 'natives-windows' project.ext.lwjglNatives = 'natives-windows'
break break
case OperatingSystem.MAC_OS:
project.ext.lwjglNatives = 'natives-macos'
break
} }
dependencies { dependencies {
@@ -36,6 +39,10 @@ task startExample(type: JavaExec, dependsOn: build) {
main = 'ImGuiGlfwExample' main = 'ImGuiGlfwExample'
classpath = sourceSets.test.runtimeClasspath classpath = sourceSets.test.runtimeClasspath
jvmArgs = ['-Djava.library.path=../bin'] jvmArgs = ['-Djava.library.path=../bin']
if (OperatingSystem.current().isMacOsX()) {
jvmArgs += ['-XstartOnFirstThread', '-Djava.awt.headless=true']
}
} }
task sourcesJar(type: Jar, dependsOn: classes) { task sourcesJar(type: Jar, dependsOn: classes) {