diff --git a/.github/workflows/libs.yml b/.github/workflows/libs.yml index 13c520fb..c653b501 100644 --- a/.github/workflows/libs.yml +++ b/.github/workflows/libs.yml @@ -68,10 +68,17 @@ jobs: configuration-cache-enabled: true env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Upload artifact + - name: Upload x86-64 artifact uses: actions/upload-artifact@v1 with: name: macos-x86-64 - path: macos/build/libs/main/libdarklaf-macos.dylib - - name: Print library information - run: otool -l macos/build/libs/main/libdarklaf-macos.dylib + path: macos/build/libs/main/x86-64/libdarklaf-macos.dylib + - name: Upload arm64 artifact + uses: actions/upload-artifact@v1 + with: + name: macos-arm64 + path: macos/build/libs/main/arm64/libdarklaf-macos.dylib + - name: Print x86-64 library information + run: otool -l macos/build/libs/main/x86-64/libdarklaf-macos.dylib && file macos/build/libs/main/x86-64/libdarklaf-macos.dylib + - name: Print arm64 library information + run: otool -l macos/build/libs/main/arm64/libdarklaf-macos.dylib && file macos/build/libs/main/arm64/libdarklaf-macos.dylib 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 2e5127bb..58181018 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 @@ -27,7 +27,9 @@ import com.github.weisj.darklaf.util.SystemInfo; public class MacOSLibrary extends AbstractLibrary { - private static final String PATH = "/com/github/weisj/darklaf/platform/darklaf-macos/macos-x86-64/"; + private static final String PATH = "/com/github/weisj/darklaf/platform/darklaf-macos/"; + private static final String x86_64_PATH = "macos-x86-64/"; + private static final String arm64_PATH = "macos-arm64/"; private static final String DLL_NAME = "libdarklaf-macos.dylib"; private static final MacOSLibrary instance = new MacOSLibrary(); @@ -39,8 +41,28 @@ public class MacOSLibrary extends AbstractLibrary { super(PATH, DLL_NAME, LogUtil.getLogger(MacOSLibrary.class)); } + private String getArm64Path() { + return super.getPath() + arm64_PATH; + } + + private String getX64Path() { + return super.getPath() + x86_64_PATH; + } + + + @Override + protected String getPath() { + if (SystemInfo.isX86Compatible && SystemInfo.isX64) { + return getX64Path(); + } else if (SystemInfo.isM1) { + return getArm64Path(); + } else { + throw new IllegalStateException("Unsupported arch"); + } + } + @Override protected boolean canLoad() { - return (SystemInfo.isX86Compatible && SystemInfo.isX64) && SystemInfo.isMacOSYosemite; + return ((SystemInfo.isX86Compatible && SystemInfo.isX64) || SystemInfo.isM1) && SystemInfo.isMacOSYosemite; } } diff --git a/windows/src/main/java/com/github/weisj/darklaf/platform/windows/WindowsLibrary.java b/windows/src/main/java/com/github/weisj/darklaf/platform/windows/WindowsLibrary.java index 12353fe4..25185c1a 100644 --- a/windows/src/main/java/com/github/weisj/darklaf/platform/windows/WindowsLibrary.java +++ b/windows/src/main/java/com/github/weisj/darklaf/platform/windows/WindowsLibrary.java @@ -56,7 +56,7 @@ public class WindowsLibrary extends AbstractLibrary { } else if (SystemInfo.isX64) { return getX64Path(); } else { - return super.getPath(); + throw new IllegalStateException("Unsupported arch"); } }