build: Adopt CMake presets for CI and add clangd/VSCode integration (#15595)

* feat: clangd support

* feat: 完善CMakePresets

* docs: 更新cmake命令

* fix: smoke test run

* docs: 更新vscode开发文档

* feat: 添加执行MaaWpf到cmake中

* feat: 支持全部的presets

* chore: 重新安排顺序

* chore: add some comment

* chore: add more comments

* feat: 简化res-update-game

* chore: 移除多余build

* chore: 统一x64和arm64

* chore: 修正重复忽略.vscode

* feat: vscode cmaketool乱码

* docs: 添加提示
This commit is contained in:
soundofautumn
2026-02-06 23:05:41 +08:00
committed by GitHub
parent e167e41696
commit 84f1bf490c
15 changed files with 566 additions and 119 deletions

View File

@@ -11,6 +11,7 @@ on:
- "3rdparty/include/**"
- "cmake/**"
- "CMakeLists.txt"
- "CMakePresets.json"
- "include/**"
- "src/**"
- "tools/maadeps-download.py"
@@ -23,6 +24,7 @@ on:
- "3rdparty/include/**"
- "cmake/**"
- "CMakeLists.txt"
- "CMakePresets.json"
- "include/**"
- "src/**"
- "tools/maadeps-download.py"
@@ -130,20 +132,12 @@ jobs:
run: |
python3 tools/maadeps-download.py ${{ matrix.arch }}-windows
- name: Config cmake
- name: Configure, build and install
run: |
mkdir -p build
cmake -B build ${{ matrix.arch == 'arm64' && '-A ARM64' }} -DCMAKE_BUILD_TYPE=RelWithDebInfo -DMAADEPS_TRIPLET='maa-${{ matrix.arch }}-windows' -DINSTALL_RESOURCE=ON -DINSTALL_PYTHON=ON -DMAA_HASH_VERSION='${{ needs.meta.outputs.tag }}' -DBUILD_WPF_GUI=OFF
- name: Build
run: |
cmake --build build --config RelWithDebInfo --parallel $env:NUMBER_OF_PROCESSORS
- name: Install
run: |
mkdir -p install
cmake --install build --prefix install --config RelWithDebInfo
cmake -B build --preset ${{ matrix.arch == 'arm64' && 'windows-publish-arm64' || 'windows-publish-x64' }} -DMAA_HASH_VERSION='${{ needs.meta.outputs.tag }}'
cmake --build --preset ${{ matrix.arch == 'arm64' && 'windows-publish-arm64' || 'windows-publish-x64' }} --parallel $env:NUMBER_OF_PROCESSORS
cmake --install build --config RelWithDebInfo
- name: Minify JSON in resource
run: python3 tools/minify_json_folder.py install/resource
@@ -267,28 +261,14 @@ jobs:
run: |
python3 tools/maadeps-download.py ${{ matrix.arch == 'x86_64' && 'x64' || 'arm64' }}-linux
- name: Config cmake
- name: Configure, build and install
run: |
mkdir -p build
cmake -B build \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DMAADEPS_TRIPLET='maa-${{ matrix.arch == 'x86_64' && 'x64' || 'arm64' }}-linux' \
-DINSTALL_RESOURCE=ON \
-DINSTALL_PYTHON=ON \
-DMAA_HASH_VERSION='${{ needs.meta.outputs.tag }}' \
-DCMAKE_TOOLCHAIN_FILE=src/MaaUtils/MaaDeps/cmake/maa-${{ matrix.arch == 'x86_64' && 'x64' || 'arm64' }}-linux-toolchain.cmake
- name: Build
run: |
cmake --build build --config RelWithDebInfo --parallel $(nproc)
cmake --preset ${{ matrix.arch == 'x86_64' && 'linux-publish-x64' || 'linux-publish-arm64' }} -DMAA_HASH_VERSION='${{ needs.meta.outputs.tag }}'
cmake --build --preset ${{ matrix.arch == 'x86_64' && 'linux-publish-x64' || 'linux-publish-arm64' }} --parallel $(nproc)
cmake --install build --config RelWithDebInfo
env:
CLICOLOR_FORCE: 1
- name: Install
run: |
mkdir -p install
cmake --install build --prefix install --config RelWithDebInfo
- name: Minify JSON in resource
run: python3 tools/minify_json_folder.py install/resource
@@ -393,20 +373,11 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Config cmake
- name: Configure, build and install
run: |
cmake -B build -GNinja \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_OSX_ARCHITECTURES='${{ matrix.arch }}' \
-DMAA_HASH_VERSION='${{ needs.meta.outputs.tag }}'
- name: Build
run: |
cmake --build build --config RelWithDebInfo --parallel $(sysctl -n hw.logicalcpu)
- name: Install
run: |
cmake --install build --prefix install --config RelWithDebInfo
cmake -B build --preset ${{ matrix.arch == 'x86_64' && 'macos-publish-x64' || 'macos-publish-arm64' }} -DMAA_HASH_VERSION='${{ needs.meta.outputs.tag }}'
cmake --build --preset ${{ matrix.arch == 'x86_64' && 'macos-publish-x64' || 'macos-publish-arm64' }} --parallel $(sysctl -n hw.logicalcpu)
cmake --install build --config RelWithDebInfo
- name: Upload MAA to GitHub
uses: actions/upload-artifact@v6

View File

@@ -185,19 +185,11 @@ jobs:
run: |
python3 tools/maadeps-download.py ${{ matrix.arch }}-windows
- name: Config cmake
- name: Configure, build and install
run: |
mkdir -p build
cmake -B build ${{ matrix.arch == 'arm64' && '-A ARM64' }} -DCMAKE_BUILD_TYPE=RelWithDebInfo -DMAADEPS_TRIPLET='maa-${{ matrix.arch }}-windows' -DINSTALL_RESOURCE=ON -DINSTALL_PYTHON=ON -DMAA_HASH_VERSION='${{ steps.set_tag.outputs.tag }}' -DBUILD_WPF_GUI=OFF
- name: Build
run: |
cmake --build build --config RelWithDebInfo --parallel $env:NUMBER_OF_PROCESSORS
- name: Install
run: |
mkdir -p install
cmake --install build --prefix install --config RelWithDebInfo
cmake -B build --preset ${{ matrix.arch == 'arm64' && 'windows-publish-arm64' || 'windows-publish-x64' }} -DMAA_HASH_VERSION='${{ steps.set_tag.outputs.tag }}'
cmake --build --preset ${{ matrix.arch == 'arm64' && 'windows-publish-arm64' || 'windows-publish-x64' }} --parallel $env:NUMBER_OF_PROCESSORS
cmake --install build --config RelWithDebInfo
- name: Download MaaFramework
if: matrix.arch == 'x64'

View File

@@ -184,25 +184,13 @@ jobs:
run: |
python3 tools/maadeps-download.py arm64-osx
- name: Config cmake
- name: Config, Build & Install ResourceUpdater
if: steps.resupd-cache.outputs.cache-hit != 'true'
run: |
cd tools/ResourceUpdater
mkdir -p build
cmake -B build -GNinja \
-DCMAKE_BUILD_TYPE=Release \
-DMAADEPS_TRIPLET='maa-arm64-osx' \
-DWITH_HASH_VERSION=ON
- name: Build
if: steps.resupd-cache.outputs.cache-hit != 'true'
run: |
cmake --build tools/ResourceUpdater/build --config Release --parallel $(sysctl -n hw.logicalcpu)
- name: Install
if: steps.resupd-cache.outputs.cache-hit != 'true'
run: |
cmake --install tools/ResourceUpdater/build --prefix tools/ResourceUpdater --config Release
cmake --preset res-updater-macos-arm64
cmake --build --preset res-updater-macos-arm64 --parallel $(sysctl -n hw.logicalcpu)
cmake --install build --config Release
- name: Save ResourceUpdater to cache
if: always() && steps.resupd-cache.outputs.cache-hit != 'true'

View File

@@ -87,27 +87,12 @@ jobs:
run: |
python3 tools/maadeps-download.py arm64-osx
- name: Config cmake
- name: Configure, build and install
if: steps.smoke-cache.outputs.cache-hit != 'true'
run: |
mkdir -p build
cmake -B build -GNinja \
-DCMAKE_BUILD_TYPE=Debug \
-DMAADEPS_TRIPLET='maa-arm64-osx' \
-DBUILD_SMOKE_TEST=ON \
-DINSTALL_RESOURCE=ON \
-DWITH_HASH_VERSION=ON
- name: Build
if: steps.smoke-cache.outputs.cache-hit != 'true'
run: |
cmake --build build --config Debug --parallel $(sysctl -n hw.logicalcpu)
- name: Install
if: steps.smoke-cache.outputs.cache-hit != 'true'
run: |
mkdir -p install
cmake --install build --prefix install --config Debug
cmake -B build --preset smoke-test
cmake --build build --preset smoke-test --parallel $(sysctl -n hw.logicalcpu)
cmake --install build --config Debug
- name: Make link to Smoke Test cache
if: steps.smoke-cache.outputs.cache-hit == 'true'