Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -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"
34 changes: 34 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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
20 changes: 20 additions & 0 deletions .github/workflows/dependency.yml
Original file line number Diff line number Diff line change
@@ -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
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
19 changes: 7 additions & 12 deletions PrimeAPI2/PrimeAPI.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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()
12 changes: 11 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}"
4 changes: 4 additions & 0 deletions build_and_copy.sh
Original file line number Diff line number Diff line change
@@ -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 "$@"

Expand Down