Skip to content

Support cross-building for ARM64 #91

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ matrix:
env: RID=alpine.3.9-x64
- os: osx
env: RID=osx
- os: linux
dist: trusty
sudo: required
env: RID=ubuntu.16.04-arm64
- os: linux
dist: trusty
sudo: required
env: RID=debian-arm64

branches:
only:
Expand Down
6 changes: 6 additions & 0 deletions CMakeLists.arm64.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
SET(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR aarch64)
set(TARGET_ABI "linux-gnu")

SET(CMAKE_C_COMPILER ${CMAKE_SYSTEM_PROCESSOR}-${TARGET_ABI}-gcc)
SET(CMAKE_CXX_COMPILER ${CMAKE_SYSTEM_PROCESSOR}-${TARGET_ABI}-g++)
12 changes: 12 additions & 0 deletions Dockerfile.debian-arm64
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM debian:9
WORKDIR /nativebinaries
COPY . /nativebinaries/

RUN dpkg --add-architecture arm64

RUN apt update \
&& apt -y install cmake pkg-config \
crossbuild-essential-arm64 \
libssl-dev:arm64

CMD ["/bin/bash", "-c", "./build.libgit2.sh"]
17 changes: 17 additions & 0 deletions Dockerfile.ubuntu.16.04-arm64
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM ubuntu:16.04

WORKDIR /nativebinaries
COPY . /nativebinaries/

RUN dpkg --add-architecture arm64 \
&& sed -i 's/deb/deb [arch=amd64]/g' /etc/apt/sources.list \
&& echo "deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports xenial main universe" > /etc/apt/sources.list.d/arm64.list \
&& echo "deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports xenial-updates main universe" > /etc/apt/sources.list.d/arm64-updates.list

RUN apt update \
&& apt -y install cmake pkg-config \
crossbuild-essential-arm64 \
pkg-config-aarch64-linux-gnu \
libssl-dev:arm64

CMD ["/bin/bash", "-c", "./build.libgit2.sh"]
5 changes: 5 additions & 0 deletions build.libgit2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,18 @@ pushd libgit2/build

export _BINPATH=`pwd`

if [[ $RID == *arm64 ]]; then
export TOOLCHAIN_FILE=/nativebinaries/CMakeLists.arm64.txt
fi

cmake -DCMAKE_BUILD_TYPE:STRING=Release \
-DBUILD_CLAR:BOOL=OFF \
-DUSE_SSH=OFF \
-DENABLE_TRACE=ON \
-DLIBGIT2_FILENAME=git2-$SHORTSHA \
-DCMAKE_OSX_ARCHITECTURES="i386;x86_64" \
-DUSE_BUNDLED_ZLIB=ON \
-DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN_FILE} \
..
cmake --build .

Expand Down