From 2db338b684d080884c2de1773df825ac5917a28a Mon Sep 17 00:00:00 2001 From: Jannis Weis Date: Sat, 10 Jul 2021 10:15:56 +0200 Subject: [PATCH] Build: Check multiple possible folder layouts in the jdk. Use the new drop-in JNF version, which specifies a flat install directory. --- gradle/libs.versions.toml | 2 +- macos/build.gradle.kts | 19 ++++++++++++------- .../darklaf/platform/macos/MacOSLibrary.java | 2 +- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 13145e2b..3d1e0b17 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -11,7 +11,7 @@ lGoodDatePicker = "11.0.2" swingDsl = "latest.integration" nullabilityAnnotations = "16.0.2" macOSFramework = "latest.release" -javaNativeFoundation = "1.0.0" +javaNativeFoundation = "1.1.0" [libraries] jna = { module = "net.java.dev.jna:jna", version.ref = "jna" } diff --git a/macos/build.gradle.kts b/macos/build.gradle.kts index fdf75afa..9311a7a7 100644 --- a/macos/build.gradle.kts +++ b/macos/build.gradle.kts @@ -27,7 +27,7 @@ val jnfConfig: Configuration by configurations.creating { } 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}" @@ -36,7 +36,7 @@ tasks.jar { jnfConfig.asFileTree.forEach { from(zipTree(it)) { into("$nativeResourcePath/JavaNativeFoundation.framework") - include("Versions/A/JavaNativeFoundation*") + include("JavaNativeFoundation*") exclude("**/*.tbd") } } @@ -66,6 +66,9 @@ library { optimizedBinary() } linkTask.configure { + val systemFrameworks = "/System/Library/Frameworks" + val current = "Versions/Current" + val jnfName = "JavaNativeFoundation.framework" linkerArgs.addAll( "-lobjc", "-mmacosx-version-min=$minOs", // "-framework", "AppKit", @@ -74,12 +77,14 @@ library { // with the dynamic library of the framework we specifically have to add the system framework // search paths accordingly. // First try any system provided framework (this will fail on arm64): - "-rpath", "/System/Library/Frameworks", - "-rpath", "/System/Library/Frameworks/JavaVM.framework/Versions/A/Frameworks", - // Then try the jdk provided framework: - "-rpath", "@executable_path/../lib", + "-rpath", "$systemFrameworks/$jnfName/$current", + "-rpath", "$systemFrameworks/JavaVM.framework/$current/Frameworks/$jnfName/$current", + // Then try the jdk provided framework (folder layout may vary. We check multiple possibilities): + "-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: - "-rpath", "@loader_path" + "-rpath", "@loader_path/$jnfName" ) } } diff --git a/macos/src/main/java/com/github/weisj/darklaf/platform/macos/MacOSLibrary.java b/macos/src/main/java/com/github/weisj/darklaf/platform/macos/MacOSLibrary.java index aa527feb..78e46ddc 100644 --- a/macos/src/main/java/com/github/weisj/darklaf/platform/macos/MacOSLibrary.java +++ b/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 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 MacOSLibrary instance = new MacOSLibrary();