Skip to content

fix: dml version

fix: dml version #69

Workflow file for this run

name: build
on:
push:
workflow_dispatch:
inputs:
use-cache:
type: boolean
default: true
description: Use binary cache
jobs:
build-maadeps:
strategy:
matrix:
os: [ubuntu, windows, macos]
arch: [x64, arm64]
include:
- os: ubuntu
arch: arm64-android
- os: ubuntu
arch: x64-android
fail-fast: false
defaults:
run:
shell: bash
runs-on: ${{ matrix.os }}-latest
timeout-minutes: 720
steps:
- name: Windows runner hack
if: runner.os == 'Windows'
shell: cmd
run: |
dir d:\a
cd ..
mkdir C:\MaaDeps
rmdir MaaDeps
mklink /j MaaDeps C:\MaaDeps
dism /Online /Disable-Feature /FeatureName:Windows-Defender /Remove /NoRestart /Quiet
cd .
- name: Windows runner hack (2)
if: runner.os == 'Windows'
uses: al-cheb/configure-pagefile-action@v1.3
with:
minimum-size: 16GB
maximum-size: 16GB
disk-root: "D:"
- uses: actions/checkout@v3
with:
submodules: "recursive"
- name: Install Packages on Linux
if: runner.os == 'Linux'
run: |
sudo apt-get update -y
sudo apt-get install -y ninja-build python3-pyelftools elfutils patchelf nasm
- name: Install Cross-Compiler for Linux
if: runner.os == 'Linux' && matrix.arch == 'arm64'
run: |
sudo apt install crossbuild-essential-arm64
- uses: nttld/setup-ndk@v1
if: contains(matrix.arch, 'android')
id: setup-ndk
with:
ndk-version: r27
add-to-path: false
# https://github.com/android/ndk/issues/2032#issuecomment-2274923977
- name: Fix ndk r27
if: contains(matrix.arch, 'android')
run: |
FLAGS_PATH=${{ steps.setup-ndk.outputs.ndk-path }}/build/cmake/flags.cmake
FLAGS_CONTENT=$(cat $FLAGS_PATH)
echo -e "cmake_policy(PUSH)\ncmake_policy(SET CMP0057 NEW)\n\n${FLAGS_CONTENT}\n\ncmake_policy(POP)\n" > $FLAGS_PATH
cat $FLAGS_PATH
- name: Install Packages on MacOS
if: runner.os == 'macOS'
run: |
brew update
brew install ccache ninja pkg-config nasm bison
brew install bash gnu-sed gnu-tar
echo "$(brew --prefix)/opt/gnu-sed/libexec/gnubin" >> $GITHUB_PATH
echo "$(brew --prefix)/opt/gnu-tar/libexec/gnubin" >> $GITHUB_PATH
# brew unlink python
# brew link --overwrite python
- uses: actions/cache@v3
with:
path: |
vcpkg/downloads/
key: cache-downloads-${{ matrix.os }}-${{ matrix.arch }}-${{ hashfiles('vcpkg-overlay', 'vcpkg*.json') }}
# no symbols if installed from binary archive
# - uses: actions/cache/restore@v3
# if: github.event.inputs.use-cache
# with:
# path: |
# vcpkg/archives/
# key: cache-${{ matrix.os }}-${{ matrix.arch }}-${{ hashfiles('vcpkg-overlay') }}
# # this should work on both bash and pwsh, and giving native path on windows
# - run: |
# mkdir -p vcpkg/archives
# echo "VCPKG_DEFAULT_BINARY_CACHE=$PWD/vcpkg/archives" >> $GITHUB_ENV
- uses: ilammy/msvc-dev-cmd@v1
if: matrix.os == 'windows'
id: msvc-env
with:
arch: amd64${{ matrix.arch != 'x64' && format('_{0}', matrix.arch) || '' }}
- name: Setup MSVC environment
if: matrix.os == 'windows'
run: |
echo "CC=cl" >> $GITHUB_ENV
echo "CXX=cl" >> $GITHUB_ENV
- name: Setup ccache
uses: Chocobo1/setup-ccache-action@v1
with:
windows_compile_environment: msvc
# vcpkg will clean environment so that ccache is not used anyway
# - name: post-setup cache (windows)
# if: runner.os == 'Windows'
# shell: cmd
# run: |
# echo "PATH=%ccache_symlinks_path%;%PATH%" >> %GITHUB_ENV%
# - name: enable NTFS compression (windows)
# if: runner.os == 'Windows'
# shell: cmd
# run: |
# compact /c /q vcpkg
- name: Set target
run: |
lower() { printf '%s\n' "${1,,}"; }
if [[ "${{matrix.arch}}" == *"android"* ]]; then
echo "TARGET=${{ matrix.arch }}" >> $GITHUB_ENV
else
export RUNNER_OS=$(lower ${{runner.os}})
export OS=$(echo $RUNNER_OS | sed 's/macOS/osx/I')
echo "TARGET=${{ matrix.arch }}-${OS}" >> $GITHUB_ENV
fi
- name: Set OBJCOPY for arm64-linux
if: matrix.arch == 'arm64' && matrix.os == 'ubuntu'
run: |
echo "OBJCOPY=aarch64-linux-gnu-objcopy" >> $GITHUB_ENV
- name: Build MaaDeps
env:
ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
run: |
for attempt in 1 2 3
do
python3 build.py --tarball --target maa-$TARGET -- $MAA_CMAKE_ARGS && break
# delete object and archive files (of already installed packages) and retry
shopt -s globstar nullglob
df -lh
rm -f vcpkg/buildtrees/**/*.{o,obj,a,lib}
df -lh
du -sh vcpkg/buildtrees/*
[[ $attempt != 3 ]] # fail on last attempt
done
- name: Collect Logs
if: always()
run: |
shopt -s globstar
tar caf logs.tar --ignore-failed-read vcpkg/buildtrees/**/*.log
- name: Upload Logs
uses: actions/upload-artifact@v4
if: always()
with:
name: logs-${{ env.TARGET }}
path: logs.tar
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: tarball-${{ env.TARGET }}
path: tarball
- name: release
if: startsWith(github.ref, 'refs/tags/')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG_NAME: ${{ github.ref_name }}
shell: bash
run: |
gh release create "$TAG_NAME" --prerelease || true # accept existing release
gh release upload "$TAG_NAME" tarball/*
# - name: cache binary archives
# uses: actions/cache/save@v3
# if: github.event.inputs.use-cache
# with:
# path: |
# vcpkg/archives/
# key: cache-${{ matrix.os }}-${{ matrix.arch }}-${{ hashfiles('vcpkg-overlay') }}