Skip to content

Commit

Permalink
build: 🤖 switch to use musl-cross instead of musl.cc
Browse files Browse the repository at this point in the history
  • Loading branch information
abcfy2 committed Nov 4, 2024
1 parent 48f6d86 commit 37e7c79
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 28 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/build_and_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,17 @@ jobs:

static-build:
runs-on: ubuntu-latest
container: "abcfy2/muslcc-toolchain-ubuntu:${{ matrix.cross_host }}"
container: "ghcr.io/abcfy2/musl-cross-toolchain-ubuntu:${{ matrix.cross_host }}"
strategy:
fail-fast: false
matrix:
cross_host:
- arm-linux-musleabi
- aarch64-linux-musl
- mips-linux-musl
- mipsel-linux-musl
- mips64-linux-musl
- x86_64-linux-musl
- arm-unknown-linux-musleabi
- aarch64-unknown-linux-musl
- mips-unknown-linux-musl
- mipsel-unknown-linux-musl
- mips64-unknown-linux-musl
- x86_64-unknown-linux-musl
- x86_64-w64-mingw32
- i686-w64-mingw32
use_libressl: [0, 1]
Expand Down Expand Up @@ -86,9 +86,9 @@ jobs:
run: |
apt install -y zip
if [ x"${USE_LIBRESSL}" = x"1" ]; then
ARCHIVE_NAME="aria2-${CROSS_HOST}_libressl_static.zip"
ARCHIVE_NAME="aria2-${CROSS_HOST//-unknown/}_libressl_static.zip"
else
ARCHIVE_NAME="aria2-${CROSS_HOST}_static.zip"
ARCHIVE_NAME="aria2-${CROSS_HOST//-unknown/}_static.zip"
fi
echo "ARCHIVE_NAME=${ARCHIVE_NAME}" >> $GITHUB_ENV
zip -j9v "/tmp/${ARCHIVE_NAME}" "${GITHUB_WORKSPACE}"/aria2c*
Expand Down
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,20 @@ Requirements:
- docker
```sh
docker run --rm -v `pwd`:/build abcfy2/muslcc-toolchain-ubuntu:${CROSS_HOST} /build/build.sh
docker run --rm -v `pwd`:/build abcfy2/musl-cross-toolchain-ubuntu:${CROSS_HOST} /build/build.sh
```
All avaliable `CROSS_HOST` can be found in [Tags](https://hub.docker.com/r/abcfy2/muslcc-toolchain-ubuntu/tags) page.
All avaliable `CROSS_HOST` can be found in [Tags](https://hub.docker.com/r/abcfy2/musl-cross-toolchain-ubuntu/tags) page.
**NOTE**: Currently I only tested these tags:
- arm-linux-musleabi
- aarch64-linux-musl
- mips-linux-musl
- mipsel-linux-musl
- mips64-linux-musl
- x86_64-linux-musl
- arm-unknown-linux-musleabi
- aarch64-unknown-linux-musl
- mips-unknown-linux-musl
- mipsel-unknown-linux-musl
- mips64-unknown-linux-musl
- x86_64-unknown-linux-musl
- i686-unknown-linux-musl
- x86_64-w64-mingw32
- i686-w64-mingw32
Expand Down
31 changes: 20 additions & 11 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,34 +1,40 @@
#!/bin/bash -e

# This scrip is for static cross compiling
# Please run this scrip in docker image: abcfy2/muslcc-toolchain-ubuntu:${CROSS_HOST}
# E.g: docker run --rm -v `git rev-parse --show-toplevel`:/build abcfy2/muslcc-toolchain-ubuntu:arm-linux-musleabi /build/build.sh
# Please run this scrip in docker image: abcfy2/musl-cross-toolchain-ubuntu:${CROSS_HOST}
# E.g: docker run --rm -v `git rev-parse --show-toplevel`:/build abcfy2/musl-cross-toolchain-ubuntu:arm-unknown-linux-musleabi /build/build.sh
# Artifacts will copy to the same directory.

set -o pipefail

# value from: https://musl.cc/ (without -cross or -native)
# export CROSS_HOST="${CROSS_HOST:-arm-linux-musleabi}"
# value from: https://hub.docker.com/repository/docker/abcfy2/musl-cross-toolchain-ubuntu/tags
# export CROSS_HOST="${CROSS_HOST:-arm-unknown-linux-musleabi}"
# value from openssl source: ./Configure LIST
case "${CROSS_HOST}" in
arm-linux*)
arm-*linux*)
export OPENSSL_COMPILER=linux-armv4
;;
aarch64-linux*)
aarch64-*linux*)
export OPENSSL_COMPILER=linux-aarch64
;;
mips-linux* | mipsel-linux*)
mips-*linux* | mipsel-*linux*)
export OPENSSL_COMPILER=linux-mips32
;;
mips64-linux*)
mips64-*linux*)
export OPENSSL_COMPILER=linux64-mips64
;;
x86_64-linux*)
x86_64-*linux*)
export OPENSSL_COMPILER=linux-x86_64
;;
s390x-linux*)
i?86-*linux*)
export OPENSSL_COMPILER=linux-x86
;;
s390x-*linux*)
export OPENSSL_COMPILER=linux64-s390x
;;
loongarch64-*linux*)
export OPENSSL_COMPILER=linux64-loongarch64
;;
*)
export OPENSSL_COMPILER=gcc
;;
Expand Down Expand Up @@ -114,6 +120,9 @@ case "${TARGET_ARCH}" in
"arm"*)
TARGET_ARCH=arm
;;
i?86*)
TARGET_ARCH=i386
;;
esac
case "${TARGET_HOST}" in
*"mingw"*)
Expand Down Expand Up @@ -485,7 +494,7 @@ build_aria2

get_build_info
# mips test will hang, I don't know why. So I just ignore test failures.
# test_build
test_build

# get release
cp -fv "${CROSS_PREFIX}/bin/"aria2* "${SELF_DIR}"

0 comments on commit 37e7c79

Please sign in to comment.