Skip to content

fix: make sure each stuffs is ready #84

fix: make sure each stuffs is ready

fix: make sure each stuffs is ready #84

Workflow file for this run

name: <Test> Cross Compiling
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
cross:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ]
platform: [ windows, linux, macos, android ]
build_type: [ MinSizeRel, Debug ]
c_compiler: [ gcc, clang, cl ]
arch: [ x86_64, aarch64, arm64, x86, arm64-v8a, armeabi-v7a ]
exclude:
# Linux (keep: x86_64, aarch64)
- platform: linux
arch: arm64-v8a
- platform: linux
arch: armeabi-v7a
- platform: linux
arch: x86
- platform: linux
arch: arm64
# macOS (keep: x86_64, arm64)
- platform: macos
arch: arm64-v8a
- platform: macos
arch: armeabi-v7a
- platform: macos
arch: x86
- platform: macos
arch: aarch64
# Windows (keep: x86_64, x86, arm64)
- platform: windows
arch: arm64-v8a
- platform: windows
arch: armeabi-v7a
- platform: windows
arch: aarch64
# Android (keep: x86_64, x86, arm64-v8a, armeabi-v7a)
- platform: android
arch: aarch64
- platform: android
arch: arm64
# Exclude unsupported compiler combinations
- os: windows-latest
c_compiler: gcc
- os: windows-latest
c_compiler: clang
- os: ubuntu-latest
c_compiler: cl
- os: macos-latest
c_compiler: gcc
- os: macos-latest
c_compiler: cl
# Exclude unsupported compiler platform (cross need heavy config cannot be auto)
- os: windows-latest
platform: linux
- os: windows-latest
platform: macos
- os: ubuntu-latest
platform: windows
- os: ubuntu-latest
platform: macos
- os: macos-latest
platform: windows
- os: macos-latest
platform: linux
steps:
- uses: actions/checkout@v4
- name: Set reusable strings
id: strings
shell: bash
run: |
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
- name: Install dependencies on Linux
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y ninja-build gcc g++
if [[ "${{ matrix.platform }}" == "macos" ]]; then
echo "Target platform is macOS."
elif [[ "${{ matrix.platform }}" == "windows" ]]; then
echo "Target platform is Windows."
sudo apt-get install mingw-w64
elif [[ "${{ matrix.platform }}" == "linux" ]]; then
echo "Target platform is Linux"
if [[ "${{ matrix.arch }}" == "aarch64" ]]; then
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
elif [[ "${{ matrix.arch }}" == "arm64" ]]; then
sudo apt-get install -y gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf
elif [[ "${{ matrix.arch }}" == "x86" ]]; then
sudo apt-get install -y gcc-multilib g++-multilib
elif [[ "${{ matrix.arch }}" == "arm64-v8a" ]]; then
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
elif [[ "${{ matrix.arch }}" == "armeabi-v7a" ]]; then
sudo apt-get install -y gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf
fi
elif [[ "${{ matrix.platform }}" == "android" ]]; then
echo "Target platform is Android"
fi
- name: Install dependencies on macOS
if: runner.os == 'macOS'
run: |
brew install ninja
brew install llvm
if [[ "${{ matrix.platform }}" == "macos" ]]; then
echo "Target platform is macOS."
elif [[ "${{ matrix.platform }}" == "windows" ]]; then
echo "Target platform is Windows."
brew install mingw-w64
brew install gcc
elif [[ "${{ matrix.platform }}" == "linux" ]]; then
echo "Target platform is Linux"
brew tap messense/macos-cross-toolchains
if [[ "${{ matrix.arch }}" == "aarch64" ]]; then
brew install aarch64-unknown-linux-gnu
elif [[ "${{ matrix.arch }}" == "arm64" ]]; then
brew install arm-unknown-linux-gnueabihf
elif [[ "${{ matrix.arch }}" == "x86" ]]; then
brew install i686-unknown-linux-gnu
elif [[ "${{ matrix.arch }}" == "x86_64" ]]; then
brew install x86_64-unknown-linux-gnu
elif [[ "${{ matrix.arch }}" == "arm64-v8a" ]]; then
brew install aarch64-unknown-linux-gnu
elif [[ "${{ matrix.arch }}" == "armeabi-v7a" ]]; then
brew install armv7-unknown-linux-gnueabihf
fi
elif [[ "${{ matrix.platform }}" == "android" ]]; then
echo "Target platform is Android."
fi
- name: Install dependencies on Windows
if: runner.os == 'Windows'
shell: bash
run: |
choco install ninja
choco install llvm
choco install mingw
if [[ ${{ matrix.platform }} == 'macos' ]]; then
echo "Target platform is macOS."
elif [[ ${{ matrix.platform }} == 'windows' ]]; then
echo "Target platform is Windows."
elif [[ ${{ matrix.platform }} == 'linux' ]]; then
echo "Target platform is Linux."
if [[ ${{ matrix.arch }} == 'x86_64' ]]; then
choco install mingw-w64-x86_64-linux-gnu
setx CC x86_64-linux-gnu-gcc
setx CXX x86_64-linux-gnu-g++
elif [[ ${{ matrix.arch }} == 'aarch64' ]]; then
choco install mingw-w64-aarch64-linux-gnu
setx CC aarch64-linux-gnu-gcc
setx CXX aarch64-linux-gnu-g++
elif [[ ${{ matrix.arch }} == 'arm64' ]]; then
choco install mingw-w64-arm-linux-gnueabihf
setx CC arm-linux-gnueabihf-gcc
setx CXX arm-linux-gnueabihf-g++
elif [[ ${{ matrix.arch }} == 'x86' ]]; then
choco install mingw-w64-i686-linux-gnu
setx CC i686-linux-gnu-gcc
setx CXX i686-linux-gnu-g++
elif [[ ${{ matrix.arch }} == 'arm64-v8a' ]]; then
choco install mingw-w64-aarch64-linux-gnu
setx CC aarch64-linux-gnu-gcc
setx CXX aarch64-linux-gnu-g++
elif [[ ${{ matrix.arch }} == 'armeabi-v7a' ]]; then
choco install mingw-w64-arm-linux-gnueabihf
setx CC arm-linux-gnueabihf-gcc
setx CXX arm-linux-gnueabihf-g++
fi
elif [[ ${{ matrix.platform }} == 'android' ]]; then
echo "Target platform is Android."
fi
- name: Set up Android SDK and NDK
if: matrix.platform == 'android'
uses: android-actions/setup-android@v2
with:
api-level: 27
ndk-version: 26.1.10909125
cmake-version: 3.29.5
- name: Run auto_build.sh
shell: bash
run: |
if [ "${{ matrix.platform }}" == "android" ]; then
bash ./auto_build.sh --platform android \
--cmake "cmake" \
--ninja "ninja" \
--build-type ${{ matrix.build_type }} \
--arch-abi ${{ matrix.arch }} \
--jobs 4 \
--android-ndk "$ANDROID_NDK_HOME" \
--android-ver 27 \
-c
else
bash ./auto_build.sh --platform ${{ matrix.platform }} \
--cmake "cmake" \
--ninja "ninja" \
--build-type ${{ matrix.build_type }} \
--arch-abi ${{ matrix.arch }} \
--jobs 4 \
-c
fi
# - name: Test
# working-directory: ${{ steps.strings.outputs.build-output-dir }}
# run: ctest --build-config ${{ matrix.build_type }}