Skip to content

Commit 65b4bba

Browse files
committed
Adds arm64 support for MacOS through universal binaries
1 parent da7049e commit 65b4bba

1 file changed

Lines changed: 62 additions & 24 deletions

File tree

.github/workflows/ci.yml

Lines changed: 62 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ jobs:
1919
java-version: '8'
2020
cache: 'maven'
2121

22+
- name: Prepare resources folder
23+
run: mkdir src/main/resources
24+
2225
- name: Build c-blosc (Windows)
2326
if: ${{ matrix.os == 'windows' }}
2427
run: |
@@ -28,18 +31,72 @@ jobs:
2831
cmake -G "MinGW Makefiles" .. -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_BUILD_TYPE=Release
2932
cmake --build . -j8 --config Release
3033
31-
- name: Build c-blosc (Linux, Mac)
32-
if: ${{ matrix.os != 'windows' }}
34+
- name: Build bloscjni (Windows)
35+
if: ${{ matrix.os == 'windows' }}
36+
shell: bash
37+
run: |
38+
cd bloscjni
39+
x86_64-w64-mingw32-gcc \
40+
-I"$JAVA_HOME\\include" -I"$JAVA_HOME\\include\\win32" -O3 \
41+
-shared -o ..\\src\\main\\resources\\libbloscjni.dll \
42+
bloscjni.c ..\\c-blosc\\build\\blosc\\libblosc.a
43+
44+
- name: Build c-blosc (Mac arm64)
45+
if: ${{ matrix.os == 'macos' }}
46+
run: |
47+
cd c-blosc
48+
mkdir build-arm64
49+
cd build-arm64
50+
cmake .. \
51+
-DCMAKE_OSX_ARCHITECTURES=arm64 \
52+
-DCMAKE_OSX_DEPLOYMENT_TARGET=10.9 \
53+
-DDEACTIVATE_AVX2=ON \
54+
-DDEACTIVATE_SSE2=ON \
55+
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
56+
-DCMAKE_BUILD_TYPE=Release
57+
cmake --build . -j8 --config Release --target blosc_static
58+
59+
- name: Build c-blosc (Mac x86_64)
60+
if: ${{ matrix.os == 'macos' }}
61+
run: |
62+
cd c-blosc
63+
mkdir build-x86_64
64+
cd build-x86_64
65+
cmake .. \
66+
-DCMAKE_OSX_DEPLOYMENT_TARGET=10.9 \
67+
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
68+
-DCMAKE_BUILD_TYPE=Release
69+
cmake --build . -j8 --config Release --target blosc_static
70+
71+
- name: Build bloscjni (Mac universal)
72+
if: ${{ matrix.os == 'macos' }}
73+
run: |
74+
cd bloscjni
75+
cc \
76+
-I"$JAVA_HOME/include" -I"$JAVA_HOME/include/darwin" \
77+
--target=arm64-apple-macos10.9 \
78+
-dynamiclib -o ../src/main/resources/libbloscjni-arm64.dylib -O3 \
79+
bloscjni.c ../c-blosc/build-arm64/blosc/libblosc.a
80+
cc \
81+
-I"$JAVA_HOME/include" -I"$JAVA_HOME/include/darwin" \
82+
--target=x86_64-apple-macos10.9 \
83+
-dynamiclib -o ../src/main/resources/libbloscjni-x86_64.dylib -O3 \
84+
bloscjni.c ../c-blosc/build-x86_64/blosc/libblosc.a
85+
lipo -create \
86+
-output ../src/main/resources/libbloscjni.dylib \
87+
../src/main/resources/libbloscjni-arm64.dylib \
88+
../src/main/resources/libbloscjni-x86_64.dylib
89+
rm ../src/main/resources/libbloscjni-*.dylib
90+
91+
- name: Build c-blosc (Linux)
92+
if: ${{ matrix.os == 'ubuntu' }}
3393
run: |
3494
cd c-blosc
3595
mkdir build
3696
cd build
3797
cmake .. -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_BUILD_TYPE=Release
3898
cmake --build . -j8 --config Release
3999
40-
- name: Prepare resources folder
41-
run: mkdir src/main/resources
42-
43100
- name: Build bloscjni (Linux)
44101
if: ${{ matrix.os == 'ubuntu' }}
45102
run: |
@@ -49,25 +106,6 @@ jobs:
49106
-shared -lc -fPIC -o ../src/main/resources/libbloscjni.so -O3 \
50107
bloscjni.c ../c-blosc/build/blosc/libblosc.a
51108
52-
- name: Build bloscjni (Mac)
53-
if: ${{ matrix.os == 'macos' }}
54-
run: |
55-
cd bloscjni
56-
gcc \
57-
-I"$JAVA_HOME/include" -I"$JAVA_HOME/include/darwin" \
58-
-dynamiclib -o ../src/main/resources/libbloscjni.dylib -O3 \
59-
bloscjni.c ../c-blosc/build/blosc/libblosc.a
60-
61-
- name: Build bloscjni (Windows)
62-
if: ${{ matrix.os == 'windows' }}
63-
shell: bash
64-
run: |
65-
cd bloscjni
66-
x86_64-w64-mingw32-gcc \
67-
-I"$JAVA_HOME\\include" -I"$JAVA_HOME\\include\\win32" -O3 \
68-
-shared -o ..\\src\\main\\resources\\libbloscjni.dll \
69-
bloscjni.c ..\\c-blosc\\build\\blosc\\libblosc.a
70-
71109
- name: Build blosc-java
72110
run: mvn compile
73111

0 commit comments

Comments
 (0)