diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..204beb4 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,11 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..ab30f88 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,34 @@ +name: CI + +on: + pull_request: + merge_group: + push: + branches: + - main + tags: + - '*' + +jobs: + elf: + runs-on: ubuntu-latest + name: Build Practice Mod ELFs + + steps: + - name: Checkout + uses: actions/checkout@v6 + with: + fetch-depth: 0 + submodules: 'recursive' + + - name: Build + run: ./build.sh Release + + - name: Upload elf + uses: actions/upload-artifact@v6 + with: + name: Release Elf + if-no-files-found: error + path: | + cmake-build-release-docker/prime2-practice + cmake-build-release-docker/prime2-practice.map diff --git a/.github/workflows/dependency.yml b/.github/workflows/dependency.yml new file mode 100644 index 0000000..1ecac25 --- /dev/null +++ b/.github/workflows/dependency.yml @@ -0,0 +1,20 @@ +name: Dependency auto-merge +on: pull_request_target + +permissions: + contents: write + pull-requests: write + +jobs: + dependency: + runs-on: ubuntu-latest + if: ${{ github.event.pull_request.user.login == 'dependabot[bot]' || github.event.pull_request.user.login == 'pre-commit-ci[bot]' }} + steps: + - name: Enable auto-merge for Dependency PRs + run: gh pr merge --auto --merge "$PR_URL" + env: + PR_URL: ${{github.event.pull_request.html_url}} + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + + - name: Automatically approve the PR + uses: hmarr/auto-approve-action@v4 diff --git a/CMakeLists.txt b/CMakeLists.txt index 3548b76..9734e8a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -124,8 +124,11 @@ set(SOURCE_FILES src/hooks.cpp ) -add_gc_static_binary(prime2-practice src/prime-practice.lst default.dol +add_gc_static_binary(prime2-practice src/prime-practice.lst src/patcher_config.toml src/opening_practice.bnr ${SOURCE_FILES}) +if(CREATE_PATCHED_DOL) + patch_dol(prime2-practice default.dol "${CREATE_PATCHED_DOL}") +endif() \ No newline at end of file diff --git a/PrimeAPI2/PrimeAPI.cmake b/PrimeAPI2/PrimeAPI.cmake index 68abadc..20785fc 100644 --- a/PrimeAPI2/PrimeAPI.cmake +++ b/PrimeAPI2/PrimeAPI.cmake @@ -112,7 +112,7 @@ macro(add_symbol_object output_file symbol_list) endmacro() # Macro to get the required link arguments in place -macro(add_gc_static_binary name symbol_list base_dol patch_toml bnr_file) +macro(add_gc_static_binary name symbol_list patch_toml bnr_file) add_executable(${name} ${ARGN} "${CMAKE_CURRENT_BINARY_DIR}/dol_symbols.o" "${CMAKE_CURRENT_BINARY_DIR}/patcher_config.o" @@ -133,27 +133,22 @@ macro(add_gc_static_binary name symbol_list base_dol patch_toml bnr_file) # add internal as an additional include directory, and also as a dependency to force rebuilds target_include_directories(${name} PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/internal/") +endmacro() +macro(patch_dol name base_dol output_dol) # Create the patched dol add_custom_command( - OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/default_mod.dol" + OUTPUT "${output_dol}" COMMAND "${GCN_STATIC_PATCHER}" -m "${CMAKE_CURRENT_BINARY_DIR}/${name}" -i "${CMAKE_CURRENT_SOURCE_DIR}/${base_dol}" - -o "${CMAKE_CURRENT_BINARY_DIR}/default_mod.dol" + -o "${output_dol}" --overwrite DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${base_dol}" "${CMAKE_CURRENT_BINARY_DIR}/${name}" ) add_custom_target( patch_dol ALL - DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/default_mod.dol" + DEPENDS "${output_dol}" SOURCES "${base_dol}" ) - - install(FILES "${CMAKE_CURRENT_BINARY_DIR}/default_mod.dol" - DESTINATION "files/" - RENAME "default.dol") - install(FILES "${CMAKE_CURRENT_BINARY_DIR}/default_mod.dol" - DESTINATION "sys/" - RENAME "main.dol") -endmacro() +endmacro() \ No newline at end of file diff --git a/build.sh b/build.sh index 3f52a64..1d85b69 100755 --- a/build.sh +++ b/build.sh @@ -7,6 +7,8 @@ BUILD_TYPE_LOWER="$(echo "$BUILD_TYPE" | tr '[:upper:]' '[:lower:]')" DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd "${DIR}" +# -DCREATE_PATCHED_DOL= default_mod.dol + # these are exported so build_and_copy.sh can use them too IMAGE="ghcr.io/metroidprimemodding/gcn-static-patcher/build:latest" CMAKE_DIR="cmake-build-${BUILD_TYPE_LOWER}-docker" # same as my clion for convenience @@ -15,7 +17,15 @@ EXTERNAL_BUILD_DIR="${EXTERNAL_SRC_DIR}${CMAKE_DIR}" DOCKER_SRC_DIR="/tmp/prime2-practice-mod/" DOCKER_BUILD_DIR="${DOCKER_SRC_DIR}${CMAKE_DIR}" +if [ "${CREATE_PATCHED_DOL}" != "" ]; then + EXTRA_CMAKE_ARGUMENTS="-DCREATE_PATCHED_DOL=${DOCKER_BUILD_DIR}/${CREATE_PATCHED_DOL}" +fi + mkdir -p "${EXTERNAL_BUILD_DIR}" # launch a build in a docker container first (this does the same thing intellij would do) -docker run --rm -v "${EXTERNAL_SRC_DIR}":"${DOCKER_SRC_DIR}" "${IMAGE}" bash -c "cd \"${DOCKER_BUILD_DIR}\" && cmake .. -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -G Ninja && cmake --build . --config ${BUILD_TYPE}" +docker run --rm \ + -w "${DOCKER_BUILD_DIR}" \ + -v "${EXTERNAL_SRC_DIR}":"${DOCKER_SRC_DIR}" \ + "${IMAGE}" \ + bash -c "cmake "${DOCKER_SRC_DIR}" -DCMAKE_BUILD_TYPE=${BUILD_TYPE} ${EXTRA_CMAKE_ARGUMENTS} -G Ninja && cmake --build . --config ${BUILD_TYPE}" diff --git a/build_and_copy.sh b/build_and_copy.sh index c2b7acf..187de9a 100755 --- a/build_and_copy.sh +++ b/build_and_copy.sh @@ -1,5 +1,9 @@ #!/bin/bash -xe +test -f default.dol || (echo "default.dol not found" && exit 1) + +CREATE_PATCHED_DOL=default_mod.dol + # call build with all params; this will set some env vars we use later source ./build.sh "$@"