diff --git a/.github/workflows/res-update-game.yml b/.github/workflows/res-update-game.yml index 790bd1804e..a1b2dff6e8 100644 --- a/.github/workflows/res-update-game.yml +++ b/.github/workflows/res-update-game.yml @@ -146,8 +146,8 @@ jobs: with: key: Resource-updater-${{ hashFiles('./tools/ResourceUpdater/main.cpp') }} path: | - ./tools/ResourceUpdater/x64/Release/opencv_world4_maa.dll - ./tools/ResourceUpdater/x64/Release/ResourceUpdater.exe + ./tools/ResourceUpdater/opencv_world4_maa.dll + ./tools/ResourceUpdater/ResourceUpdater.exe - name: Cache MaaDeps if: steps.cache-resupd.outputs.cache-hit != 'true' @@ -165,14 +165,18 @@ jobs: run: | python3 tools/maadeps-download.py x64-windows - - name: Add msbuild to PATH - if: steps.cache-resupd.outputs.cache-hit != 'true' - uses: microsoft/setup-msbuild@v2 + - name: Config cmake + run: | + mkdir -p build + cmake -B build -DCMAKE_BUILD_TYPE=Release -DMAADEPS_TRIPLET='maa-x64-windows' -DMAA_HASH_VERSION='${{ needs.meta.outputs.tag }}' -DBUILD_WPF_GUI=OFF -DBUILD_RES_UPDATER=ON - name: Build Resource Updater - if: steps.cache-resupd.outputs.cache-hit != 'true' run: | - MSBUILD tools/ResourceUpdater/ResourceUpdater.vcxproj /t:rebuild /p:Configuration="Release" /p:Platform="x64" /p:BuildProjectReferences=false /m + cmake --build build --target ResourceUpdater --config Release --parallel $env:NUMBER_OF_PROCESSORS + + - name: Install Resource Updater + run: | + cmake --install build --component ResourceUpdater --config Release --prefix tools/ResourceUpdater - name: Save ResourceUpdater.exe to cache if: always() && steps.cache-resupd.outputs.cache-hit != 'true' @@ -180,8 +184,8 @@ jobs: with: key: Resource-updater-${{ hashFiles('./tools/ResourceUpdater/main.cpp') }} path: | - ./tools/ResourceUpdater/x64/Release/opencv_world4_maa.dll - ./tools/ResourceUpdater/x64/Release/ResourceUpdater.exe + ./tools/ResourceUpdater/opencv_world4_maa.dll + ./tools/ResourceUpdater/ResourceUpdater.exe - name: Download txwy id: download-txwy @@ -189,7 +193,7 @@ jobs: continue-on-error: true with: name: txwy - path: ./tools/ResourceUpdater/x64/Release/Overseas/tw/gamedata/excel + path: ./tools/ResourceUpdater/Overseas/tw/gamedata/excel - name: Delay txwy if: steps.download-txwy.outcome == 'failure' @@ -201,7 +205,7 @@ jobs: uses: actions/download-artifact@v5 with: name: txwy - path: ./tools/ResourceUpdater/x64/Release/Overseas/tw/gamedata/excel + path: ./tools/ResourceUpdater/Overseas/tw/gamedata/excel - name: Download Overseas id: download-overseas @@ -209,7 +213,7 @@ jobs: continue-on-error: true with: name: overseas - path: ./tools/ResourceUpdater/x64/Release/Overseas + path: ./tools/ResourceUpdater/Overseas - name: Delay Overseas if: steps.download-overseas.outcome == 'failure' @@ -221,7 +225,7 @@ jobs: uses: actions/download-artifact@v5 with: name: overseas - path: ./tools/ResourceUpdater/x64/Release/Overseas + path: ./tools/ResourceUpdater/Overseas - name: Download Official id: download-official @@ -229,7 +233,7 @@ jobs: continue-on-error: true with: name: official - path: ./tools/ResourceUpdater/x64/Release/Official + path: ./tools/ResourceUpdater/Official - name: Delay Official if: steps.download-official.outcome == 'failure' @@ -241,11 +245,11 @@ jobs: uses: actions/download-artifact@v5 with: name: official - path: ./tools/ResourceUpdater/x64/Release/Official + path: ./tools/ResourceUpdater/Official - name: Run Resource Updater run: | - ./tools/ResourceUpdater/x64/Release/ResourceUpdater.exe + ./tools/ResourceUpdater/ResourceUpdater.exe - name: Task Sorting id: task_sorting diff --git a/CMakeLists.txt b/CMakeLists.txt index e5ac903184..cbbed7669d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,7 +16,7 @@ option(INSTALL_RESOURCE "install resource" OFF) option(INSTALL_FLATTEN "do not use bin lib include directory" ON) option(WITH_EMULATOR_EXTRAS "build with emulator extras" ${WIN32}) option(BUILD_SMOKE_TEST "build smoke_test" OFF) -option(BUILD_RES_UPDATER "build resource_updater" OFF) +option(BUILD_RES_UPDATER "build ResourceUpdater" OFF) include(${PROJECT_SOURCE_DIR}/MaaDeps/maadeps.cmake) @@ -128,11 +128,19 @@ if (BUILD_SMOKE_TEST) endif (BUILD_SMOKE_TEST) if (BUILD_RES_UPDATER) - add_executable(resource_updater tools/ResourceUpdater/main.cpp) - target_include_directories(resource_updater PUBLIC include PRIVATE src/MaaCore) # For Utils/Time.hpp - target_link_libraries(resource_updater HeaderOnlyLibraries ${OpenCV_LIBS}) + add_executable(ResourceUpdater tools/ResourceUpdater/main.cpp) + target_include_directories(ResourceUpdater PUBLIC include PRIVATE src/MaaCore) # For Utils/Time.hpp + target_link_libraries(ResourceUpdater HeaderOnlyLibraries ${OpenCV_LIBS}) if(LINUX) - target_link_libraries(resource_updater pthread) + target_link_libraries(ResourceUpdater pthread) + endif() + install(TARGETS ResourceUpdater DESTINATION . COMPONENT ResourceUpdater) + + # Copy from maadeps_install, adding component + if(MSVC) + install(DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/MaaDeps/runtime/${MAADEPS_TRIPLET}/$<$:msvc-debug/>" DESTINATION . USE_SOURCE_PERMISSIONS COMPONENT ResourceUpdater) + else() + install(DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/MaaDeps/runtime/${MAADEPS_TRIPLET}/" DESTINATION . USE_SOURCE_PERMISSIONS COMPONENT ResourceUpdater) endif() endif (BUILD_RES_UPDATER) diff --git a/tools/ResourceUpdater/.gitignore b/tools/ResourceUpdater/.gitignore new file mode 100644 index 0000000000..9866f39362 --- /dev/null +++ b/tools/ResourceUpdater/.gitignore @@ -0,0 +1,7 @@ +# for win +*.exe +*.dll +# for linux & macos +ResourceUpdater +*.so.* +*.dylib.* diff --git a/tools/ResourceUpdater/clone_data_repo.ps1 b/tools/ResourceUpdater/clone_data_repo.ps1 index 118fdc4acb..eda7e96ac8 100644 --- a/tools/ResourceUpdater/clone_data_repo.ps1 +++ b/tools/ResourceUpdater/clone_data_repo.ps1 @@ -2,8 +2,8 @@ $scriptRoot = $PSScriptRoot Push-Location -New-Item -ItemType Directory -Path "$scriptRoot/x64/Release/" -Force | Out-Null -Set-Location "$scriptRoot/x64/Release/" +New-Item -ItemType Directory -Path "$scriptRoot/" -Force | Out-Null +Set-Location "$scriptRoot/" if (Test-Path -Path "Official") { Remove-Item "Official" -Recurse -Force } if (Test-Path -Path "Overseas") { Remove-Item "Overseas" -Recurse -Force } @@ -76,7 +76,7 @@ $jobs += Start-Job -ScriptBlock { $scriptRoot = $using:scriptRoot # Change to the target directory - Set-Location -Path "$scriptRoot/x64/Release/Overseas/tw/gamedata/excel" + Set-Location -Path "$scriptRoot/Overseas/tw/gamedata/excel" # Define the base URL $baseUrl = "https://penguin-stats.io/PenguinStats/api/v2/stages?server="