diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e5ec019f..b31288ec 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 @@ -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 diff --git a/CMakeLists.arm.txt b/CMakeLists.arm.txt deleted file mode 100644 index 4b11f14a..00000000 --- a/CMakeLists.arm.txt +++ /dev/null @@ -1,6 +0,0 @@ -SET(CMAKE_SYSTEM_NAME Linux) -set(CMAKE_SYSTEM_PROCESSOR arm) -set(TARGET_ABI "linux-gnueabihf") - -SET(CMAKE_C_COMPILER ${CMAKE_SYSTEM_PROCESSOR}-${TARGET_ABI}-gcc) -SET(CMAKE_CXX_COMPILER ${CMAKE_SYSTEM_PROCESSOR}-${TARGET_ABI}-g++) diff --git a/CMakeLists.arm64.txt b/CMakeLists.arm64.txt deleted file mode 100644 index 304ef973..00000000 --- a/CMakeLists.arm64.txt +++ /dev/null @@ -1,6 +0,0 @@ -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++) diff --git a/Dockerfile.linux b/Dockerfile.linux new file mode 100644 index 00000000..25bf7368 --- /dev/null +++ b/Dockerfile.linux @@ -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"] \ No newline at end of file diff --git a/Dockerfile.linux-arm b/Dockerfile.linux-arm deleted file mode 100644 index 9e6d6c06..00000000 --- a/Dockerfile.linux-arm +++ /dev/null @@ -1,9 +0,0 @@ -FROM debian:9 -WORKDIR /nativebinaries -COPY . /nativebinaries/ - -RUN dpkg --add-architecture armhf - -RUN apt update && apt -y install cmake pkg-config crossbuild-essential-armhf - -CMD ["/bin/bash", "-c", "./build.libgit2.sh"] diff --git a/Dockerfile.linux-arm64 b/Dockerfile.linux-arm64 deleted file mode 100644 index 239dd775..00000000 --- a/Dockerfile.linux-arm64 +++ /dev/null @@ -1,9 +0,0 @@ -FROM debian:9 -WORKDIR /nativebinaries -COPY . /nativebinaries/ - -RUN dpkg --add-architecture arm64 - -RUN apt update && apt -y install cmake pkg-config crossbuild-essential-arm64 - -CMD ["/bin/bash", "-c", "./build.libgit2.sh"] diff --git a/Dockerfile.linux-musl b/Dockerfile.linux-musl new file mode 100644 index 00000000..a3620994 --- /dev/null +++ b/Dockerfile.linux-musl @@ -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"] \ No newline at end of file diff --git a/Dockerfile.linux-musl-x64 b/Dockerfile.linux-musl-x64 deleted file mode 100644 index 07cd6f88..00000000 --- a/Dockerfile.linux-musl-x64 +++ /dev/null @@ -1,7 +0,0 @@ -FROM alpine:3.7 -WORKDIR /nativebinaries -COPY . /nativebinaries/ - -RUN apk add --no-cache bash build-base cmake - -CMD ["/bin/bash", "-c", "./build.libgit2.sh"] diff --git a/Dockerfile.linux-x64 b/Dockerfile.linux-x64 deleted file mode 100644 index dbed1ff7..00000000 --- a/Dockerfile.linux-x64 +++ /dev/null @@ -1,9 +0,0 @@ -FROM ubuntu:14.04 -WORKDIR /nativebinaries -COPY . /nativebinaries/ - -RUN apt update && apt -y install pkg-config curl make gcc build-essential - -RUN curl -L https://github.com/Kitware/CMake/releases/download/v3.15.4/cmake-3.15.4-Linux-x86_64.sh -o /tmp/cmake.sh && bash /tmp/cmake.sh --skip-license --prefix=/usr/local - -CMD ["/bin/bash", "-c", "./build.libgit2.sh"] diff --git a/README.md b/README.md index 96d856cf..29759472 100644 --- a/README.md +++ b/README.md @@ -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/ diff --git a/build.libgit2.sh b/build.libgit2.sh index 76154faa..90ed5ad6 100755 --- a/build.libgit2.sh +++ b/build.libgit2.sh @@ -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 \ @@ -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 . diff --git a/dockerbuild.sh b/dockerbuild.sh index ae5018b4..9dad1dc4 100755 --- a/dockerbuild.sh +++ b/dockerbuild.sh @@ -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