name: Linux Build on: workflow_call: inputs: runs-on: description: 'Image' required: true type: string llvm_version: description: 'LLVM Version' required: true type: string ubuntu_base: description: 'Ubuntu Base' required: true type: string jobs: build: name: Build runs-on: ${{ inputs.runs-on }} steps: - name: Checkout repository uses: actions/checkout@v6 with: fetch-depth: 0 - name: Cache Vulkan SDK id: cache-vulkan-sdk-linux uses: actions/cache@v6 with: path: ~/vulkan-sdk key: ${{ runner.os }}-vulkan-sdk-latest - name: Cache linuxdeploy tools id: cache-linuxdeploy uses: actions/cache@v6 with: path: ~/linuxdeploy key: ${{ runner.os }}-linuxdeploy-tools - name: Setup build environment run: |- wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc sudo apt-add-repository "deb http://apt.llvm.org/${{ inputs.ubuntu_base }}/ llvm-toolchain-${{ inputs.ubuntu_base }}-${{ inputs.llvm_version }} main" sudo apt-get -y update sudo apt-get -y install mesa-vulkan-drivers valgrind libc++-dev libc++abi-dev libgtk-3-dev libsdl2-dev libvulkan-dev libx11-xcb-dev clang-${{ inputs.llvm_version }} lld-${{ inputs.llvm_version }} spirv-tools libfuse2 # Pin LLVM tools to the correct version so system ar/ranlib/lld # don't use the older LLVM 17 gold plugin with clang-20 LTO bitcode sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-${{ inputs.llvm_version }} 200 sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-${{ inputs.llvm_version }} 200 sudo update-alternatives --install /usr/bin/lld lld /usr/bin/lld-${{ inputs.llvm_version }} 200 sudo update-alternatives --install /usr/bin/ld.lld ld.lld /usr/bin/ld.lld-${{ inputs.llvm_version }} 200 sudo update-alternatives --install /usr/bin/llvm-ar llvm-ar /usr/bin/llvm-ar-${{ inputs.llvm_version }} 200 sudo update-alternatives --install /usr/bin/llvm-ranlib llvm-ranlib /usr/bin/llvm-ranlib-${{ inputs.llvm_version }} 200 sudo update-alternatives --install /usr/bin/llvm-nm llvm-nm /usr/bin/llvm-nm-${{ inputs.llvm_version }} 200 # Download linuxdeploy tools if not cached if [ "${{ steps.cache-linuxdeploy.outputs.cache-hit }}" != "true" ]; then mkdir -p ~/linuxdeploy wget -q https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage -O ~/linuxdeploy/linuxdeploy chmod +x ~/linuxdeploy/linuxdeploy fi echo "${HOME}/linuxdeploy" >> $GITHUB_PATH - name: Install Vulkan SDK run: |- if [ "${{ steps.cache-vulkan-sdk-linux.outputs.cache-hit }}" != "true" ]; then wget -qO vulkan-sdk.tar.xz https://sdk.lunarg.com/sdk/download/latest/linux/vulkan-sdk.tar.xz mkdir -p ~/vulkan-sdk tar -xf vulkan-sdk.tar.xz -C ~/vulkan-sdk fi VULKAN_SDK_VERSION=$(ls ~/vulkan-sdk) echo "VULKAN_SDK=${HOME}/vulkan-sdk/${VULKAN_SDK_VERSION}/x86_64" >> $GITHUB_ENV echo "${HOME}/vulkan-sdk/${VULKAN_SDK_VERSION}/x86_64/bin" >> $GITHUB_PATH # Verify shader tools are available for tool in glslangValidator spirv-opt spirv-dis; do which "$tool" && "$tool" --version 2>/dev/null || echo "Warning: $tool not found" done - name: Download submodules run: |- # Exclude unneeded submodules SUBMODULES=$(grep -oP '(?<=path = )(?!third_party\/(?:DirectX(?:-Headers|ShaderCompiler)|xbyak_aarch64)).+' .gitmodules) git submodule update --init --depth=1 -j$(getconf _NPROCESSORS_ONLN) $SUBMODULES - name: Build Xenia env: CC: clang-${{ inputs.llvm_version }} CXX: clang++-${{ inputs.llvm_version }} run: ./xenia-build.py build --config=Release - name: Prepare AppImage id: prepare_artifacts run: |- binary=build/bin/Linux/Release/xenia_canary if [ $(stat -c%s $binary) -le 100000 ]; then echo "::error::Binary is too small." exit 1 fi chmod +x $binary # Set up AppDir structure APPDIR=artifacts/xenia_canary mkdir -p ${APPDIR}/usr/bin # Install icons for size in 16 32 48 64 128 256 512 1024; do mkdir -p ${APPDIR}/usr/share/icons/hicolor/${size}x${size}/apps cp assets/icon/${size}.png ${APPDIR}/usr/share/icons/hicolor/${size}x${size}/apps/xenia_canary.png done # Copy any extra runtime data directories alongside the binary find build/bin/Linux/Release -maxdepth 1 -type d ! -name Release -exec cp -r {} ${APPDIR}/usr/bin/ \; # Build AppImage with linuxdeploy (requires absolute paths) linuxdeploy --appdir $APPDIR \ --executable $binary \ --desktop-file ${GITHUB_WORKSPACE}/assets/xenia_canary.desktop \ --icon-file ${GITHUB_WORKSPACE}/assets/icon/256.png \ --output appimage # Find the generated AppImage and move to release directory appimage_file=$(ls -1 *.AppImage | head -n1) if [ -z "$appimage_file" ]; then echo "::error::AppImage file not found after linuxdeploy" exit 1 fi chmod +x "$appimage_file" artifact=xenia_canary_linux.AppImage mv "$appimage_file" $artifact echo "path=$artifact" >> $GITHUB_OUTPUT - name: Upload Xenia Canary artifact if: ${{ steps.prepare_artifacts.outcome == 'success' }} uses: actions/upload-artifact@v7 with: path: ${{ steps.prepare_artifacts.outputs.path }} if-no-files-found: error retention-days: 7 archive: false