From cf56a7d1250d2d5b961c3e04ad6a18e052291f64 Mon Sep 17 00:00:00 2001 From: nekosu Date: Mon, 25 Nov 2024 19:17:36 +0800 Subject: [PATCH] chore: optimize --- .github/workflows/build.yml | 70 ++++++++++++++++------------------- .github/workflows/test.yml | 54 ++++++++++++++------------- CMakeLists.txt | 2 +- source/binding/CMakeLists.txt | 2 +- 4 files changed, 61 insertions(+), 67 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 78b8badc2..7824785f2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,27 +3,27 @@ name: build on: push: tags: - - "v*" + - 'v*' branches: - - "**" + - '**' paths: - - ".github/workflows/build.yml" - - "3rdparty/**" - - "cmake/**" - - "include/**" - - "source/**" - - "CMakeLists.txt" + - '.github/workflows/build.yml' + - '3rdparty/**' + - 'cmake/**' + - 'include/**' + - 'source/**' + - 'CMakeLists.txt' pull_request: branches: - - "**" + - '**' paths: - - ".github/workflows/build.yml" - - "3rdparty/**" - - "cmake/**" - - "include/**" - - "source/**" - - "CMakeLists.txt" + - '.github/workflows/build.yml' + - '3rdparty/**' + - 'cmake/**' + - 'include/**' + - 'source/**' + - 'CMakeLists.txt' workflow_dispatch: jobs: @@ -55,7 +55,7 @@ jobs: with: minimum-size: 16GB maximum-size: 16GB - disk-root: "D:" + disk-root: 'D:' - uses: actions/checkout@v4 with: @@ -89,7 +89,7 @@ jobs: - name: Build MAA run: | - cmake --preset "${{ matrix.arch == 'x86_64' && 'MSVC 2022' || 'MSVC 2022 ARM' }}" -DCMAKE_SYSTEM_VERSION="10.0.22621.0" -DMAADEPS_TRIPLET="maa-${{ matrix.arch == 'x86_64' && 'x64' || 'arm64' }}-windows" -DMAA_HASH_VERSION='${{ needs.meta.outputs.tag }}' + cmake --preset "${{ matrix.arch == 'x86_64' && 'MSVC 2022' || 'MSVC 2022 ARM' }}" -DCMAKE_SYSTEM_VERSION="10.0.22621.0" -DMAADEPS_TRIPLET="maa-${{ matrix.arch == 'x86_64' && 'x64' || 'arm64' }}-windows" -DMAA_HASH_VERSION='${{ needs.meta.outputs.tag }}' -DBUILD_NODEJS_BINDING=ON cmake --build build --preset "${{ matrix.arch == 'x86_64' && 'MSVC 2022' || 'MSVC 2022 ARM' }} - Release" -j 16 @@ -111,7 +111,7 @@ jobs: if: always() with: name: MAA-win-${{ matrix.arch }} - path: "install" + path: 'install' ubuntu: needs: meta @@ -177,7 +177,8 @@ jobs: run: | cmake --preset 'NinjaMulti' \ -DMAADEPS_TRIPLET='maa-${{ matrix.arch == 'x86_64' && 'x64' || 'arm64' }}-linux' \ - -DMAA_HASH_VERSION='${{ needs.meta.outputs.tag }}' + -DMAA_HASH_VERSION='${{ needs.meta.outputs.tag }}' \ + -DBUILD_NODEJS_BINDING=ON cmake --build build --preset 'NinjaMulti - Release' -j 16 @@ -198,7 +199,7 @@ jobs: if: always() with: name: MAA-linux-${{ matrix.arch }} - path: "install" + path: 'install' macos: needs: meta @@ -258,7 +259,8 @@ jobs: -DMAADEPS_TRIPLET='maa-${{ matrix.arch == 'x86_64' && 'x64' || 'arm64' }}-osx' \ -DMAA_HASH_VERSION='${{ needs.meta.outputs.tag }}' \ -DCMAKE_C_COMPILER=${LLVM_PREFIX}/bin/clang \ - -DCMAKE_CXX_COMPILER=${LLVM_PREFIX}/bin/clang++ + -DCMAKE_CXX_COMPILER=${LLVM_PREFIX}/bin/clang++ \ + -DBUILD_NODEJS_BINDING=ON cmake --build build --preset 'NinjaMulti - Release' -j 16 @@ -279,7 +281,7 @@ jobs: if: always() with: name: MAA-macos-${{ matrix.arch }} - path: "install" + path: 'install' android: needs: meta @@ -345,7 +347,7 @@ jobs: if: always() with: name: MAA-android-${{ matrix.arch }} - path: "install" + path: 'install' nuget_pack: needs: [meta, windows, ubuntu, macos, android] @@ -375,7 +377,7 @@ jobs: if: always() with: name: MAA-nupkgs - path: "tools/nupkgs/*.nupkg" + path: 'tools/nupkgs/*.nupkg' pip_pack: needs: [meta, windows, ubuntu, macos, android] @@ -397,7 +399,7 @@ jobs: if: always() with: name: MAA-pip-pkgs - path: "tools/pip_pack/wheel/*.whl" + path: 'tools/pip_pack/wheel/*.whl' nodejs_pack: needs: [meta, windows, ubuntu, macos, android] @@ -434,21 +436,11 @@ jobs: - uses: actions/upload-artifact@v4 with: name: MAA-nodejs-package - path: "source/binding/NodeJS/release" + path: 'source/binding/NodeJS/release' release: if: ${{ needs.meta.outputs.is_release == 'true' && github.repository_id == '632024122' }} - needs: - [ - meta, - windows, - ubuntu, - macos, - android, - nuget_pack, - pip_pack, - nodejs_pack, - ] + needs: [meta, windows, ubuntu, macos, android, nuget_pack, pip_pack, nodejs_pack] runs-on: ubuntu-latest env: OUTPUT_PUBLISH_FAILED: 'echo "failed=true" >> $GITHUB_OUTPUT && echo "::error::Failed to publish packages"' @@ -537,8 +529,8 @@ jobs: if: steps.nuget.outputs.failed || steps.pip.outputs.failed uses: actions-cool/issues-helper@v3 with: - actions: "create-issue" - title: "${{ needs.meta.outputs.tag }} failed to publish packages" + actions: 'create-issue' + title: '${{ needs.meta.outputs.tag }} failed to publish packages' body: | Please manually publish the following packages: ${{ steps.nuget.outputs.failed && '- nuget @moomiji' || '' }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 678c7c767..5d49cad6d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3,27 +3,27 @@ name: test on: push: branches: - - "**" + - '**' paths: - - ".github/workflows/test.yml" - - "3rdparty/**" - - "cmake/**" - - "include/**" - - "source/**" - - "CMakeLists.txt" - - "test/**" + - '.github/workflows/test.yml' + - '3rdparty/**' + - 'cmake/**' + - 'include/**' + - 'source/**' + - 'CMakeLists.txt' + - 'test/**' pull_request: branches: - - "**" + - '**' paths: - - ".github/workflows/test.yml" - - "3rdparty/**" - - "cmake/**" - - "include/**" - - "source/**" - - "CMakeLists.txt" - - "test/**" + - '.github/workflows/test.yml' + - '3rdparty/**' + - 'cmake/**' + - 'include/**' + - 'source/**' + - 'CMakeLists.txt' + - 'test/**' workflow_dispatch: jobs: @@ -55,7 +55,7 @@ jobs: with: minimum-size: 16GB maximum-size: 16GB - disk-root: "D:" + disk-root: 'D:' - uses: actions/checkout@v4 with: @@ -92,7 +92,7 @@ jobs: - name: Build MAA run: | - cmake --preset "${{ matrix.arch == 'x86_64' && 'MSVC 2022' || 'MSVC 2022 ARM' }}" -DMAADEPS_TRIPLET="maa-${{ matrix.arch == 'x86_64' && 'x64' || 'arm64' }}-windows" -DCMAKE_SYSTEM_VERSION="10.0.22621.0" -DMAA_HASH_VERSION='${{ needs.meta.outputs.tag }}' -DBUILD_PIPELINE_TESTING=ON -DBUILD_DLOPEN_TESTING=ON + cmake --preset "${{ matrix.arch == 'x86_64' && 'MSVC 2022' || 'MSVC 2022 ARM' }}" -DMAADEPS_TRIPLET="maa-${{ matrix.arch == 'x86_64' && 'x64' || 'arm64' }}-windows" -DCMAKE_SYSTEM_VERSION="10.0.22621.0" -DMAA_HASH_VERSION='${{ needs.meta.outputs.tag }}' -DBUILD_NODEJS_BINDING=ON -DBUILD_PIPELINE_TESTING=ON -DBUILD_DLOPEN_TESTING=ON cmake --build build --preset "${{ matrix.arch == 'x86_64' && 'MSVC 2022' || 'MSVC 2022 ARM' }} - Release" -j 16 @@ -132,13 +132,13 @@ jobs: if: always() with: name: MAA-win-${{ matrix.arch }}-text_log - path: "install/bin/debug/*.log" + path: 'install/bin/debug/*.log' - uses: actions/upload-artifact@v4 if: always() with: name: MAA-win-${{ matrix.arch }}-full_log - path: "install/bin/debug" + path: 'install/bin/debug' ubuntu: needs: meta @@ -208,6 +208,7 @@ jobs: cmake --preset 'NinjaMulti' \ -DMAADEPS_TRIPLET='maa-${{ matrix.arch == 'x86_64' && 'x64' || 'arm64' }}-linux' \ -DMAA_HASH_VERSION='${{ needs.meta.outputs.tag }}' \ + -DBUILD_NODEJS_BINDING=ON \ -DBUILD_PIPELINE_TESTING=ON -DBUILD_DLOPEN_TESTING=ON cmake --build build --preset 'NinjaMulti - Release' -j 16 @@ -250,13 +251,13 @@ jobs: if: always() with: name: MAA-linux-${{ matrix.arch }}-text_log - path: "install/bin/debug/*.log" + path: 'install/bin/debug/*.log' - uses: actions/upload-artifact@v4 if: always() with: name: MAA-linux-${{ matrix.arch }}-full_log - path: "install/bin/debug" + path: 'install/bin/debug' macos: needs: meta @@ -318,9 +319,10 @@ jobs: cmake --preset 'NinjaMulti' \ -DMAADEPS_TRIPLET='maa-${{ matrix.arch == 'x86_64' && 'x64' || 'arm64' }}-osx' \ -DMAA_HASH_VERSION='${{ needs.meta.outputs.tag }}' \ - -DBUILD_PIPELINE_TESTING=ON -DBUILD_DLOPEN_TESTING=ON \ -DCMAKE_C_COMPILER=${LLVM_PREFIX}/bin/clang \ - -DCMAKE_CXX_COMPILER=${LLVM_PREFIX}/bin/clang++ + -DCMAKE_CXX_COMPILER=${LLVM_PREFIX}/bin/clang++ \ + -DBUILD_NODEJS_BINDING=ON \ + -DBUILD_PIPELINE_TESTING=ON -DBUILD_DLOPEN_TESTING=ON cmake --build build --preset 'NinjaMulti - Release' -j 16 @@ -359,10 +361,10 @@ jobs: if: always() with: name: MAA-macos-${{ matrix.arch }}-text_log - path: "install/bin/debug/*.log" + path: 'install/bin/debug/*.log' - uses: actions/upload-artifact@v4 if: always() with: name: MAA-macos-${{ matrix.arch }}-full_log - path: "install/bin/debug" + path: 'install/bin/debug' diff --git a/CMakeLists.txt b/CMakeLists.txt index 7ca573bd1..90db0c944 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,7 +15,7 @@ option(WITH_ADB_CONTROLLER "build with adb controller" ON) option(WITH_WIN32_CONTROLLER "build with win32 controller" ON) option(WITH_DBG_CONTROLLER "build with debugging controller" ON) option(ENABLE_CCACHE "enable ccache if possible" ON) -option(BUILD_NODEJS_BINDING "build nodejs binding" ON) +option(BUILD_NODEJS_BINDING "build nodejs binding" OFF) option(BUILD_SAMPLE "build a demo" OFF) diff --git a/source/binding/CMakeLists.txt b/source/binding/CMakeLists.txt index 1744f2975..7fbd156a7 100644 --- a/source/binding/CMakeLists.txt +++ b/source/binding/CMakeLists.txt @@ -2,7 +2,7 @@ if(BUILD_NODEJS_BINDING) if(EXISTS ${CMAKE_CURRENT_LIST_DIR}/NodeJS/node_modules) add_subdirectory(NodeJS) else() - message("NodeJS/node_modules not found, install via `pnpm install` first.") + message(FATAL_ERROR "NodeJS/node_modules not found, install via `pnpm install` first.") endif() endif()