From 5730fdb73d2dac7c8e9ce2fd9e33bb78069e479f Mon Sep 17 00:00:00 2001 From: briaguya <70942617+briaguya0@users.noreply.github.com> Date: Sat, 25 Jul 2026 03:55:59 -0400 Subject: [PATCH] Build soh.o2r in CI without libultraship or soh SOH_TOOLS_ONLY returns from the root CMakeLists once the asset tools are declared, before libultraship and soh are added, so a configure that only needs soh-o2r-packer never reaches LUS's find_package(SDL2 REQUIRED). That lets generate-soh-otr drop building SDL2 from source, SDL2_net, and the deps cache that existed to hold the SDL2 tarball -- eleven steps down to six. Verified a tools-only build produces the archive with all 1,042 entries matching. The tool targets move above the sub-projects so the early return can sit between them; they only ever needed torch. The packer creates its output directory, which previously came for free from soh's build directory. --- .github/workflows/generate-builds.yml | 29 +------------- CMakeLists.txt | 50 ++++++++++++++---------- soh/assets/tools/soh-o2r-packer/main.cpp | 1 + 3 files changed, 31 insertions(+), 49 deletions(-) diff --git a/.github/workflows/generate-builds.yml b/.github/workflows/generate-builds.yml index 7cf2185a00..3888664cdb 100644 --- a/.github/workflows/generate-builds.yml +++ b/.github/workflows/generate-builds.yml @@ -26,40 +26,13 @@ jobs: run: | sudo apt-get update sudo apt-get install -y $(cat linux-build-deps/apt.txt) - - name: Restore Cached deps folder - uses: actions/cache/restore@v5 - with: - key: ${{ runner.os }}-deps-${{ github.ref }}-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-deps-${{ github.ref }}- - ${{ runner.os }}-deps- - path: deps - - name: Create deps folder - run: mkdir -p deps - name: Add ccache to PATH run: | echo "/usr/lib/ccache" >> "$GITHUB_PATH" echo "/usr/local/opt/ccache/libexec" >> "$GITHUB_PATH" - - name: Install latest SDL - run: | - if [ ! -d "deps/SDL2-2.30.3" ]; then - wget https://github.com/libsdl-org/SDL/releases/download/release-2.30.3/SDL2-2.30.3.tar.gz - tar -xzf SDL2-2.30.3.tar.gz -C deps - fi - cd deps/SDL2-2.30.3 - ./configure --enable-hidapi-libusb - make -j 10 - sudo make install - sudo cp -av /usr/local/lib/libSDL* /lib/x86_64-linux-gnu/ - - uses: ./.github/actions/install-sdl2-net - - name: Copy SDL libs to multiarch dir - run: sudo cp -av /usr/local/lib/libSDL* /lib/x86_64-linux-gnu/ - - name: Remove distro tinyxml2 - run: sudo apt-get remove libtinyxml2-dev - - uses: ./.github/actions/install-tinyxml2 - name: Generate soh.o2r run: | - cmake --no-warn-unused-cli -H. -Bbuild-cmake -GNinja -DCMAKE_BUILD_TYPE:STRING=Release + cmake --no-warn-unused-cli -H. -Bbuild-cmake -GNinja -DCMAKE_BUILD_TYPE:STRING=Release -DSOH_TOOLS_ONLY=ON cmake --build build-cmake --config Release --target GenerateSohOtr -j3 - name: Upload soh.o2r uses: actions/upload-artifact@v7 diff --git a/CMakeLists.txt b/CMakeLists.txt index dae6ee87f2..b6ab7a1179 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -216,27 +216,6 @@ FetchContent_Declare( ) FetchContent_MakeAvailable(torch) -################################################################################ -# Sub-projects -################################################################################ -add_subdirectory(libultraship ${CMAKE_BINARY_DIR}/libultraship) -target_compile_options(libultraship PRIVATE "${WARNING_OVERRIDE}") -target_compile_definitions(libultraship PUBLIC INCLUDE_MPQ_SUPPORT) -add_subdirectory(soh) - -set_property(TARGET soh PROPERTY APPIMAGE_DESKTOP_FILE_TERMINAL YES) -set_property(TARGET soh PROPERTY APPIMAGE_DESKTOP_FILE "${CMAKE_SOURCE_DIR}/scripts/linux/appimage/soh.desktop") -set_property(TARGET soh PROPERTY APPIMAGE_ICON_FILE "${CMAKE_BINARY_DIR}/sohIcon.png") - -if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") -install(FILES "${CMAKE_BINARY_DIR}/soh/soh.o2r" DESTINATION . COMPONENT ship) -install(DIRECTORY "${CMAKE_SOURCE_DIR}/soh/assets/yml/" DESTINATION ./assets COMPONENT ship) -endif() - -if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows") -install(DIRECTORY "${CMAKE_SOURCE_DIR}/soh/assets/yml/" DESTINATION ./assets COMPONENT ship) -endif() - # Build-time ROM extraction. soh links torch as a static library, which compiles out torch's # own CLI, so this supplies an entry point around the same code the game runs. add_executable(soh-torch @@ -301,6 +280,35 @@ add_custom_target( # ExtractAssets produced soh.o2r as well as the rom archives, so keep doing that. add_dependencies(ExtractAssets GenerateSohOtr) +# The asset tools only need torch, so a tools-only configure can skip libultraship and soh +# entirely -- that is all CI needs to produce soh.o2r. +option(SOH_TOOLS_ONLY "Configure only the asset tools, skipping libultraship and soh" OFF) +if(SOH_TOOLS_ONLY) + file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/soh) + return() +endif() + +################################################################################ +# Sub-projects +################################################################################ +add_subdirectory(libultraship ${CMAKE_BINARY_DIR}/libultraship) +target_compile_options(libultraship PRIVATE "${WARNING_OVERRIDE}") +target_compile_definitions(libultraship PUBLIC INCLUDE_MPQ_SUPPORT) +add_subdirectory(soh) + +set_property(TARGET soh PROPERTY APPIMAGE_DESKTOP_FILE_TERMINAL YES) +set_property(TARGET soh PROPERTY APPIMAGE_DESKTOP_FILE "${CMAKE_SOURCE_DIR}/scripts/linux/appimage/soh.desktop") +set_property(TARGET soh PROPERTY APPIMAGE_ICON_FILE "${CMAKE_BINARY_DIR}/sohIcon.png") + +if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") +install(FILES "${CMAKE_BINARY_DIR}/soh/soh.o2r" DESTINATION . COMPONENT ship) +install(DIRECTORY "${CMAKE_SOURCE_DIR}/soh/assets/yml/" DESTINATION ./assets COMPONENT ship) +endif() + +if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows") +install(DIRECTORY "${CMAKE_SOURCE_DIR}/soh/assets/yml/" DESTINATION ./assets COMPONENT ship) +endif() + if(CMAKE_SYSTEM_NAME MATCHES "Linux") find_package(ImageMagick COMPONENTS convert) if (ImageMagick_FOUND) diff --git a/soh/assets/tools/soh-o2r-packer/main.cpp b/soh/assets/tools/soh-o2r-packer/main.cpp index bad554bb8c..6048c06206 100644 --- a/soh/assets/tools/soh-o2r-packer/main.cpp +++ b/soh/assets/tools/soh-o2r-packer/main.cpp @@ -67,6 +67,7 @@ int main(int argc, char** argv) { fs::copy_file(path, stage / rel, fs::copy_options::overwrite_existing); } + fs::create_directories(outPath.parent_path(), ec); fs::remove(outPath, ec); Companion::Pack(stage.string(), outPath.string(), ArchiveType::O2R, version); fs::remove_all(stage, ec);