Skip to content

Build native libs for linux-musl-arm and linux-musl-arm64 #133

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 1 commit into from
Nov 4, 2021
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
7 changes: 7 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ jobs:
name: linux-musl-x64
- os: ubuntu-20.04
name: linux-arm64
- os: ubuntu-20.04
name: linux-musl-arm
- os: ubuntu-20.04
name: linux-musl-arm64
- os: ubuntu-20.04
name: linux-arm
- os: macos-10.15
Expand All @@ -49,6 +53,9 @@ jobs:
- name: Build macOS
if: runner.os == 'macOS'
run: ./build.libgit2.sh
- name: Setup QEMU
run: docker run --rm --privileged multiarch/qemu-user-static:register --reset
if: matrix.name == 'linux-musl-arm' || matrix.name == 'linux-musl-arm64'
- name: Build Linux
if: runner.os == 'Linux'
run: ./dockerbuild.sh
Expand Down
6 changes: 0 additions & 6 deletions CMakeLists.arm.txt

This file was deleted.

6 changes: 0 additions & 6 deletions CMakeLists.arm64.txt

This file was deleted.

9 changes: 9 additions & 0 deletions Dockerfile.linux
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM multiarch/crossbuild
ARG ARCH='amd64'
ENV CROSS_TRIPLE=${ARCH}
RUN apt update && apt -y install pkg-config

WORKDIR /nativebinaries
COPY . /nativebinaries/

CMD ["/bin/bash", "-c", "./build.libgit2.sh"]
9 changes: 0 additions & 9 deletions Dockerfile.linux-arm

This file was deleted.

9 changes: 0 additions & 9 deletions Dockerfile.linux-arm64

This file was deleted.

8 changes: 8 additions & 0 deletions Dockerfile.linux-musl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
ARG ARCH='amd64'
FROM multiarch/alpine:${ARCH}-v3.12
RUN apk add --no-cache bash build-base cmake

WORKDIR /nativebinaries
COPY . /nativebinaries/

CMD ["/bin/bash", "-c", "./build.libgit2.sh"]
7 changes: 0 additions & 7 deletions Dockerfile.linux-musl-x64

This file was deleted.

9 changes: 0 additions & 9 deletions Dockerfile.linux-x64

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ the following platforms:

- Windows (x86, x64, arm64)
- macOS (x64, arm64)
- Linux (arm, arm64, x64)
- Linux (arm, arm64, x64, musl-x64, linux-musl-arm, linux-musl-arm64)

[lg2s-nb]: https://www.nuget.org/packages/LibGit2Sharp.NativeBinaries
[lg2]: https://libgit2.github.com/
Expand Down
11 changes: 0 additions & 11 deletions build.libgit2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,6 @@ pushd libgit2/build

export _BINPATH=`pwd`

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

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

cmake -DCMAKE_BUILD_TYPE:STRING=Release \
-DBUILD_CLAR:BOOL=OFF \
-DUSE_SSH=OFF \
Expand All @@ -42,7 +32,6 @@ cmake -DCMAKE_BUILD_TYPE:STRING=Release \
-DCMAKE_OSX_ARCHITECTURES=$OSXARCHITECTURE \
-DUSE_HTTPS=$USEHTTPS \
-DUSE_BUNDLED_ZLIB=ON \
-DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN_FILE} \
..
cmake --build .

Expand Down
17 changes: 16 additions & 1 deletion dockerbuild.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,23 @@
#!/bin/bash

set -e
echo "building for $RID"

docker build -t $RID -f Dockerfile.$RID .
if [[ $RID =~ arm64 ]]; then
arch="arm64"
elif [[ $RID =~ arm ]]; then
arch="armhf"
else
arch="amd64"
fi

if [[ $RID == linux-musl* ]]; then
dockerfile="Dockerfile.linux-musl"
else
dockerfile="Dockerfile.linux"
fi

docker buildx build -t $RID -f $dockerfile --build-arg ARCH=$arch .

docker run -t -e RID=$RID --name=$RID $RID

Expand Down