Skip to content

mpv clang

mpv clang #5

Workflow file for this run

name: mpv clang
defaults:
run:
shell: bash
on:
workflow_dispatch:
inputs:
command:
description: 'Run custom command before building'
required: false
type: string
github_release:
description: 'Upload to Github release'
required: false
default: false
type: boolean
mpv_tarball:
description: 'Build latest mpv tarball'
required: false
default: false
type: boolean
jobs:
build_mpv:
name: Building mpv
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion != 'failure' }}
strategy:
fail-fast: false
matrix:
bit: [x86_64, x86_64_v3]
env:
BIT: ${{ matrix.bit }}
container:
image: docker://ghcr.io/shinchiro/archlinux:latest
outputs:
mpv_ver: ${{ steps.build_mpv_step.outputs.mpv_ver }}
steps:
- name: Init variable
run: |
if [[ $BIT == "i686" ]]; then
echo "arch=i686" >> $GITHUB_ENV
elif [[ $BIT == "x86_64" ]]; then
echo "arch=x86_64" >> $GITHUB_ENV
elif [[ $BIT == "x86_64_v3" ]]; then
echo "arch=x86_64" >> $GITHUB_ENV
echo "x86_64_level=-v3" >> $GITHUB_ENV
fi
- name: Setup git config
run: |
git config --global user.name "github-actions"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global pull.rebase true
git config --global rebase.autoStash true
git config --global fetch.prune true
git config --global --add safe.directory $PWD
- uses: actions/checkout@main
- name: Loading clang sysroot cache
uses: actions/cache/restore@main
with:
path: |
clang_root
key: ${{ secrets.CACHE_VERSION }}-clang_root-${{ github.run_id }}
restore-keys: |
${{ secrets.CACHE_VERSION }}-clang_root
- name: Loading repository cache
uses: actions/cache/restore@main
with:
path: src_packages
key: ${{ secrets.CACHE_VERSION }}-repository-${{ github.run_id }}
restore-keys: |
${{ secrets.CACHE_VERSION }}-repository
- name: Loading ${{ matrix.bit }} toolchain cache
uses: actions/cache/restore@main
with:
path: |
build_${{ matrix.bit }}
key: ${{ secrets.CACHE_VERSION }}-clang-${{ matrix.bit }}_toolchain-${{ github.run_id }}
restore-keys: |
${{ secrets.CACHE_VERSION }}-clang-${{ matrix.bit }}_toolchain
- name: Running custom command
if: ${{ github.event.inputs.command != '' }}
continue-on-error: true
run: ${{ github.event.inputs.command }}
- name: Configuring CMake & Downloading source
run: |
if [[ $BIT == x86_64_v3 ]]; then echo "x86_64_v3_ARCH=-DGCC_ARCH=x86-64-v3" >> $GITHUB_ENV; fi
cmake -DTARGET_ARCH=${{ env.arch }}-w64-mingw32 -DCOMPILER_TOOLCHAIN=clang ${{ env.x86_64_v3_ARCH }} -DCMAKE_INSTALL_PREFIX=$PWD/clang_root -DMINGW_INSTALL_PREFIX=$PWD/build_$BIT/$BIT-w64-mingw32 -DSINGLE_SOURCE_LOCATION=$PWD/src_packages -DRUSTUP_LOCATION=$PWD/clang_root/install_rustup -DENABLE_CCACHE=ON -DCLANG_PACKAGES_LTO=ON -G Ninja --fresh -B build_$BIT -S $PWD
ninja -C build_$BIT download || true
- name: Building mpv
id: build_mpv_step
env:
MPV_TARBALL: ${{ github.event.inputs.mpv_tarball }}
run: |
ninja -C build_$BIT update
ninja -C build_$BIT llvm-copy-builtin
$MPV_TARBALL && ninja -C build_$BIT mpv-release || ninja -C build_$BIT mpv
$MPV_TARBALL && echo "mpv_ver=$(cat build_$BIT/packages/mpv-release-prefix/VERSION)" >> $GITHUB_OUTPUT || echo "mpv_ver=$(cat build_$BIT/$BIT-w64-mingw32/mpv-version.h | grep -oP '#define VERSION "(\K[^"]+)')" >> $GITHUB_OUTPUT
- name: Packaging mpv
run: |
mkdir -p release_$BIT
ninja -C build_$BIT mpv-packaging; mv build_$BIT/mpv*.7z release_$BIT
if [[ $BIT == x86_64_v3 ]]; then for dir in release_$BIT/mpv-*; do name=$(basename $dir); mv $dir $(dirname $dir)/${name/x86_64/x86_64-v3}; done; fi
- name: Copying ffmpeg
run: |
hash=$(git -C src_packages/ffmpeg rev-parse --short HEAD)
7z a -m0=lzma2 -mx=9 -ms=on release_$BIT/ffmpeg-${{ env.arch }}${{ env.x86_64_level }}-git-$hash.7z ./build_$BIT/$BIT-w64-mingw32/bin/ffmpeg.exe
- name: Print dir info
id: print_dir_info
continue-on-error: true
run: |
ls -alh build_$BIT build_$BIT/* build_$BIT/$BIT-w64-mingw32/lib build_$BIT/$BIT-w64-mingw32/lib/*/
- name: Collecting logs
if: always()
run: |
mkdir -p build_${BIT}_logs
cp -fr $(find build_$BIT -type f -iname "*-*.log" -or -wholename "*/ffbuild/config.log") build_${BIT}_logs || true
7z a -m0=lzma2 -mx=9 -ms=on logs.7z build*logs
7z a -m0=lzma2 -mx=9 -ms=on -r logs2.7z *.log *.cmake *.ninja *.txt configure *.m4 *.sh
- name: Uploading logs
uses: actions/upload-artifact@main
if: always()
with:
name: mpv-${{ matrix.bit }}-logs
path: logs*.7z
- name: Uploading ${{ matrix.bit }} build
uses: actions/upload-artifact@main
with:
name: mpv-${{ matrix.bit }}
path: release_${{ matrix.bit }}/mpv-${{ env.arch }}*
- name: Uploading ${{ matrix.bit }} debug
uses: actions/upload-artifact@main
with:
name: mpv-${{ matrix.bit }}-debug
path: release_${{ matrix.bit }}/mpv-debug-${{ env.arch }}*
- name: Cleaning build directory
if: always()
run: |
rm -rf build_$BIT/mpv*
rm -rf release_$BIT/mpv-debug*.7z
- name: Cleaning rust toolchain directory
if: always()
run: |
ninja -C build_$BIT cargo-clean
- name: Saving clang sysroot cache
uses: actions/cache/save@main
if: ${{ always() && matrix.bit == 'x86_64' }}
with:
path: |
clang_root
key: ${{ secrets.CACHE_VERSION }}-clang_root-${{ github.run_id }}
- name: Saving repository cache
uses: actions/cache/save@main
if: ${{ always() && matrix.bit == 'x86_64' }}
with:
path: src_packages
key: ${{ secrets.CACHE_VERSION }}-repository-${{ github.run_id }}
- name: Saving ${{ matrix.bit }} toolchain cache
uses: actions/cache/save@main
if: always()
with:
path: |
build_${{ matrix.bit }}
key: ${{ secrets.CACHE_VERSION }}-clang-${{ matrix.bit }}_toolchain-${{ github.run_id }}
- name: Saving release_${{ matrix.bit }} cache
uses: actions/cache/save@main
with:
path: release_${{ matrix.bit }}
key: ${{ secrets.CACHE_VERSION }}-release_${{ matrix.bit }}-${{ github.run_id }}
release:
name: Upload releases
runs-on: ubuntu-latest
needs: build_mpv
env:
release_x86_64_key: ${{ secrets.CACHE_VERSION }}-release_x86_64-${{ github.run_id }}
release_x86_64_v3_key: ${{ secrets.CACHE_VERSION }}-release_x86_64_v3-${{ github.run_id }}
container:
image: docker://alpine:latest
steps:
- name: Installing dependencies
shell: sh
run: |
apk add --update --no-cache bash git file openssh curl tar zstd jq
git config --global pull.rebase true
git config --global fetch.prune true
git config --global --add safe.directory $PWD
- uses: actions/checkout@main
with:
ref: main
- name: Loading release_x86_64 cache
uses: actions/cache/restore@main
with:
path: release_x86_64
key: ${{ env.release_x86_64_key }}
- name: Loading release_x86_64_v3 cache
uses: actions/cache/restore@main
with:
path: release_x86_64_v3
key: ${{ env.release_x86_64_v3_key }}
- name: Moving archives
run: |
mkdir -p release
mv release_x86_64/* release_x86_64_v3/* release
du -ah release/*
echo "short_date=$(date "+%Y%m%d")" >> $GITHUB_ENV
- name: Release
uses: softprops/action-gh-release@v1
if: ${{ github.event.inputs.github_release == 'true' }}
continue-on-error: true
with:
prerelease: true
tag_name: ${{ needs.build_mpv.outputs.mpv_ver }}-${{ env.short_date }}
fail_on_unmatched_files: true
files: release/*