Skip to content

Commit

Permalink
armv7l-linux-gnueabihf precompile
Browse files Browse the repository at this point in the history
Signed-off-by: Cocoa <[email protected]>
  • Loading branch information
cocoa-xu committed Oct 10, 2024
1 parent 06401ab commit dda08fc
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 1 deletion.
14 changes: 14 additions & 0 deletions .github/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh

set -x

DOCKER_PLATFORM=$1
DOCKER_IMAGE=$2
OTP_VERSION=$3
ELIXIR_VERSION=$4
TARGET_TRIPLET=$5

sudo docker run --privileged --network=host --rm --platform="${DOCKER_PLATFORM}" -v $(pwd):/work "${DOCKER_IMAGE}" \
sh -c "chmod a+x /work/do-build.sh && /work/do-build.sh ${OTP_VERSION} ${ELIXIR_VERSION} ${TARGET_TRIPLET}"

sudo chmod -R a+r ./cache
47 changes: 47 additions & 0 deletions .github/do-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/sh

set -x

OTP_VERSION=$1
ELIXIR_VERSION=$2
TARGET_TRIPLET=$3

OTP_MAIN_VER="${OTP_VERSION%%.*}"
export DEBIAN_FRONTEND=noninteractive
export LANG=en_US.UTF-8 LANGUAGE=en_US:en LC_ALL=en_US.UTF-8

case $TARGET_TRIPLET in
armv7l-linux-gnueabihf )
apt-get update && \
apt-get install -y libncurses-dev libssl-dev make cmake build-essential gcc g++ curl unzip locales locales-all && \
sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && \
locale-gen
;;
*)
echo "Unknown TRIPLET: ${TARGET_TRIPLET}"
exit 1
;;
esac

ROOTDIR="/work"
OTP_ROOTDIR="${ROOTDIR}/.tools/otp"
ELIXIR_DIR="${ROOTDIR}/.tools/elixir"
export PATH="${OTP_ROOTDIR}/usr/local/bin:${ELIXIR_DIR}/${ELIXIR_VERSION}/bin:${PATH}"
export ERL_ROOTDIR="${OTP_ROOTDIR}/usr/local/lib/erlang"
export ELIXIR_MAKE_CACHE_DIR="${ROOTDIR}/cache"
export CC_PRECOMPILER_PRECOMPILE_ONLY_LOCAL="true"

mkdir -p "${OTP_ROOTDIR}" && \
mkdir -p "${ELIXIR_DIR}" && \
mkdir -p "${ELIXIR_MAKE_CACHE_DIR}" && \
cd "${OTP_ROOTDIR}" && \
curl -fSL "https://github.com/cocoa-xu/otp-build/releases/download/v${OTP_VERSION}/otp-${TARGET_TRIPLET}.tar.gz" -o "otp-${TARGET_TRIPLET}.tar.gz" && \
tar -xzf "otp-${TARGET_TRIPLET}.tar.gz" && \
cd "${ELIXIR_DIR}" && \
curl -fSL "https://github.com/elixir-lang/elixir/releases/download/v${ELIXIR_VERSION}/elixir-otp-${OTP_MAIN_VER}.zip" -o "elixir-otp-${OTP_MAIN_VER}.zip" && \
unzip -o -q "elixir-otp-${OTP_MAIN_VER}.zip" -d "${ELIXIR_VERSION}" && \
mix local.hex --force && \
mix local.rebar --force && \
cd "${ROOTDIR}" && \
mix deps.get && \
mix elixir_make.precompile
40 changes: 39 additions & 1 deletion .github/workflows/linux-precompile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,45 @@ permissions:
contents: write

jobs:
armv7l-linux-gnueabihf:
runs-on: ubuntu-latest
env:
TARGET: armv7l-linux-gnueabihf
DOCKER_PLATFORM: linux/arm/v7
DOCKER_IMAGE: ubuntu:20.04
strategy:
matrix:
job:
- {otp: "27.1.1", elixir: "1.17.3"}
- {otp: "25.3.2.14", elixir: "1.16.0"}

name: Linux armv7l - OTP ${{ matrix.job.otp }} - Elixir ${{ matrix.job.elixir }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install binfmt
run: |
sudo apt update
sudo apt install -y binfmt-support qemu-user-static
- name: Pull docker image
run: |
sudo docker pull --platform=${{ env.DOCKER_PLATFORM }} ${{ env.DOCKER_IMAGE }}
- name: Run docker container
run: |
cp .github/build.sh ./
cp .github/do-build.sh ./
bash ./build.sh ${{ env.DOCKER_PLATFORM }} ${{ env.DOCKER_IMAGE }} "${{ matrix.job.otp }}" "${{ matrix.job.elixir }}" "${{ env.TARGET }}"
- uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
cache/*.tar.gz
precompile:
runs-on: ubuntu-20.04
env:
Expand Down Expand Up @@ -44,7 +83,6 @@ jobs:
if: matrix.arch == 'x86_64'
run: |
sudo apt-get install -y gcc-i686-linux-gnu g++-i686-linux-gnu \
gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf \
gcc-powerpc64le-linux-gnu g++-powerpc64le-linux-gnu \
gcc-s390x-linux-gnu g++-s390x-linux-gnu
Expand Down

0 comments on commit dda08fc

Please sign in to comment.