Skip to content

Commit 8816a61

Browse files
authored
Merge pull request #3 from henriquegemignani/feature/no-dol-build
Add support for building the mod without a dol being present + CI
2 parents 4760ca3 + 8878889 commit 8816a61

7 files changed

Lines changed: 91 additions & 14 deletions

File tree

.github/dependabot.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: "github-actions"
9+
directory: "/"
10+
schedule:
11+
interval: "daily"

.github/workflows/ci.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
merge_group:
6+
push:
7+
branches:
8+
- main
9+
tags:
10+
- '*'
11+
12+
jobs:
13+
elf:
14+
runs-on: ubuntu-latest
15+
name: Build Practice Mod ELFs
16+
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v6
20+
with:
21+
fetch-depth: 0
22+
submodules: 'recursive'
23+
24+
- name: Build
25+
run: ./build.sh Release
26+
27+
- name: Upload elf
28+
uses: actions/upload-artifact@v6
29+
with:
30+
name: Release Elf
31+
if-no-files-found: error
32+
path: |
33+
cmake-build-release-docker/prime2-practice
34+
cmake-build-release-docker/prime2-practice.map

.github/workflows/dependency.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Dependency auto-merge
2+
on: pull_request_target
3+
4+
permissions:
5+
contents: write
6+
pull-requests: write
7+
8+
jobs:
9+
dependency:
10+
runs-on: ubuntu-latest
11+
if: ${{ github.event.pull_request.user.login == 'dependabot[bot]' || github.event.pull_request.user.login == 'pre-commit-ci[bot]' }}
12+
steps:
13+
- name: Enable auto-merge for Dependency PRs
14+
run: gh pr merge --auto --merge "$PR_URL"
15+
env:
16+
PR_URL: ${{github.event.pull_request.html_url}}
17+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
18+
19+
- name: Automatically approve the PR
20+
uses: hmarr/auto-approve-action@v4

CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,11 @@ set(SOURCE_FILES
124124
src/hooks.cpp
125125
)
126126

127-
add_gc_static_binary(prime2-practice src/prime-practice.lst default.dol
127+
add_gc_static_binary(prime2-practice src/prime-practice.lst
128128
src/patcher_config.toml
129129
src/opening_practice.bnr
130130
${SOURCE_FILES})
131131

132+
if(CREATE_PATCHED_DOL)
133+
patch_dol(prime2-practice default.dol "${CREATE_PATCHED_DOL}")
134+
endif()

PrimeAPI2/PrimeAPI.cmake

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ macro(add_symbol_object output_file symbol_list)
112112
endmacro()
113113

114114
# Macro to get the required link arguments in place
115-
macro(add_gc_static_binary name symbol_list base_dol patch_toml bnr_file)
115+
macro(add_gc_static_binary name symbol_list patch_toml bnr_file)
116116
add_executable(${name} ${ARGN}
117117
"${CMAKE_CURRENT_BINARY_DIR}/dol_symbols.o"
118118
"${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)
133133

134134
# add internal as an additional include directory, and also as a dependency to force rebuilds
135135
target_include_directories(${name} PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/internal/")
136+
endmacro()
136137

138+
macro(patch_dol name base_dol output_dol)
137139
# Create the patched dol
138140
add_custom_command(
139-
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/default_mod.dol"
141+
OUTPUT "${output_dol}"
140142
COMMAND "${GCN_STATIC_PATCHER}"
141143
-m "${CMAKE_CURRENT_BINARY_DIR}/${name}"
142144
-i "${CMAKE_CURRENT_SOURCE_DIR}/${base_dol}"
143-
-o "${CMAKE_CURRENT_BINARY_DIR}/default_mod.dol"
145+
-o "${output_dol}"
144146
--overwrite
145147
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${base_dol}" "${CMAKE_CURRENT_BINARY_DIR}/${name}"
146148
)
147149
add_custom_target(
148150
patch_dol ALL
149-
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/default_mod.dol"
151+
DEPENDS "${output_dol}"
150152
SOURCES "${base_dol}"
151153
)
152-
153-
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/default_mod.dol"
154-
DESTINATION "files/"
155-
RENAME "default.dol")
156-
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/default_mod.dol"
157-
DESTINATION "sys/"
158-
RENAME "main.dol")
159-
endmacro()
154+
endmacro()

build.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ BUILD_TYPE_LOWER="$(echo "$BUILD_TYPE" | tr '[:upper:]' '[:lower:]')"
77
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
88
cd "${DIR}"
99

10+
# -DCREATE_PATCHED_DOL= default_mod.dol
11+
1012
# these are exported so build_and_copy.sh can use them too
1113
IMAGE="ghcr.io/metroidprimemodding/gcn-static-patcher/build:latest"
1214
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}"
1517
DOCKER_SRC_DIR="/tmp/prime2-practice-mod/"
1618
DOCKER_BUILD_DIR="${DOCKER_SRC_DIR}${CMAKE_DIR}"
1719

20+
if [ "${CREATE_PATCHED_DOL}" != "" ]; then
21+
EXTRA_CMAKE_ARGUMENTS="-DCREATE_PATCHED_DOL=${DOCKER_BUILD_DIR}/${CREATE_PATCHED_DOL}"
22+
fi
23+
1824
mkdir -p "${EXTERNAL_BUILD_DIR}"
1925

2026
# launch a build in a docker container first (this does the same thing intellij would do)
21-
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}"
27+
docker run --rm \
28+
-w "${DOCKER_BUILD_DIR}" \
29+
-v "${EXTERNAL_SRC_DIR}":"${DOCKER_SRC_DIR}" \
30+
"${IMAGE}" \
31+
bash -c "cmake "${DOCKER_SRC_DIR}" -DCMAKE_BUILD_TYPE=${BUILD_TYPE} ${EXTRA_CMAKE_ARGUMENTS} -G Ninja && cmake --build . --config ${BUILD_TYPE}"

build_and_copy.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#!/bin/bash -xe
22

3+
test -f default.dol || (echo "default.dol not found" && exit 1)
4+
5+
CREATE_PATCHED_DOL=default_mod.dol
6+
37
# call build with all params; this will set some env vars we use later
48
source ./build.sh "$@"
59

0 commit comments

Comments
 (0)