Skip to content
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

Better cross compile #163

Draft
wants to merge 21 commits into
base: master
Choose a base branch
from
29 changes: 13 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ jobs:
strategy:
matrix:
include:
- os: windows-2019
name: win-x86
param: -x86
- os: windows-2019
name: win-x64
param: -x64
- os: windows-2019
name: win-arm64
param: -arm64
# - os: windows-2019
# name: win-x86
# param: -x86
# - os: windows-2019
# name: win-x64
# param: -x64
# - os: windows-2019
# name: win-arm64
# param: -arm64
- os: ubuntu-24.04
name: linux-x64
- os: ubuntu-24.04
Expand All @@ -39,10 +39,10 @@ jobs:
name: linux-musl-arm
- os: ubuntu-24.04
name: linux-musl-arm64
- os: macos-13
name: osx-x64
- os: macos-13
name: osx-arm64
# - os: macos-13
# name: osx-x64
# - os: macos-13
# name: osx-arm64
fail-fast: false
steps:
- name: Checkout
Expand All @@ -55,9 +55,6 @@ jobs:
- name: Build macOS
if: runner.os == 'macOS'
run: ./build.libgit2.sh
- name: Setup QEMU
if: matrix.name == 'linux-musl-arm' || matrix.name == 'linux-musl-arm64'
run: docker run --rm --privileged multiarch/qemu-user-static:register --reset
- name: Build Linux
if: runner.os == 'Linux'
run: ./dockerbuild.sh
Expand Down
16 changes: 13 additions & 3 deletions Dockerfile.linux-musl
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
ARG ARCH='amd64'
FROM multiarch/alpine:${ARCH}-v3.13
RUN apk add --no-cache bash build-base cmake
FROM --platform=$BUILDPLATFORM tonistiigi/xx AS xx

FROM --platform=$BUILDPLATFORM alpine

COPY --from=xx / /

RUN apk add cmake clang lld bash build-base

WORKDIR /nativebinaries
COPY . /nativebinaries/

ARG TARGETPLATFORM
RUN xx-apk add musl-dev gcc pkgconf

RUN xx-info env
RUN xx-clang --setup-target-triple

CMD ["/bin/bash", "-c", "./build.libgit2.sh"]
1 change: 1 addition & 0 deletions build.libgit2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ cmake -DCMAKE_BUILD_TYPE:STRING=Release \
-DCMAKE_OSX_ARCHITECTURES=$OSXARCHITECTURE \
-DUSE_HTTPS=$USEHTTPS \
-DUSE_BUNDLED_ZLIB=ON \
$(xx-clang --print-cmake-defines) \
..
cmake --build .

Expand Down
4 changes: 2 additions & 2 deletions dockerbuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ else
dockerfile="Dockerfile.linux"
fi

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

docker run -t -e RID=$RID --name=$RID $RID
docker run -t -e RID=$RID --name=$RID --platform=linux/$arch $RID

docker cp $RID:/nativebinaries/nuget.package/runtimes nuget.package

Expand Down