Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use dtk-template for ninja build #216

Merged
merged 24 commits into from
Aug 17, 2024
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 4 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[flake8]
# E203: whitespace before ':'
# E501: line too long
extend-ignore = E203,E501
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@
*.bat text eol=crlf
*.sh text eol=lf
*.sha1 text eol=lf

# decomp-toolkit writes files with LF
config/**/*.txt text eol=lf
36 changes: 26 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,43 @@ jobs:
strategy:
fail-fast: false
matrix:
version: [usa, usa.demo]
version: [GPVE01, GPVE01_D17]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- name: Git config
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
- name: Prepare
run: cp -R /orig .
- name: Build
run: |
python configure.py -m -v ${{matrix.version}} --compilers /compilers/GC
ninja
python configure.py --map --version ${{ matrix.version }} \
--binutils /binutils --compilers /compilers
ninja all_source build/${{ matrix.version }}/progress.json \
build/${{ matrix.version }}/report.json
- name: Upload progress
if: github.ref == 'refs/heads/main'
continue-on-error: true
env:
PROGRESS_SLUG: pikmin2
PROGRESS_API_KEY: ${{secrets.PROGRESS_API_KEY}}
run: |
python tools/upload-progress.py -b https://progress.decomp.club/ -p pikmin2 -v ${{matrix.version}} \
build/pikmin2.${{matrix.version}}/main.dol.progress
python tools/upload_progress.py -b https://progress.decomp.club/ \
-p $PROGRESS_SLUG -v ${{ matrix.version }} \
build/${{ matrix.version }}/progress.json
- name: Upload map
uses: actions/upload-artifact@v4
with:
name: pikmin2UP-${{matrix.version}}.MAP
path: build/*/pikmin2UP.MAP
name: ${{ matrix.version }}_maps
path: build/${{ matrix.version }}/**/*.MAP
- name: Upload report
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.version }}_report
path: build/${{ matrix.version }}/report.json

build_make:
name: Build (legacy)
Expand All @@ -43,13 +57,15 @@ jobs:
strategy:
fail-fast: false
matrix:
version: [usa, usa.demo]
version: [GPVE01, GPVE01_D17]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- name: Git config
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
- name: Build
run: |
python configure.py --map --compilers /compilers/GC
make -j$(nproc) MAPGENFLAG=1 VERSION=${{matrix.version}} COMPILERS=/compilers/GC
make -j$(nproc) MAPGENFLAG=1 VERSION=${{matrix.version}}
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,11 @@ __pycache__
.ninja_log
newlines.py
objdiff.json

.idea
.ninja_*
.mypy_cache

orig/*/*
!orig/*/.gitkeep
/*.txt
8 changes: 4 additions & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"[c]": {
"files.encoding": "shiftjis",
"files.encoding": "utf8",
"editor.defaultFormatter": "ms-vscode.cpptools"
},
"[cpp]": {
"files.encoding": "shiftjis",
"files.encoding": "utf8",
"editor.defaultFormatter": "ms-vscode.cpptools"
},
"editor.tabSize": 4,
Expand Down Expand Up @@ -59,7 +59,7 @@
"ctype.h": "c",
"mem_funcs.h": "c",
"card.h": "c",
"FILE_POS.C": "cpp",
"FILE_POS.c": "cpp",
"ctype_api.h": "c"
}
}
}
125 changes: 68 additions & 57 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,24 @@ endif
#-------------------------------------------------------------------------------

NAME := pikmin2
VERSION ?= usa
#VERSION := usa.demo
VERSION ?= GPVE01
#VERSION := GPVE01_D17

ifeq ($(VERSION), usa)
VERNUM = 2
else ifeq ($(VERSION), usa.demo)
# only GPVE01 and GPVE01_D17 are implemented right now --EpochFlame

ifeq ($(VERSION), GPVE01)
VERNUM = 4
else ifeq ($(VERSION), GPVE01_D17)
VERNUM = 0
else ifeq ($(VERSION), GPVE01_D18)
VERNUM = 1
else ifeq ($(VERSION), GPVJ01)
VERNUM = 2
else ifeq ($(VERSION), GPVP01)
VERNUM = 3
# default to usa retail
else
VERNUM = 0
VERNUM = 4
endif

# Use the all-in-one updater after successful build? (Fails on non-windows platforms)
Expand Down Expand Up @@ -80,35 +89,35 @@ DEPENDS += $(MAKECMDGOALS:.o=.d)
MWCC_VERSION := 2.6
MWLD_VERSION := 2.6

# Tool versions (keep in sync with configure.py)
BINUTILS_TAG := 2.42-1
COMPILERS_TAG := 20240706
DTK_TAG := v0.9.4
SJISWRAP_TAG := v1.1.1
WIBO_TAG := 0.6.11

# Programs
POWERPC ?= tools/powerpc
BINUTILS ?= build/binutils
COMPILERS ?= build/compilers
DTK ?= build/tools/dtk
SJISWRAP ?= build/tools/sjiswrap.exe
WIBO ?= build/tools/wibo
ifeq ($(WINDOWS),1)
WINE :=
AS := $(POWERPC)/powerpc-eabi-as.exe
WRAPPER :=
AS := $(BINUTILS)/powerpc-eabi-as.exe
PYTHON := python
else
WIBO := $(shell command -v wibo 2> /dev/null)
ifdef WIBO
WINE ?= wibo
else
WINE ?= wine
endif
# Disable wine debug output for cleanliness
export WINEDEBUG ?= -all
AS := $(POWERPC)/powerpc-eabi-as
WRAPPER := $(WIBO)
AS := $(BINUTILS)/powerpc-eabi-as
PYTHON := python3
endif
COMPILERS ?= tools/mwcc_compiler
CC = $(WINE) $(COMPILERS)/$(MWCC_VERSION)/mwcceppc.exe
LD := $(WINE) $(COMPILERS)/$(MWLD_VERSION)/mwldeppc.exe
DTK := tools/dtk
ELF2DOL := $(DTK) elf2dol
SHASUM := $(DTK) shasum
CC = $(WRAPPER) $(SJISWRAP) $(COMPILERS)/GC/$(MWCC_VERSION)/mwcceppc.exe
LD := $(WRAPPER) $(COMPILERS)/GC/$(MWLD_VERSION)/mwldeppc.exe

ifneq ($(WINDOWS),1)
TRANSFORM_DEP := tools/transform-dep.py
TRANSFORM_DEP := tools/transform_dep.py
else
TRANSFORM_DEP := tools/transform-win.py
TRANSFORM_DEP := tools/transform_win.py
endif

# Options
Expand All @@ -125,7 +134,7 @@ ifeq ($(VERBOSE),0)
LDFLAGS := $(MAPGEN) -fp hard -nodefaults -w off
endif
LIBRARY_LDFLAGS := -nodefaults -fp hard -proc gekko
CFLAGS := -Cpp_exceptions off -enum int -inline auto -proc gekko -RTTI off -fp hard -fp_contract on -rostr -O4,p -use_lmw_stmw on -common on -sdata 8 -sdata2 8 -nodefaults -MMD -DVERNUM=$(VERNUM) $(INCLUDES)
CFLAGS := -Cpp_exceptions off -enum int -inline auto -proc gekko -RTTI off -fp hard -fp_contract on -rostr -O4,p -use_lmw_stmw on -common on -multibyte -sdata 8 -sdata2 8 -nodefaults -MMD -DVERNUM=$(VERNUM) $(INCLUDES)

ifeq ($(VERBOSE),0)
# this set of ASFLAGS generates no warnings.
Expand All @@ -152,24 +161,45 @@ DUMMY != mkdir -p $(ALL_DIRS)
LDSCRIPT := ldscript.lcf

$(DOL): $(ELF) | $(DTK)
$(QUIET) $(ELF2DOL) $< $@
$(QUIET) $(SHASUM) -c sha1/$(NAME).$(VERSION).sha1
$(QUIET) $(DTK) elf2dol $< $@
$(QUIET) $(DTK) shasum -c sha1/$(NAME).$(VERSION).sha1
ifneq ($(findstring -map,$(LDFLAGS)),)
$(QUIET) $(PYTHON) tools/calcprogress.py $(DOL) $(MAP)
endif
ifeq ($(USE_AOI),1)
$(WINE) ./aoi.exe
./aoi.exe
endif

clean:
rm -f -d -r build

$(DTK): tools/dtk_version
$(DTK):
@echo "Downloading $@"
$(QUIET) mkdir -p $(dir $@)
$(QUIET) $(PYTHON) tools/download_tool.py dtk $@ --tag $(DTK_TAG)

$(SJISWRAP):
@echo "Downloading $@"
$(QUIET) mkdir -p $(dir $@)
$(QUIET) $(PYTHON) tools/download_tool.py sjiswrap $@ --tag $(SJISWRAP_TAG)

$(BINUTILS):
@echo "Downloading $@"
$(QUIET) $(PYTHON) tools/download_dtk.py $< $@
$(QUIET) mkdir -p $(dir $@)
$(QUIET) $(PYTHON) tools/download_tool.py binutils $@ --tag $(BINUTILS_TAG)

$(COMPILERS):
@echo "Downloading $@"
$(QUIET) mkdir -p $(dir $@)
$(QUIET) $(PYTHON) tools/download_tool.py compilers $@ --tag $(COMPILERS_TAG)

$(WIBO):
@echo "Downloading $@"
$(QUIET) mkdir -p $(dir $@)
$(QUIET) $(PYTHON) tools/download_tool.py wibo $@ --tag $(WIBO_TAG)

# ELF creation makefile instructions
$(ELF): $(O_FILES) $(LDSCRIPT)
$(ELF): $(O_FILES) $(LDSCRIPT) $(WRAPPER) $(COMPILERS)
@echo Linking ELF $@
$(QUIET) @echo $(O_FILES) > build/o_files
$(QUIET) $(LD) $(LDFLAGS) -o $@ -lcf $(LDSCRIPT) @build/o_files
Expand All @@ -185,46 +215,27 @@ ifneq ($(MAKECMDGOALS), clean)
-include $(DEPENDS)
endif

$(BUILD_DIR)/%.o: %.s
$(BUILD_DIR)/%.o: %.s | $(BINUTILS) $(DTK)
@echo Assembling $<
$(QUIET) mkdir -p $(dir $@)
$(QUIET) $(AS) $(ASFLAGS) -o $@ $<
$(QUIET) $(DTK) elf fixup $@ $@

# for files with capitalized .C extension
$(BUILD_DIR)/%.o: %.C
$(BUILD_DIR)/%.o: %.c | $(WRAPPER) $(COMPILERS) $(SJISWRAP)
@echo "Compiling " $<
$(QUIET) mkdir -p $(dir $@)
$(QUIET) $(CC) $(CFLAGS) -c -o $(dir $@) $<

$(BUILD_DIR)/%.o: %.c
$(BUILD_DIR)/%.o: %.cp | $(WRAPPER) $(COMPILERS) $(SJISWRAP)
@echo "Compiling " $<
$(QUIET) mkdir -p $(dir $@)
$(QUIET) $(CC) $(CFLAGS) -c -o $(dir $@) $<

$(BUILD_DIR)/%.o: %.cp
$(BUILD_DIR)/%.o: %.cpp | $(WRAPPER) $(COMPILERS) $(SJISWRAP)
@echo "Compiling " $<
$(QUIET) mkdir -p $(dir $@)
$(QUIET) $(CC) $(CFLAGS) -c -o $(dir $@) $<

$(BUILD_DIR)/%.o: %.cpp
@echo "Compiling " $<
$(QUIET) mkdir -p $(dir $@)
$(QUIET) $(CC) $(CFLAGS) -c -o $(dir $@) $<

### Extremely lazy recipes for generating context ###
# Example usage: make build/pikmin2.usa/src/plugProjectYamashitaU/farmMgr.h
$(BUILD_DIR)/%.h: %.c
@echo "Compiling and generating context for " $<
$(QUIET) $(CC) $(CFLAGS) -E -c -o $@ $<

$(BUILD_DIR)/%.h: %.cp
@echo "Compiling and generating context for " $<
$(QUIET) $(CC) $(CFLAGS) -E -c -o $@ $<

$(BUILD_DIR)/%.h: %.cpp
@echo "Compiling and generating context for " $<
$(QUIET) $(CC) $(CFLAGS) -E -c -o $@ $<

### Debug Print ###

print-% : ; $(info $* is a $(flavor $*) variable set to [$($*)]) @true
Loading