Skip to content

Update build script to use Clang 20 instead of 23 #41

Update build script to use Clang 20 instead of 23

Update build script to use Clang 20 instead of 23 #41

Workflow file for this run

# Based on CanerKaraca20 build script
name: Build ModelExtras
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Setup xmake
uses: xmake-io/github-action-setup-xmake@v1
with:
xmake-version: latest
actions-cache-folder: .xmake-cache
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y wget gnupg software-properties-common lsb-release
# Add LLVM APT repository
wget https://apt.llvm.org/llvm-snapshot.gpg.key
sudo apt-key add llvm-snapshot.gpg.key
sudo add-apt-repository "deb http://apt.llvm.org/$(lsb_release -cs)/ llvm-toolchain-$(lsb_release -cs)-20 main"
sudo apt-get update
# Install Clang 20
sudo apt-get install -y clang-20 clang++-20 g++-mingw-w64-i686
- name: Get latest plugin-sdk commit
id: plugin-sdk-ref
run: |
echo "sha=$(git ls-remote https://github.com/user-grinch/plugin-sdk-mingw.git HEAD | cut -f1)" >> "$GITHUB_OUTPUT"
- name: Restore plugin-sdk cache
id: plugin-sdk-cache
uses: actions/cache@v5
with:
path: plugin-sdk
key: plugin-sdk-${{ steps.plugin-sdk-ref.outputs.sha }}-i686-w64-mingw32
- name: Build plugin-sdk
if: steps.plugin-sdk-cache.outputs.cache-hit != 'true'
run: |
# Clone repo and check out the exact commit used in the cache key
git clone https://github.com/user-grinch/plugin-sdk-mingw.git plugin-sdk
cd plugin-sdk
git checkout "${{ steps.plugin-sdk-ref.outputs.sha }}"
mkdir -p output/lib
# Prepare object directories
for dir in shared plugin_sa safetyhook; do
find "$dir" -type d -exec mkdir -p "obj/{}" \;
done
# Common flags
FLAGS="-I. -Ishared -Ishared/game -Iplugin_sa -Iplugin_sa/game_sa -Iplugin_sa/game_sa/rw -Isafetyhook -DGTASA -DPLUGIN_SGV_10US -DRW"
CLANG_FLAGS="--target=i686-w64-mingw32 -fpermissive -fcommon -fms-extensions -Wno-microsoft-include -Wno-invalid-offsetof -Wno-builtin-macro-redefined -O2 -D__cpp_concepts=202002L"
# Parallel build
find shared plugin_sa safetyhook -name '*.cpp' -print0 | \
xargs -0 -P$(nproc) -I{} clang++-20 $CLANG_FLAGS -std=c++2b $FLAGS -c {} -o obj/{}.o
find safetyhook -name '*.c' -print0 | \
xargs -0 -P$(nproc) -I{} clang-20 $CLANG_FLAGS $FLAGS -c {} -o obj/{}.o
find obj -name '*.o' | xargs i686-w64-mingw32-ar rcs output/lib/libplugin.a
echo "PLUGIN_SDK_DIR=$GITHUB_WORKSPACE/plugin-sdk" >> "$GITHUB_ENV"
- name: Use cached plugin-sdk
if: steps.plugin-sdk-cache.outputs.cache-hit == 'true'
run: echo "PLUGIN_SDK_DIR=$GITHUB_WORKSPACE/plugin-sdk" >> "$GITHUB_ENV"
- name: Build ModelExtras with xmake
run: |
xmake f -m release \
--mingw=/usr \
--cc=clang-20 \
--cxx=clang++-20 \
-c -y
xmake -j$(nproc)
- name: Prepare artifact files
run: |
mkdir -p artifact/ModelExtras
cp build/mingw/x86/release/ModelExtras.asi artifact/ModelExtras.asi
cp resource/dist/ModelExtras.ini artifact/ModelExtras.ini
cp -r resource/dist/ModelExtras/* artifact/ModelExtras/
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: ModelExtras-Test-Build
path: |
artifact/ModelExtras.asi
artifact/ModelExtras.ini
artifact/ModelExtras/**