Skip to content

Commit 99bb339

Browse files
committed
Add support for MacOsX
1 parent f327038 commit 99bb339

File tree

6 files changed

+28
-5
lines changed

6 files changed

+28
-5
lines changed

bin/README.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ The same way you can use 'java.library.path' option as well.
44
By default binding expects 'imgui-java' ('imgui-java64' for x64 arch) file name.
55
You can change that by using 'imgui.library.name' VM option (ex: -Dimgui.library.name=custom-lib-name).
66

7-
- imgui-java.dll << win32
8-
- imgui-java64.dll << win64
9-
- libimgui-java.so << linux32
10-
- libimgui-java64.so << linux64
7+
- imgui-java.dll << win32
8+
- imgui-java64.dll << win64
9+
- libimgui-java.so << linux32
10+
- libimgui-java64.so << linux64
11+
- libimgui-java64.dylib << MacOs64

bin/libimgui-java64.dylib

1.06 MB
Binary file not shown.

buildSrc/src/main/groovy/imgui/generate/GenerateLibs.groovy

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ class GenerateLibs extends DefaultTask {
3838
def linux32 = BuildTarget.newDefaultTarget(BuildTarget.TargetOs.Linux, false)
3939
def linux64 = BuildTarget.newDefaultTarget(BuildTarget.TargetOs.Linux, true)
4040

41+
def mac64 = BuildTarget.newDefaultTarget(BuildTarget.TargetOs.MacOsX, true)
42+
mac64.cppFlags += " -stdlib=libc++"
43+
mac64.cppFlags = mac64.cppFlags.replaceAll("10.5", "10.9")
44+
mac64.linkerFlags = mac64.linkerFlags.replaceAll("10.5", "10.9")
45+
4146
// Freetype Deps Config
4247
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"
4348
win32.libraries += "-lfreetype -lbz2 -lssp"
@@ -47,6 +52,8 @@ class GenerateLibs extends DefaultTask {
4752
linux32.linkerFlags += " -lfreetype"
4853
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"
4954
linux64.linkerFlags += " -lfreetype"
55+
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"
56+
mac64.linkerFlags += " -lfreetype"
5057
// End
5158

5259
new AntScriptGenerator().generate(buildConfig, win32, win64, linux32, linux64)
@@ -58,6 +65,7 @@ class GenerateLibs extends DefaultTask {
5865
BuildExecutor.executeAnt(jniDir + '/build-windows64.xml', '-v', '-Dhas-compiler=true', '-Drelease=true', 'clean', 'postcompile')
5966
BuildExecutor.executeAnt(jniDir + '/build-linux32.xml', '-v', '-Dhas-compiler=true', '-Drelease=true', 'clean', 'postcompile')
6067
BuildExecutor.executeAnt(jniDir + '/build-linux64.xml', '-v', '-Dhas-compiler=true', '-Drelease=true', 'clean', 'postcompile')
68+
BuildExecutor.executeAnt(jniDir + '/build-macosx64.xml', '-v', '-Dhas-compiler=true', '-Drelease=true', 'clean', 'postcompile')
6169
BuildExecutor.executeAnt(jniDir + '/build.xml', '-v', 'pack-natives')
6270
}
6371
}

imgui-binding-natives/build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ if (System.getProperty('deployWin32')) {
2424
} else if (System.getProperty('deployLinux64')) {
2525
packageName = 'natives-linux'
2626
libName = 'libimgui-java64.so'
27+
} else if (System.getProperty('deployMacOs64')) {
28+
packageName = 'natives-macos'
29+
libName = 'libimgui-java64.dylib'
2730
}
2831

2932
jar {

imgui-binding/src/main/java/imgui/ImGui.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,17 @@ public final class ImGui {
5656

5757
private static String resolveFullLibName() {
5858
final boolean isWin = System.getProperty("os.name").toLowerCase().contains("win");
59+
final boolean isMac = System.getProperty("os.name").toLowerCase().contains("mac");
5960
final String libPrefix;
6061
final String libSuffix;
6162

6263
if (isWin) {
6364
libPrefix = "";
6465
libSuffix = ".dll";
65-
} else { // Only linux as an alternative OS
66+
} else if (isMac) {
67+
libPrefix = "lib";
68+
libSuffix = ".dylib";
69+
} else {
6670
libPrefix = "lib";
6771
libSuffix = ".so";
6872
}

imgui-lwjgl3/build.gradle

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ switch (OperatingSystem.current()) {
1616
case OperatingSystem.WINDOWS:
1717
project.ext.lwjglNatives = 'natives-windows'
1818
break
19+
case OperatingSystem.MAC_OS:
20+
project.ext.lwjglNatives = 'natives-macos'
21+
break
1922
}
2023

2124
dependencies {
@@ -36,6 +39,10 @@ task startExample(type: JavaExec, dependsOn: build) {
3639
main = 'ImGuiGlfwExample'
3740
classpath = sourceSets.test.runtimeClasspath
3841
jvmArgs = ['-Djava.library.path=../bin']
42+
43+
if (OperatingSystem.current().isMacOsX()) {
44+
jvmArgs += ['-XstartOnFirstThread', '-Djava.awt.headless=true']
45+
}
3946
}
4047

4148
task sourcesJar(type: Jar, dependsOn: classes) {

0 commit comments

Comments
 (0)