Skip to content

add github actions to generate artifacts #4

add github actions to generate artifacts

add github actions to generate artifacts #4

name: Generate artifacts
on:
push:
jobs:
build:
name: Build ${{ matrix.os }} ${{ matrix.android }} ${{ matrix.abi }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
android: [false]
abi: ['']
include:
- os: windows-latest
- os: ubuntu-latest
- os: ubuntu-latest
android: true
abi: x86_64
- os: ubuntu-latest
android: true
abi: arm64-v8a
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Free space on runner
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
set +x
dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -n | tail -n 100
df -h
sudo apt-get update
sudo apt-get remove -y '^dotnet-.*'
sudo apt-get remove -y '^temurin-.*'
sudo apt-get remove -y azure-cli google-cloud-cli microsoft-edge-stable google-chrome-stable firefox
sudo apt-get autoremove -y
sudo apt-get clean
sudo rm -rf /usr/share/dotnet/
sudo rm -rf /usr/local/share/powershell
sudo rm -rf /usr/local/share/chromium
sudo rm -rf /usr/local/lib/node_modules
df -h
- name: Download and extract Android NDK
if: ${{ matrix.android }}
run: |
set -x
wget https://dl.google.com/android/repository/android-ndk-r27c-linux.zip
unzip android-ndk-r27c-linux.zip
rm -rf android-ndk-r27c-linux.zip
- name: Select build directory
shell: bash
run: |
if [ $RUNNER_OS == "Windows" ]; then
echo "builddir=C:/build" >> $GITHUB_ENV
else
echo "builddir=${{ github.workspace }}/build" >> $GITHUB_ENV
fi
- name: Fetch dependencies
run: python3 ./utils/fetch_sources.py --shallow
- name: Download LLVM Windows
if: ${{ matrix.os == 'windows-latest' }}
shell: bash
env:
LLVM_ARCHIVE_PREFIX: LLVM-19.1.3-Windows-X64
run: |
set -x
curl -L https://github.com/llvm/llvm-project/releases/download/llvmorg-19.1.3/${LLVM_ARCHIVE_PREFIX}.tar.xz --output ${LLVM_ARCHIVE_PREFIX}.tar.xz
tar -xf ${LLVM_ARCHIVE_PREFIX}.tar.xz
rm -rf ${LLVM_ARCHIVE_PREFIX}.tar.xz
echo "llvmnative=$(pwd)/${LLVM_ARCHIVE_PREFIX}" >> $GITHUB_ENV
echo "clangxxbinary=clang++.exe" >> $GITHUB_ENV
echo "clangbinary=clang.exe" >> $GITHUB_ENV
- name: Download LLVM Linux
if: ${{ matrix.os == 'ubuntu-latest' }}
env:
LLVM_ARCHIVE_PREFIX: LLVM-19.1.3-Linux-X64
run: |
set -x
wget https://github.com/llvm/llvm-project/releases/download/llvmorg-19.1.3/${LLVM_ARCHIVE_PREFIX}.tar.xz
tar -xf ${LLVM_ARCHIVE_PREFIX}.tar.xz
rm -rf ${LLVM_ARCHIVE_PREFIX}.tar.xz
echo "llvmnative=${{ github.workspace }}/${LLVM_ARCHIVE_PREFIX}" >> $GITHUB_ENV
echo "clangxxbinary=clang++" >> $GITHUB_ENV
echo "clangbinary=clang" >> $GITHUB_ENV
- name: Build libclc
if: ${{ matrix.android }}
env:
LIBCLC_DIR: ${{ github.workspace }}/build_libclc
run: |
set -x
cmake -S '${{ github.workspace }}/third_party/llvm/libclc' -B ${LIBCLC_DIR} \
-DLLVM_CMAKE_DIR=${{ env.llvmnative }}/lib/cmake \
-DCMAKE_C_COMPILER=${{ env.llvmnative }}/bin/${{ env.clangbinary }} \
-DCMAKE_CXX_COMPILER=${{ env.llvmnative }}/bin/${{ env.clangxxbinary }} \
-DCMAKE_CXX_FLAGS="-fuse-ld=lld" \
-DLIBCLC_TARGETS_TO_BUILD="clspv--;clspv64--"
cmake --build ${LIBCLC_DIR} -j4
ls -l ${LIBCLC_DIR}
echo "android-cmake-args=-DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/android-ndk-r27c/build/cmake/android.toolchain.cmake -DANDROID_ABI=${{ matrix.abi }} -DCLSPV_EXTERNAL_LIBCLC_DIR=${LIBCLC_DIR}" >> $GITHUB_ENV
- name: Configure
shell: bash
run: |
set -x
cmake -B '${{ env.builddir }}' -S '${{ github.workspace }}' \
-DCMAKE_BUILD_TYPE=Release \
${{ env.android-cmake-args }} \
-DCMAKE_CXX_COMPILER=${{ env.llvmnative }}/bin/${{ env.clangbinary }} \
-DCMAKE_CXX_FLAGS="-fuse-ld=lld -Wno-unused-command-line-argument -Wno-unknown-warning-option"
ls -l '${{ env.builddir }}'
- name: Build
run: cmake --build '${{ env.builddir }}' --config Release -j4
- uses: actions/upload-artifact@v4
with:
name: clspv-${{ matrix.os }}-${{ matrix.abi }}-${{ matrix.android }}
path: '${{ env.builddir }}'