Browse Source

Build: Check multiple possible folder layouts in the jdk.

Use the new drop-in JNF version, which specifies a flat install directory.
jxlayer
Jannis Weis 3 years ago committed by Jannis Weis
parent
commit
2db338b684
  1. 2
      gradle/libs.versions.toml
  2. 19
      macos/build.gradle.kts
  3. 2
      macos/src/main/java/com/github/weisj/darklaf/platform/macos/MacOSLibrary.java

2
gradle/libs.versions.toml

@ -11,7 +11,7 @@ lGoodDatePicker = "11.0.2"
swingDsl = "latest.integration" swingDsl = "latest.integration"
nullabilityAnnotations = "16.0.2" nullabilityAnnotations = "16.0.2"
macOSFramework = "latest.release" macOSFramework = "latest.release"
javaNativeFoundation = "1.0.0" javaNativeFoundation = "1.1.0"
[libraries] [libraries]
jna = { module = "net.java.dev.jna:jna", version.ref = "jna" } jna = { module = "net.java.dev.jna:jna", version.ref = "jna" }

19
macos/build.gradle.kts

@ -27,7 +27,7 @@ val jnfConfig: Configuration by configurations.creating {
} }
dependencies { dependencies {
jnfConfig("com.github.weisj:java-native-foundation:1.0.0") jnfConfig("com.github.weisj:java-native-foundation:1.1.0")
} }
val nativeResourcePath = "com/github/weisj/darklaf/platform/${project.name}" val nativeResourcePath = "com/github/weisj/darklaf/platform/${project.name}"
@ -36,7 +36,7 @@ tasks.jar {
jnfConfig.asFileTree.forEach { jnfConfig.asFileTree.forEach {
from(zipTree(it)) { from(zipTree(it)) {
into("$nativeResourcePath/JavaNativeFoundation.framework") into("$nativeResourcePath/JavaNativeFoundation.framework")
include("Versions/A/JavaNativeFoundation*") include("JavaNativeFoundation*")
exclude("**/*.tbd") exclude("**/*.tbd")
} }
} }
@ -66,6 +66,9 @@ library {
optimizedBinary() optimizedBinary()
} }
linkTask.configure { linkTask.configure {
val systemFrameworks = "/System/Library/Frameworks"
val current = "Versions/Current"
val jnfName = "JavaNativeFoundation.framework"
linkerArgs.addAll( linkerArgs.addAll(
"-lobjc", "-mmacosx-version-min=$minOs", "-lobjc", "-mmacosx-version-min=$minOs",
// "-framework", "AppKit", // "-framework", "AppKit",
@ -74,12 +77,14 @@ library {
// with the dynamic library of the framework we specifically have to add the system framework // with the dynamic library of the framework we specifically have to add the system framework
// search paths accordingly. // search paths accordingly.
// First try any system provided framework (this will fail on arm64): // First try any system provided framework (this will fail on arm64):
"-rpath", "/System/Library/Frameworks", "-rpath", "$systemFrameworks/$jnfName/$current",
"-rpath", "/System/Library/Frameworks/JavaVM.framework/Versions/A/Frameworks", "-rpath", "$systemFrameworks/JavaVM.framework/$current/Frameworks/$jnfName/$current",
// Then try the jdk provided framework: // Then try the jdk provided framework (folder layout may vary. We check multiple possibilities):
"-rpath", "@executable_path/../lib", "-rpath", "@executable_path/../lib/$jnfName",
"-rpath", "@executable_path/../lib/$jnfName/$current/",
"-rpath", "@executable_path/../lib/$jnfName/Versions/A/",
// Lastly use our bundled drop-in replacement: // Lastly use our bundled drop-in replacement:
"-rpath", "@loader_path" "-rpath", "@loader_path/$jnfName"
) )
} }
} }

2
macos/src/main/java/com/github/weisj/darklaf/platform/macos/MacOSLibrary.java

@ -36,7 +36,7 @@ public class MacOSLibrary extends AbstractLibrary {
private static final String arm64_PATH = "macos-arm64/"; private static final String arm64_PATH = "macos-arm64/";
private static final String DLL_NAME = "libdarklaf-macos.dylib"; private static final String DLL_NAME = "libdarklaf-macos.dylib";
private static final String FRAMEWORK_TARGET_PATH = "JavaNativeFoundation.framework/Versions/A/"; private static final String FRAMEWORK_TARGET_PATH = "JavaNativeFoundation.framework/";
private static final String FRAMEWORK_PATH = PATH + FRAMEWORK_TARGET_PATH + "JavaNativeFoundation"; private static final String FRAMEWORK_PATH = PATH + FRAMEWORK_TARGET_PATH + "JavaNativeFoundation";
private static final MacOSLibrary instance = new MacOSLibrary(); private static final MacOSLibrary instance = new MacOSLibrary();

Loading…
Cancel
Save