Skip to content

Commit

Permalink
Merge pull request #1594 from matthiasblaesing/build_mac
Browse files Browse the repository at this point in the history
Improve Testing / native libarary building for darwin/mac OS
  • Loading branch information
matthiasblaesing committed Feb 23, 2024
2 parents 7da005e + cc38576 commit 83f2fc8
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 2 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/ci.yaml
Expand Up @@ -47,3 +47,37 @@ jobs:
run: |
ant test
ant test-platform
test-m1:
runs-on: ${{ matrix.os }}
strategy:
matrix:
java: [21]
# macos-14 is documented to run on m1
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners#standard-github-hosted-runners-for-public-repositories
os: [macos-14]
# Run all tests even if one fails
fail-fast: true
name: Test JDK ${{ matrix.java }}, ${{ matrix.os }}

steps:
- uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java }}
distribution: 'zulu'
- name: Linux requirements
if: contains(matrix.os, 'ubuntu')
run: sudo apt-get -y install texinfo
- name: macOS requirements
if: contains(matrix.os, 'macos')
run: |
brew update
brew install automake --force
brew install libtool --force
brew install texinfo --force
- name: Run test
run: |
ant test
ant test-platform
42 changes: 42 additions & 0 deletions .github/workflows/native-libraries-macOS.yaml
@@ -0,0 +1,42 @@
# Build native library for mac OS
name: mac OS native libraries

on:
workflow_dispatch:

permissions:
contents: read

jobs:
build-native-darwin:
runs-on: ${{ matrix.os }}
strategy:
matrix:
java: [21]
os: [macos-latest]
name: Build native libraries for mac OS / darwin

steps:
- uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java }}
distribution: 'zulu'
- name: macOS requirements
if: contains(matrix.os, 'macos')
run: |
brew update
brew install automake --force
brew install libtool --force
- name: Build native code
run: |
ant -Dos.prefix=darwin-aarch64
ant -Dos.prefix=darwin-x86-64
- name: Upload mac OS binaries
uses: actions/upload-artifact@v4
with:
name: darwin-native
path: |
lib/native/darwin-aarch64.jar
lib/native/darwin-x86-64.jar
5 changes: 3 additions & 2 deletions contrib/platform/test/com/sun/jna/platform/mac/IOKitTest.java
Expand Up @@ -103,7 +103,8 @@ public void testMatching() {
String serialNumberViaUtil = platformExpert.getStringProperty("IOPlatformSerialNumber");
assertEquals(serialNumber, serialNumberViaUtil);

assertEquals(12, serialNumber.length());
assertTrue("Known serial number lengths are 10 and 12, was: " + serialNumber.length(),
serialNumber.length() == 12 || serialNumber.length() == 10);
// Get all the keys
dict = platformExpert.createCFProperties();
assertNotEquals(0, dict.getValueIfPresent(serialKey, null));
Expand Down Expand Up @@ -214,7 +215,7 @@ public void testIOConnect() {
int masterPort = IOKitUtil.getMasterPort();

IOService smcService = IOKitUtil.getMatchingService("AppleSMC");
assertNotNull(smcService);
assumeTrue(smcService != null); // Service is not available on github M1 runners

PointerByReference connPtr = new PointerByReference();
int taskSelf = SYS.mach_task_self();
Expand Down

0 comments on commit 83f2fc8

Please sign in to comment.