Browse Source

Remove dependency on JavaNativeFoundation framework

jnf_util_static v3.0.0-jnf-SNAPSHOT
Jannis Weis 3 years ago
parent
commit
b407db478c
No known key found for this signature in database
GPG Key ID: 7C9D8D4B558049AB
  1. 1
      gradle.properties
  2. 39
      macos/build.gradle.kts
  3. 12
      macos/src/main/java/com/github/weisj/darklaf/platform/macos/MacOSLibrary.java
  4. 1
      settings.gradle.kts

1
gradle.properties

@ -37,7 +37,6 @@ javaxAnnotations.version = 1.3.2
# MacOS Frameworks # MacOS Frameworks
macOSFramework.version = latest.release macOSFramework.version = latest.release
javaNativeFoundation.version = 1.1.1
# Test libraries # Test libraries
junit.version = 5.6.2 junit.version = 5.6.2

39
macos/build.gradle.kts

@ -13,28 +13,8 @@ moduleInfo {
stubModule("darklaf.platform.preferences") stubModule("darklaf.platform.preferences")
} }
val jnfConfig: Configuration by configurations.creating {
attributes {
attribute(Attribute.of("dev.nokee.architecture", String::class.java), "arm64")
}
}
dependencies {
jnfConfig(macOsFrameworks.javaNativeFoundation)
}
val nativeResourcePath = "com/github/weisj/darklaf/platform/${project.name}" val nativeResourcePath = "com/github/weisj/darklaf/platform/${project.name}"
tasks.jar {
jnfConfig.asFileTree.forEach {
from(zipTree(it)) {
into("$nativeResourcePath/JavaNativeFoundation.framework")
include("JavaNativeFoundation*")
exclude("**/*.tbd")
}
}
}
library { library {
dependencies { dependencies {
jvmImplementation(projects.darklafThemeSpec) jvmImplementation(projects.darklafThemeSpec)
@ -44,7 +24,6 @@ library {
jvmImplementation(projects.darklafPlatformDecorations) jvmImplementation(projects.darklafPlatformDecorations)
nativeLibImplementation(macOsFrameworks.appKit) nativeLibImplementation(macOsFrameworks.appKit)
nativeLibImplementation(macOsFrameworks.cocoa) nativeLibImplementation(macOsFrameworks.cocoa)
nativeLibImplementation(macOsFrameworks.javaNativeFoundation)
} }
targetMachines.addAll(machines.macOS.x86_64, machines.macOS.architecture("arm64")) targetMachines.addAll(machines.macOS.x86_64, machines.macOS.architecture("arm64"))
@ -59,28 +38,10 @@ library {
optimizedBinary() optimizedBinary()
} }
linkTask.configure { linkTask.configure {
val systemFrameworks = "/System/Library/Frameworks"
val versionCurrent = "Versions/Current"
val versionA = "Versions/A"
val jnfName = "JavaNativeFoundation.framework"
linkerArgs.addAll( linkerArgs.addAll(
"-lobjc", "-mmacosx-version-min=$minOs", "-lobjc", "-mmacosx-version-min=$minOs",
// "-framework", "AppKit", // "-framework", "AppKit",
// "-framework", "Cocoa", // "-framework", "Cocoa",
// The custom JNF framework specified @rpath for searching. As we aren't actually linking
// 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", "$systemFrameworks/$jnfName/$versionCurrent",
"-rpath", "$systemFrameworks/$jnfName/$versionA",
"-rpath", "$systemFrameworks/JavaVM.framework/$versionCurrent/Frameworks/$jnfName/$versionCurrent",
"-rpath", "$systemFrameworks/JavaVM.framework/$versionA/Frameworks/$jnfName/$versionA",
// Then try the jdk provided framework (folder layout may vary. We check multiple possibilities):
"-rpath", "@executable_path/../lib/$jnfName",
"-rpath", "@executable_path/../lib/$jnfName/$versionCurrent",
"-rpath", "@executable_path/../lib/$jnfName/$versionA",
// Lastly use our bundled drop-in replacement:
"-rpath", "@loader_path/$jnfName"
) )
} }
} }

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

@ -20,11 +20,7 @@
*/ */
package com.github.weisj.darklaf.platform.macos; package com.github.weisj.darklaf.platform.macos;
import java.util.Collections;
import java.util.List;
import com.github.weisj.darklaf.nativeutil.AbstractLibrary; import com.github.weisj.darklaf.nativeutil.AbstractLibrary;
import com.github.weisj.darklaf.nativeutil.NativeUtil;
import com.github.weisj.darklaf.platform.SystemInfo; import com.github.weisj.darklaf.platform.SystemInfo;
import com.github.weisj.darklaf.util.LogUtil; import com.github.weisj.darklaf.util.LogUtil;
@ -34,8 +30,6 @@ public class MacOSLibrary extends AbstractLibrary {
private static final String x86_64_PATH = PATH + "/libdarklaf-macos-x86-64.dylib"; private static final String x86_64_PATH = PATH + "/libdarklaf-macos-x86-64.dylib";
private static final String arm64_PATH = PATH + "/libdarklaf-macos-arm64.dylib"; private static final String arm64_PATH = PATH + "/libdarklaf-macos-arm64.dylib";
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(); private static final MacOSLibrary instance = new MacOSLibrary();
public static MacOSLibrary get() { public static MacOSLibrary get() {
@ -70,12 +64,6 @@ public class MacOSLibrary extends AbstractLibrary {
} }
} }
@Override
protected List<NativeUtil.Resource> getResourcePaths() {
return Collections.singletonList(
new NativeUtil.Resource(FRAMEWORK_PATH, FRAMEWORK_TARGET_PATH));
}
@Override @Override
protected boolean canLoad() { protected boolean canLoad() {
return ((SystemInfo.isX86Compatible && SystemInfo.isX64) || SystemInfo.isM1) && SystemInfo.isMacOSYosemite; return ((SystemInfo.isX86Compatible && SystemInfo.isX64) || SystemInfo.isM1) && SystemInfo.isMacOSYosemite;

1
settings.gradle.kts

@ -41,7 +41,6 @@ dependencyResolutionManagement {
idv("nullabilityAnnotations", "org.jetbrains:annotations") idv("nullabilityAnnotations", "org.jetbrains:annotations")
} }
create("macOsFrameworks") { create("macOsFrameworks") {
idv("javaNativeFoundation", "com.github.weisj:java-native-foundation")
idv("appKit", "dev.nokee.framework:AppKit", "macOSFramework") idv("appKit", "dev.nokee.framework:AppKit", "macOSFramework")
idv("cocoa", "dev.nokee.framework:Cocoa", "macOSFramework") idv("cocoa", "dev.nokee.framework:Cocoa", "macOSFramework")
} }

Loading…
Cancel
Save