-
-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
M1 support #112
Closed
Closed
M1 support #112
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ repositories { | |
} | ||
|
||
ext { | ||
jnigenVersion = '2.0.1' | ||
jnigenVersion = '2.2.1' | ||
} | ||
|
||
dependencies { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ class GenerateLibs extends DefaultTask { | |
private final boolean forWindows = buildEnvs?.contains('win') | ||
private final boolean forLinux = buildEnvs?.contains('linux') | ||
private final boolean forMac = buildEnvs?.contains('mac') | ||
private static final boolean isARM = System.getProperty("os.arch").equals("arm") || System.getProperty("os.arch").startsWith("aarch64"); | ||
|
||
private final boolean isLocal = System.properties.containsKey('local') | ||
private final boolean withFreeType = Boolean.valueOf(System.properties.getProperty('freetype', 'false')) | ||
|
@@ -104,6 +105,13 @@ class GenerateLibs extends DefaultTask { | |
mac64.linkerFlags = mac64.linkerFlags.replace('10.7', minMacOsVersion) | ||
addFreeTypeIfEnabled(mac64) | ||
buildTargets += mac64 | ||
|
||
def macM1 = BuildTarget.newDefaultTarget(BuildTarget.TargetOs.MacOsX, true, true) | ||
macM1.cppFlags += ' -std=c++14' | ||
macM1.cppFlags = macM1.cppFlags.replace('10.7', minMacOsVersion) | ||
macM1.linkerFlags = macM1.linkerFlags.replace('10.7', minMacOsVersion) | ||
addFreeTypeIfEnabled(macM1) | ||
buildTargets += macM1 | ||
} | ||
|
||
new AntScriptGenerator().generate(buildConfig, buildTargets) | ||
|
@@ -117,8 +125,10 @@ class GenerateLibs extends DefaultTask { | |
BuildExecutor.executeAnt(jniDir + '/build-windows64.xml', commonParams) | ||
if (forLinux) | ||
BuildExecutor.executeAnt(jniDir + '/build-linux64.xml', commonParams) | ||
if (forMac) | ||
if (forMac) { | ||
BuildExecutor.executeAnt(jniDir + '/build-macosx64.xml', commonParams) | ||
BuildExecutor.executeAnt(jniDir + '/build-macosxarm64.xml', commonParams) | ||
} | ||
|
||
BuildExecutor.executeAnt(jniDir + '/build.xml', '-v', 'pack-natives') | ||
} | ||
|
@@ -137,6 +147,10 @@ class GenerateLibs extends DefaultTask { | |
break | ||
case BuildTarget.TargetOs.MacOsX: | ||
target.cppFlags += ' -I/usr/local/include/freetype2' | ||
if (isARM) { | ||
//For GHA | ||
target.cppFlags += ' -I/usr/local/arm64/include/freetype2' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That what I was talking about: split builds for different archs. |
||
} | ||
break | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,10 @@ | |
public class ImGui { | ||
private static final String LIB_PATH_PROP = "imgui.library.path"; | ||
private static final String LIB_NAME_PROP = "imgui.library.name"; | ||
private static final String LIB_NAME_DEFAULT = System.getProperty("os.arch").contains("64") ? "imgui-java64" : "imgui-java"; | ||
private static final String LIB_NAME_BASE = "imgui-java"; | ||
private static final boolean is64Bit = System.getProperty("os.arch").contains("64") || System.getProperty("os.arch").startsWith("armv8"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can be simplified: if it's no ARM, then it's 64 for sure. |
||
private static final boolean isARM = System.getProperty("os.arch").equals("arm") || System.getProperty("os.arch").startsWith("aarch64"); | ||
|
||
private static final String LIB_TMP_DIR_PREFIX = "imgui-java-natives_" + System.currentTimeMillis(); | ||
|
||
private static final ImGuiContext IMGUI_CONTEXT; | ||
|
@@ -45,7 +48,16 @@ public class ImGui { | |
|
||
static { | ||
final String libPath = System.getProperty(LIB_PATH_PROP); | ||
final String libName = System.getProperty(LIB_NAME_PROP, LIB_NAME_DEFAULT); | ||
String genLibName = LIB_NAME_BASE; | ||
|
||
if (isARM) { | ||
genLibName += "arm"; | ||
} | ||
if (is64Bit) { | ||
genLibName += "64"; | ||
} | ||
|
||
final String libName = System.getProperty(LIB_NAME_PROP, genLibName); | ||
final String fullLibName = resolveFullLibName(); | ||
|
||
final String extractedLibAbsPath = tryLoadFromClasspath(fullLibName); | ||
|
@@ -104,7 +116,17 @@ private static String resolveFullLibName() { | |
libSuffix = ".so"; | ||
} | ||
|
||
return System.getProperty(LIB_NAME_PROP, libPrefix + LIB_NAME_DEFAULT + libSuffix); | ||
String genLibName = LIB_NAME_BASE; | ||
|
||
if (isARM) { | ||
genLibName += "arm"; | ||
} | ||
if (is64Bit) { | ||
genLibName += "64"; | ||
} | ||
|
||
|
||
return System.getProperty(LIB_NAME_PROP, libPrefix + genLibName + libSuffix); | ||
} | ||
|
||
// This method tries to unpack the library binary from classpath into the temp dir. | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need it for amd64 builds.