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
38 changes: 30 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,35 @@
.DS_Store
# IDE folders
.idea/
.vs/

# Caches
__pycache__
.idea
.ninja_*
.mypy_cache
*.exe
build
build.ninja
objdiff.json
.cache/

# Original files
orig/*/*
!orig/*/.gitkeep
*.dol
*.rel
*.elf
*.o
*.map
*.MAP

# Build files
build/
.ninja_*
build.ninja

# decompctx output
ctx.*
*.ctx

# Generated configs
objdiff.json
compile_commands.json

# Miscellaneous
/*.txt
ctx.c
*.exe
12 changes: 12 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"recommendations": [
"llvm-vs-code-extensions.vscode-clangd",
"ms-python.black-formatter",
"ms-python.flake8",
],
"unwantedRecommendations": [
"ms-vscode.cmake-tools",
"ms-vscode.cpptools-extension-pack",
"ms-vscode.cpptools",
]
}
23 changes: 8 additions & 15 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,30 +1,23 @@
{
"[c]": {
"files.encoding": "utf8",
"editor.defaultFormatter": "xaver.clang-format"
"editor.defaultFormatter": "llvm-vs-code-extensions.vscode-clangd"
},
"[cpp]": {
"files.encoding": "utf8",
"editor.defaultFormatter": "xaver.clang-format"
"editor.defaultFormatter": "llvm-vs-code-extensions.vscode-clangd"
},
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter"
},
// "editor.tabSize": 2,
"files.autoSave": "onFocusChange",
"files.insertFinalNewline": true,
"files.trimFinalNewlines": true,
"files.associations": {
".fantomasignore": "ignore",
"*.inc": "cpp",
"new": "cpp"
"*.inc": "c",
".clangd": "yaml"
},
"search.useIgnoreFiles": false,
"search.exclude": {
"build/*/config.json": true,
"build/**/*.MAP": true,
"build.ninja": true,
".ninja_*": true,
"objdiff.json": true,
".mypy_cache": true
},
"C_Cpp.errorSquiggles": "enabled"
// Disable C/C++ IntelliSense, use clangd instead
"C_Cpp.intelliSenseEngine": "disabled",
}
16 changes: 16 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
// Use Ctrl+Shift+B to run build tasks.
// Or "Run Build Task" in the Command Palette.
"version": "2.0.0",
"tasks": [
{
"label": "ninja",
"type": "shell",
"command": "ninja",
"group": {
"kind": "build",
"isDefault": true
}
},
]
}
108 changes: 77 additions & 31 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

from tools.project import (
Object,
ProgressCategory,
ProjectConfig,
calculate_progress,
generate_build,
Expand Down Expand Up @@ -71,11 +72,6 @@
action="store_true",
help="generate map file(s)",
)
parser.add_argument(
"--no-asm",
action="store_true",
help="don't incorporate .s files from asm directory",
)
parser.add_argument(
"--debug",
action="store_true",
Expand All @@ -94,6 +90,12 @@
type=Path,
help="path to decomp-toolkit binary or source (optional)",
)
parser.add_argument(
"--objdiff",
metavar="BINARY | DIR",
type=Path,
help="path to objdiff-cli binary or source (optional)",
)
parser.add_argument(
"--sjiswrap",
metavar="EXE",
Expand All @@ -111,6 +113,12 @@
action="store_true",
help="builds equivalent (but non-matching) or modded objects",
)
parser.add_argument(
"--no-progress",
dest="progress",
action="store_false",
help="disable progress calculation",
)
args = parser.parse_args()

config = ProjectConfig()
Expand All @@ -120,22 +128,25 @@
# Apply arguments
config.build_dir = args.build_dir
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
config.progress = args.progress
if not is_windows():
config.wrapper = args.wrapper
if args.no_asm:
# Don't build asm unless we're --non-matching
if not config.non_matching:
config.asm_dir = None

# Tool versions
config.binutils_tag = "2.42-1"
config.compilers_tag = "20240702"
config.dtk_tag = "v1.4.0"
config.sjiswrap_tag = "v1.1.1"
config.compilers_tag = "20240706"
config.dtk_tag = "v1.4.1"
config.objdiff_tag = "v2.7.1"
config.sjiswrap_tag = "v1.2.0"
config.wibo_tag = "0.6.11"

# Project
Expand All @@ -146,17 +157,26 @@
"--strip-local-absolute",
"-I include",
f"-I build/{config.version}/include",
f"--defsym version={version_num}",
f"--defsym BUILD_VERSION={version_num}",
f"--defsym VERSION_{config.version}",
]
config.ldflags = [
"-fp hardware",
"-nodefaults",
"-warn off",
# "-listclosure", # Uncomment for Wii linkers
]
if args.debug:
config.ldflags.append("-g") # Or -gdwarf-2 for Wii linkers
if args.map:
config.ldflags.append("-mapunused")
# config.ldflags.append("-listclosure") # For Wii linkers

# Use for any additional files that should cause a re-configure when modified
config.reconfig_deps = []

# Optional numeric ID for decomp.me preset
# Can be overridden in libraries or objects
config.scratch_preset_id = 65 # Battle for Bikini Bottom

# Base flags, common to most GC/Wii games.
# Generally leave untouched, with overrides added below.
cflags_base = [
Expand All @@ -179,11 +199,13 @@
"-multibyte", # For Wii compilers, replace with `-enc SJIS`
"-i include",
f"-i build/{config.version}/include",
f"-DVERSION={version_num}",
f"-DBUILD_VERSION={version_num}",
f"-DVERSION_{config.version}",
]

# Debug flags
if config.debug:
if args.debug:
# Or -sym dwarf-2 for Wii compilers
cflags_base.extend(["-sym on", "-DDEBUG=1"])
else:
cflags_base.append("-DNDEBUG=1")
Expand Down Expand Up @@ -236,7 +258,7 @@ def DolphinLib(lib_name: str, objects: List[Object]) -> Dict[str, Any]:
"lib": lib_name,
"mw_version": "GC/1.2.5n",
"cflags": cflags_base,
"host": False,
"progress_category": "sdk",
"objects": objects,
}

Expand All @@ -247,7 +269,7 @@ def RenderWareLib(lib_name: str, objects: List[Object]) -> Dict[str, Any]:
"lib": lib_name,
"mw_version": "GC/1.3.2",
"cflags": cflags_base,
"host": False,
"progress_category": "sdk",
"objects": objects,
}

Expand All @@ -258,7 +280,7 @@ def Rel(lib_name: str, objects: List[Object]) -> Dict[str, Any]:
"lib": lib_name,
"mw_version": "GC/1.3.2",
"cflags": cflags_rel,
"host": True,
"progress_category": "game",
"objects": objects,
}

Expand All @@ -267,14 +289,20 @@ def Rel(lib_name: str, objects: List[Object]) -> Dict[str, Any]:
NonMatching = False # Object does not match and should not be linked
Equivalent = config.non_matching # Object should be linked when configured with --non-matching


# Object is only matching for specific versions
def MatchingFor(*versions):
return config.version in versions


config.warn_missing_config = True
config.warn_missing_source = False
config.libs = [
{
"lib": "SB",
"mw_version": config.linker_version,
"cflags": cflags_bfbb,
"host": True,
"progress_category": "game",
"objects": [
Object(NonMatching, "SB/Core/x/xAnim.cpp", extra_cflags=["-sym on"]),
Object(Matching, "SB/Core/x/xBase.cpp"),
Expand Down Expand Up @@ -506,7 +534,7 @@ def Rel(lib_name: str, objects: List[Object]) -> Dict[str, Any]:
"lib": "binkngc",
"mw_version": "GC/1.3.2",
"cflags": cflags_runtime,
"host": False,
"progress_category": "sdk",
"objects": [
Object(NonMatching, "bink/src/sdk/decode/ngc/binkngc.c"),
Object(NonMatching, "bink/src/sdk/decode/ngc/ngcsnd.c"),
Expand Down Expand Up @@ -703,7 +731,7 @@ def Rel(lib_name: str, objects: List[Object]) -> Dict[str, Any]:
"lib": "Runtime.PPCEABI.H",
"mw_version": config.linker_version,
"cflags": cflags_runtime,
"host": False,
"progress_category": "sdk",
"objects": [
Object(NonMatching, "PowerPC_EABI_Support/Runtime/Src/__mem.c"),
Object(NonMatching, "PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/abort_exit.c"),
Expand Down Expand Up @@ -781,7 +809,7 @@ def Rel(lib_name: str, objects: List[Object]) -> Dict[str, Any]:
"lib": "TRK_Minnow_Dolphin",
"mw_version": "GC/1.3.2",
"cflags": cflags_runtime,
"host": False,
"progress_category": "sdk",
"objects": [
Object(NonMatching, "TRK_MINNOW_DOLPHIN/Portable/mainloop.c"),
Object(NonMatching, "TRK_MINNOW_DOLPHIN/Portable/nubevent.c"),
Expand Down Expand Up @@ -813,7 +841,7 @@ def Rel(lib_name: str, objects: List[Object]) -> Dict[str, Any]:
"lib": "OdemuExi2",
"mw_version": "GC/1.3.2",
"cflags": cflags_runtime,
"host": False,
"progress_category": "sdk",
"objects": [
Object(NonMatching, "OdemuExi2/DebuggerDriver.c"),
],
Expand All @@ -834,13 +862,6 @@ def Rel(lib_name: str, objects: List[Object]) -> Dict[str, Any]:
Object(NonMatching, "rwsdk/plugin/hanim/rphanim.c"),
],
),
RenderWareLib(
"rphanim",
[
Object(NonMatching, "rwsdk/plugin/hanim/stdkey.c"),
Object(NonMatching, "rwsdk/plugin/hanim/rphanim.c"),
],
),
RenderWareLib(
"rpmatfx",
[
Expand Down Expand Up @@ -1002,12 +1023,37 @@ def Rel(lib_name: str, objects: List[Object]) -> Dict[str, Any]:
),
]


# Optional callback to adjust link order. This can be used to add, remove, or reorder objects.
# This is called once per module, with the module ID and the current link order.
#
# For example, this adds "dummy.c" to the end of the DOL link order if configured with --non-matching.
# "dummy.c" *must* be configured as a Matching (or Equivalent) object in order to be linked.
def link_order_callback(module_id: int, objects: List[str]) -> List[str]:
# Don't modify the link order for matching builds
if not config.non_matching:
return objects
if module_id == 0: # DOL
return objects + ["dummy.c"]
return objects

# Uncomment to enable the link order callback.
# config.link_order_callback = link_order_callback


# 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