Skip to content

Commit

Permalink
Update to latest dtk template
Browse files Browse the repository at this point in the history
  • Loading branch information
henriquegemignani committed Sep 4, 2024
1 parent 31ff5cf commit 66867d0
Show file tree
Hide file tree
Showing 14 changed files with 1,166 additions and 530 deletions.
File renamed without changes.
26 changes: 13 additions & 13 deletions config/G2ME01/splits.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
Sections:
.init type:code
extab type:rodata
extabindex type:rodata
.text type:code
.ctors type:rodata
.dtors type:rodata
.rodata type:rodata
.data type:data
.bss type:bss
.sdata type:data
.sbss type:bss
.sdata2 type:rodata
.sbss2 type:bss
.init type:code align:4
extab type:rodata align:16
extabindex type:rodata align:32
.text type:code align:4
.ctors type:rodata align:16
.dtors type:rodata align:32
.rodata type:rodata align:32
.data type:data align:32
.bss type:bss align:32
.sdata type:data align:32
.sbss type:bss align:32
.sdata2 type:rodata align:32
.sbss2 type:bss align:4

MetroidPrime/main.cpp:
.text start:0x800053B8 end:0x80008B60
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
132 changes: 81 additions & 51 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,11 @@
# Append --help to see available options.
###

import sys
import argparse

import sys
from pathlib import Path
from tools.project import (
Object,
ProjectConfig,
calculate_progress,
generate_build,
is_windows,
)
from typing import Any, Dict, List
from tools.project import *

# Game versions
DEFAULT_VERSION = 0
Expand All @@ -35,106 +29,135 @@
"R3MP01", # 5
]

if len(VERSIONS) > 1:
versions_str = ", ".join(VERSIONS[:-1]) + f" or {VERSIONS[-1]}"
else:
versions_str = VERSIONS[0]

parser = argparse.ArgumentParser()
parser.add_argument(
"mode",
choices=["configure", "progress"],
default="configure",
help="configure or progress (default: configure)",
help="script mode (default: configure)",
nargs="?",
)
parser.add_argument(
"-v",
"--version",
dest="version",
choices=VERSIONS,
type=str.upper,
default=VERSIONS[DEFAULT_VERSION],
help=f"version to build ({versions_str})",
help="version to build",
)
parser.add_argument(
"--build-dir",
dest="build_dir",
metavar="DIR",
type=Path,
default=Path("build"),
help="base build directory (default: build)",
)
parser.add_argument(
"--binutils",
metavar="BINARY",
type=Path,
help="path to binutils (optional)",
)
parser.add_argument(
"--compilers",
dest="compilers",
metavar="DIR",
type=Path,
help="path to compilers (optional)",
)
parser.add_argument(
"--map",
dest="map",
action="store_true",
help="generate map file(s)",
)
parser.add_argument(
"--debug",
dest="debug",
action="store_true",
help="build with debug info (non-matching)",
)
if not is_windows():
parser.add_argument(
"--wrapper",
dest="wrapper",
metavar="BINARY",
type=Path,
help="path to wibo or wine (optional)",
)
parser.add_argument(
"--build-dtk",
dest="build_dtk",
"--dtk",
metavar="BINARY | DIR",
type=Path,
help="path to decomp-toolkit binary or source (optional)",
)
parser.add_argument(
"--objdiff",
metavar="BINARY | DIR",
type=Path,
help="path to decomp-toolkit source (optional)",
help="path to objdiff-cli binary or source (optional)",
)
parser.add_argument(
"--sjiswrap",
dest="sjiswrap",
metavar="EXE",
type=Path,
help="path to sjiswrap.exe (optional)",
)
parser.add_argument(
"--verbose",
dest="verbose",
action="store_true",
help="print verbose output",
)
parser.add_argument(
"--non-matching",
dest="non_matching",
action="store_true",
help="builds equivalent (but non-matching) or modded objects",
)
args = parser.parse_args()

config = ProjectConfig()
config.version = args.version.upper()
if config.version not in VERSIONS:
sys.exit(f"Invalid version '{config.version}', expected {versions_str}")
config.version = str(args.version)
version_num = VERSIONS.index(config.version)

# Apply arguments
config.build_dir = args.build_dir
config.build_dtk_path = args.build_dtk
config.dtk_path = args.dtk
config.objdiff_path = args.objdiff
config.binutils_path = args.binutils
config.compilers_path = args.compilers
config.debug = args.debug
config.generate_map = args.map
config.non_matching = args.non_matching
config.sjiswrap_path = args.sjiswrap
if not is_windows():
config.wrapper = args.wrapper
# Don't build asm unless we're --non-matching
if not config.non_matching:
config.asm_dir = None

# Tool versions
config.compilers_tag = "20230715"
config.dtk_tag = "v0.5.7"
config.binutils_tag = "2.42-1"
config.compilers_tag = "20240706"
config.dtk_tag = "v0.9.4"
config.objdiff_tag = "v2.0.0-beta.5"
config.sjiswrap_tag = "v1.1.1"
config.wibo_tag = "0.6.3"
config.wibo_tag = "0.6.11"

# Project
config.config_path = Path("config") / config.version / "config.yml"
config.check_sha_path = Path("orig") / f"{config.version}.sha1"
config.check_sha_path = Path("config") / config.version / "build.sha1"
config.asflags = [
"-mgekko",
"--strip-local-absolute",
"-I include",
f"-I build/{config.version}/include",
f"--defsym version={version_num}",
]
config.ldflags = [
"-fp hardware",
"-nodefaults",
# "-warn off",
"-listclosure",
]
# Use for any additional files that should cause a re-configure when modified
config.reconfig_deps = []

# Base flags, common to most GC/Wii games.
# Generally leave untouched, with overrides added below.
Expand All @@ -147,7 +170,6 @@
"-Cpp_exceptions off",
# "-W all",
"-O4,p",
#"-g",
"-inline auto",
'-pragma "cats off"',
'-pragma "warn_notinlined off"',
Expand All @@ -156,10 +178,11 @@
"-RTTI off",
"-fp_contract on",
"-str reuse",
"-multibyte", # For Wii compilers, replace with `-enc SJIS`
"-i include",
"-i libc",
f"-i build/{config.version}/include",
f"-DVERSION={version_num}",
#"-D_DEBUG=1",
]

cflags_base_dbg = [
Expand All @@ -186,12 +209,6 @@
"-D_DEBUG=1",
]

# GC 3.0 and above require -enc SJIS instead of -multibyte
if version_num >= 3:
cflags_base.append("-enc SJIS")
else:
cflags_base.append("-multibyte")

# Debug flags
if config.debug:
cflags_base.extend(["-sym on", "-DDEBUG=1"])
Expand All @@ -205,6 +222,7 @@
"-str reuse,pool,readonly",
"-gccinc",
"-common off",
# "-inline auto",
]

# Retro flags
Expand Down Expand Up @@ -235,31 +253,33 @@
# RELs not yet set up for non-USA versions
config.build_rels = False


# Helper function for Dolphin libraries
def DolphinLib(lib_name, objects, debug=False):
def DolphinLib(lib_name: str, objects: List[Object], debug=False) -> Dict[str, Any]:
return {
"lib": lib_name,
"mw_version": "GC/1.2.5n",
"cflags": cflags_base if not debug else cflags_base_dbg,
"cflags": cflags_base,
"progress_category": "sdk",
"host": False,
"objects": objects,
}


# Helper function for REL script objects
def Rel(lib_name, objects):
def Rel(lib_name: str, objects: List[Object]) -> Dict[str, Any]:
return {
"lib": lib_name,
"mw_version": "GC/2.7",
"mw_version": "GC/1.3.2",
"cflags": cflags_rel,
"progress_category": "game",
"host": True,
"objects": objects,
}


Matching = True
NonMatching = False
Matching = True # Object matches and should be linked
NonMatching = False # Object does not match and should not be linked
Equivalent = config.non_matching # Object should be linked when configured with --non-matching

config.warn_missing_config = True
config.warn_missing_source = False
Expand All @@ -268,6 +288,7 @@ def Rel(lib_name, objects):
"lib": "MetroidPrime",
"cflags": cflags_retro,
"mw_version": "GC/2.7",
"progress_category": "game",
"host": True,
"objects": [
Object(NonMatching, "MetroidPrime/main.cpp"),
Expand All @@ -291,6 +312,7 @@ def Rel(lib_name, objects):
"lib": "Kyoto_CW",
"mw_version": "GC/2.7",
"cflags": cflags_retro,
"progress_category": "game",
"host": True,
"objects": [
Object(Matching, "Kyoto/Basics/CStopwatch.cpp"),
Expand All @@ -311,6 +333,7 @@ def Rel(lib_name, objects):
"lib": "Runtime.PPCEABI.H",
"mw_version": config.linker_version,
"cflags": cflags_runtime,
"progress_category": "sdk", # str | List[str]
"host": False,
"objects": [
Object(Matching, "Runtime/global_destructor_chain.c"),
Expand Down Expand Up @@ -396,12 +419,19 @@ def Rel(lib_name, objects):
),
]

# Optional extra categories for progress tracking
# Adjust as desired for your project
config.progress_categories = [
ProgressCategory("game", "Game Code"),
ProgressCategory("sdk", "SDK Code"),
]
config.progress_each_module = args.verbose

if args.mode == "configure":
# Write build.ninja and objdiff.json
generate_build(config)
elif args.mode == "progress":
# Print progress and write progress.json
config.progress_each_module = args.verbose
calculate_progress(config)
else:
sys.exit("Unknown mode: " + args.mode)
Loading

0 comments on commit 66867d0

Please sign in to comment.