Skip to content

Commit b5fdc59

Browse files
authored
Cross compile to Mac arm64 (#89)
* Cross compile to Mac arm64 * Docs changes for M1
1 parent 6776010 commit b5fdc59

File tree

3 files changed

+45
-7
lines changed

3 files changed

+45
-7
lines changed

CHANGELOG.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,25 @@ file [H3Core.java](./src/main/java/com/uber/h3core/H3Core.java), and support
77
for the Linux x64 and Darwin x64 platforms.
88

99
## [Unreleased]
10-
## Fixed
11-
- Fixes local build script to support Apple M1
10+
### Added
11+
- Added Apple M1 build (#89)
12+
### Fixed
13+
- Fixes local build script to support Apple M1 (#86)
1214

1315
## [3.7.1] - 2021-08-18
14-
## Fixed
16+
### Fixed
1517
- Fixes for non-English locales (#80)
1618

17-
## Changed
19+
### Changed
1820
- Updated the core library to v3.7.2. (#81)
1921

2022
## [3.7.0] - 2020-12-03
21-
## Added
23+
### Added
2224
- Area and haversine distance functions (#70)
2325
- `cellArea`
2426
- `pointDist`
2527
- `exactEdgeLength`
26-
## Changed
28+
### Changed
2729
- Updated the core library to v3.7.1. (#70)
2830

2931
## [3.6.4] - 2020-06-29

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ H3-Java provides bindings to the H3 library, which is written in C. The built ar
5454
| ---------------- | -------------
5555
| Linux | x64, x86, ARM64, ARMv5, ARMv7, MIPS, MIPSEL, PPC64LE, s390x
5656
| Windows | x64, x86
57-
| Darwin (Mac OSX) | x64
57+
| Darwin (Mac OSX) | x64, ARM64
5858
| FreeBSD | x64
5959
| Android | ARM, ARM64
6060

src/main/c/h3-java/build-h3.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,42 @@ esac
107107
mkdir -p src/main/resources/$LIBRARY_DIR
108108
cp target/h3-java-build/lib/libh3-java* src/main/resources/$LIBRARY_DIR
109109

110+
# Cross compile from Mac x64 to Mac arm64
111+
if [ "$(uname -sm)" == "Darwin x86_64" ]; then
112+
pushd target
113+
114+
mkdir -p h3-java-build-mac-arm64
115+
pushd h3-java-build-mac-arm64
116+
117+
mkdir -p build
118+
pushd build
119+
120+
cmake -DBUILD_SHARED_LIBS=OFF \
121+
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
122+
-DCMAKE_BUILD_TYPE=Release \
123+
-DCMAKE_OSX_ARCHITECTURES="arm64" \
124+
../../h3
125+
cmake --build . --target h3 --config Release
126+
H3_BUILD_ROOT="$(pwd)"
127+
128+
popd # build
129+
130+
cmake -DUSE_NATIVE_JNI=ON \
131+
-DBUILD_SHARED_LIBS=ON \
132+
"-DH3_BUILD_ROOT=$H3_BUILD_ROOT" \
133+
-DCMAKE_BUILD_TYPE=Release \
134+
-DCMAKE_OSX_ARCHITECTURES="arm64" \
135+
../../src/main/c/h3-java
136+
cmake --build . --target h3-java --config Release
137+
138+
popd # h3-java-build
139+
140+
popd # target
141+
142+
mkdir -p src/main/resources/darwin-arm64
143+
cp target/h3-java-build-mac-arm64/lib/libh3-java* src/main/resources/darwin-arm64
144+
fi
145+
110146
#
111147
# Now that H3 is downloaded, build H3-Java's native library for other platforms.
112148
#

0 commit comments

Comments
 (0)