Browse Source

Actions+Native: Upload arm64 library on macOS.

Upload the arm64 library on macos so it can be consumed by the build on other platforms. We also print the file information to check that the produced library really targets the correct arch.
jxlayer
weisj 3 years ago committed by Jannis Weis
parent
commit
e174ff15ca
  1. 15
      .github/workflows/libs.yml
  2. 26
      macos/src/main/java/com/github/weisj/darklaf/platform/macos/MacOSLibrary.java
  3. 2
      windows/src/main/java/com/github/weisj/darklaf/platform/windows/WindowsLibrary.java

15
.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

26
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;
}
}

2
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");
}
}

Loading…
Cancel
Save