Update to latest dtk-template

This commit is contained in:
Luke Street 2024-09-04 22:03:20 -06:00
parent bc0fcbb7b3
commit 3efecd011f
7 changed files with 517 additions and 251 deletions

2
.gitattributes vendored
View File

@ -9,5 +9,5 @@
*.sh text eol=lf *.sh text eol=lf
*.sha1 text eol=lf *.sha1 text eol=lf
# DTK keeps these files with LF # decomp-toolkit writes files with LF
config/**/*.txt text eol=lf config/**/*.txt text eol=lf

View File

@ -35,7 +35,8 @@ jobs:
run: | run: |
python configure.py --map --version ${{ matrix.version }} \ python configure.py --map --version ${{ matrix.version }} \
--binutils /binutils --compilers /compilers --binutils /binutils --compilers /compilers
ninja all_source build/${{ matrix.version }}/progress.json ninja all_source build/${{ matrix.version }}/progress.json \
build/${{ matrix.version }}/report.json
# Upload progress if we're on the main branch # Upload progress if we're on the main branch
- name: Upload progress - name: Upload progress
@ -55,3 +56,10 @@ jobs:
with: with:
name: ${{ matrix.version }}_maps name: ${{ matrix.version }}_maps
path: build/${{ matrix.version }}/**/*.MAP path: build/${{ matrix.version }}/**/*.MAP
# Upload progress report
- name: Upload report
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.version }}_report
path: build/${{ matrix.version }}/report.json

View File

@ -26,7 +26,7 @@ If you'd like to contribute, see [CONTRIBUTING.md](CONTRIBUTING.md).
Dependencies Dependencies
============ ============
Windows: Windows
-------- --------
On Windows, it's **highly recommended** to use native tooling. WSL or msys2 are **not** required. On Windows, it's **highly recommended** to use native tooling. WSL or msys2 are **not** required.
@ -37,60 +37,73 @@ When running under WSL, [objdiff](#diffing) is unable to get filesystem notifica
- Download [ninja](https://github.com/ninja-build/ninja/releases) and add it to `%PATH%`. - Download [ninja](https://github.com/ninja-build/ninja/releases) and add it to `%PATH%`.
- Quick install via pip: `pip install ninja` - Quick install via pip: `pip install ninja`
macOS: macOS
------ ------
- Install [ninja](https://github.com/ninja-build/ninja/wiki/Pre-built-Ninja-packages): - Install [ninja](https://github.com/ninja-build/ninja/wiki/Pre-built-Ninja-packages):
```
```sh
brew install ninja brew install ninja
``` ```
- Install [wine-crossover](https://github.com/Gcenx/homebrew-wine): - Install [wine-crossover](https://github.com/Gcenx/homebrew-wine):
```
```sh
brew install --cask --no-quarantine gcenx/wine/wine-crossover brew install --cask --no-quarantine gcenx/wine/wine-crossover
``` ```
After OS upgrades, if macOS complains about `Wine Crossover.app` being unverified, you can unquarantine it using: After OS upgrades, if macOS complains about `Wine Crossover.app` being unverified, you can unquarantine it using:
```sh ```sh
sudo xattr -rd com.apple.quarantine '/Applications/Wine Crossover.app' sudo xattr -rd com.apple.quarantine '/Applications/Wine Crossover.app'
``` ```
Linux: Linux
------ ------
- Install [ninja](https://github.com/ninja-build/ninja/wiki/Pre-built-Ninja-packages). - Install [ninja](https://github.com/ninja-build/ninja/wiki/Pre-built-Ninja-packages).
- For non-x86(_64) platforms: Install wine from your package manager. - For non-x86(_64) platforms: Install wine from your package manager.
- For x86(_64), [WiBo](https://github.com/decompals/WiBo), a minimal 32-bit Windows binary wrapper, will be automatically downloaded and used. - For x86(_64), [wibo](https://github.com/decompals/wibo), a minimal 32-bit Windows binary wrapper, will be automatically downloaded and used.
Building Building
======== ========
- Clone the repository: - Clone the repository:
```
```sh
git clone https://github.com/PrimeDecomp/prime.git git clone https://github.com/PrimeDecomp/prime.git
``` ```
- Update and Initialize submodules: - Update and Initialize submodules:
```
```sh
git submodule update --init --recursive git submodule update --init --recursive
``` ```
- Using [Dolphin Emulator](https://dolphin-emu.org/), extract your game to `orig/GM8E01_00` (or the appropriate version). - Using [Dolphin Emulator](https://dolphin-emu.org/), extract your game to `orig/GM8E01_00` (or the appropriate version).
![](assets/dolphin-extract.png) ![](assets/dolphin-extract.png)
- To save space, the only necessary files are the following. Any others can be deleted. - To save space, the only necessary files are the following. Any others can be deleted.
- `sys/main.dol` - `sys/main.dol`
- `files/NESemuP.rel` - `files/NESemuP.rel`
- Configure: - Configure:
```
```sh
python configure.py python configure.py
``` ```
To use a version other than `GM8E01_00` (USA), specify `--version GM8E01_01` or similar. To use a version other than `GM8E01_00` (USA), specify `--version GM8E01_01` or similar.
- Build: - Build:
```
```sh
ninja ninja
``` ```
Diffing Diffing
======= =======
Once the initial build succeeds, an `objdiff.json` should exist in the project root. Once the initial build succeeds, an `objdiff.json` should exist in the project root.
Download the latest release from [encounter/objdiff](https://github.com/encounter/objdiff). Under project settings, set `Project directory`. The configuration should be loaded automatically. Download the latest release from [encounter/objdiff](https://github.com/encounter/objdiff). Under project settings, set `Project directory`. The configuration should be loaded automatically.
Select an object from the left sidebar to begin diffing. Changes to the project will rebuild automatically: changes to source files, headers, `configure.py`, `splits.txt` or `symbols.txt`. Select an object from the left sidebar to begin diffing. Changes to the project will rebuild automatically: changes to source files, headers, `configure.py`, `splits.txt` or `symbols.txt`.

View File

@ -16,14 +16,7 @@ import argparse
import sys import sys
from pathlib import Path from pathlib import Path
from typing import Any, Dict, List from typing import Any, Dict, List
from tools.project import *
from tools.project import (
Object,
ProjectConfig,
calculate_progress,
generate_build,
is_windows,
)
# Game versions # Game versions
DEFAULT_VERSION = 0 DEFAULT_VERSION = 0
@ -79,11 +72,6 @@ parser.add_argument(
action="store_true", action="store_true",
help="generate map file(s)", 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( parser.add_argument(
"--debug", "--debug",
action="store_true", action="store_true",
@ -102,6 +90,12 @@ parser.add_argument(
type=Path, type=Path,
help="path to decomp-toolkit binary or source (optional)", 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( parser.add_argument(
"--sjiswrap", "--sjiswrap",
metavar="EXE", metavar="EXE",
@ -128,6 +122,7 @@ version_num = VERSIONS.index(config.version)
# Apply arguments # Apply arguments
config.build_dir = args.build_dir config.build_dir = args.build_dir
config.dtk_path = args.dtk config.dtk_path = args.dtk
config.objdiff_path = args.objdiff
config.binutils_path = args.binutils config.binutils_path = args.binutils
config.compilers_path = args.compilers config.compilers_path = args.compilers
config.debug = args.debug config.debug = args.debug
@ -136,13 +131,15 @@ config.non_matching = args.non_matching
config.sjiswrap_path = args.sjiswrap config.sjiswrap_path = args.sjiswrap
if not is_windows(): if not is_windows():
config.wrapper = args.wrapper 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 config.asm_dir = None
# Tool versions # Tool versions
config.binutils_tag = "2.42-1" config.binutils_tag = "2.42-1"
config.compilers_tag = "20231018" config.compilers_tag = "20240706"
config.dtk_tag = "v0.9.2" config.dtk_tag = "v0.9.5"
config.objdiff_tag = "v2.0.0-beta.5"
config.sjiswrap_tag = "v1.1.1" config.sjiswrap_tag = "v1.1.1"
config.wibo_tag = "0.6.11" config.wibo_tag = "0.6.11"
@ -159,7 +156,6 @@ config.asflags = [
config.ldflags = [ config.ldflags = [
"-fp hardware", "-fp hardware",
"-nodefaults", "-nodefaults",
"-warn off",
] ]
config.progress_all = False config.progress_all = False
@ -272,7 +268,7 @@ cflags_rel = [
"-sdata 0", "-sdata 0",
"-sdata2 0", "-sdata2 0",
"-str noreuse", "-str noreuse",
"-Cpp_exceptions off" "-Cpp_exceptions off",
] ]
config.linker_version = "GC/1.3.2" config.linker_version = "GC/1.3.2"
@ -327,9 +323,11 @@ def Rel(lib_name, objects):
} }
Matching = True # Object matches and should be linked Matching = True # Object matches and should be linked
NonMatching = False # Object does not match and should not 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 Equivalent = (
config.non_matching
) # Object should be linked when configured with --non-matching
config.warn_missing_config = True config.warn_missing_config = True
config.warn_missing_source = False config.warn_missing_source = False
@ -1338,17 +1336,23 @@ config.libs = [
Object( Object(
Matching, Matching,
"NESemu/modwrapper.c", "NESemu/modwrapper.c",
), ),
], ],
), ),
] ]
# Optional extra categories for progress tracking
config.progress_categories = [
# ProgressCategory("game", "Game Code"),
# ProgressCategory("sdk", "SDK Code"),
]
config.progress_each_module = args.verbose
if args.mode == "configure": if args.mode == "configure":
# Write build.ninja and objdiff.json # Write build.ninja and objdiff.json
generate_build(config) generate_build(config)
elif args.mode == "progress": elif args.mode == "progress":
# Print progress and write progress.json # Print progress and write progress.json
config.progress_each_module = args.verbose
calculate_progress(config) calculate_progress(config)
else: else:
sys.exit("Unknown mode: " + args.mode) sys.exit("Unknown mode: " + args.mode)

View File

@ -24,8 +24,8 @@ include_dirs = [
os.path.join(root_dir, "extern/musyx/include") os.path.join(root_dir, "extern/musyx/include")
] ]
include_pattern = re.compile(r'^#include\s*[<"](.+?)[>"]$') include_pattern = re.compile(r'^#\s*include\s*[<"](.+?)[>"]$')
guard_pattern = re.compile(r"^#ifndef\s+(.*)$") guard_pattern = re.compile(r"^#\s*ifndef\s+(.*)$")
defines = set() defines = set()

View File

@ -55,6 +55,21 @@ def dtk_url(tag: str) -> str:
repo = "https://github.com/encounter/decomp-toolkit" repo = "https://github.com/encounter/decomp-toolkit"
return f"{repo}/releases/download/{tag}/dtk-{system}-{arch}{suffix}" return f"{repo}/releases/download/{tag}/dtk-{system}-{arch}{suffix}"
def objdiff_cli_url(tag: str) -> str:
uname = platform.uname()
suffix = ""
system = uname.system.lower()
if system == "darwin":
system = "macos"
elif system == "windows":
suffix = ".exe"
arch = uname.machine.lower()
if arch == "amd64":
arch = "x86_64"
repo = "https://github.com/encounter/objdiff"
return f"{repo}/releases/download/{tag}/objdiff-cli-{system}-{arch}{suffix}"
def sjiswrap_url(tag: str) -> str: def sjiswrap_url(tag: str) -> str:
repo = "https://github.com/encounter/sjiswrap" repo = "https://github.com/encounter/sjiswrap"
@ -70,6 +85,7 @@ TOOLS: Dict[str, Callable[[str], str]] = {
"binutils": binutils_url, "binutils": binutils_url,
"compilers": compilers_url, "compilers": compilers_url,
"dtk": dtk_url, "dtk": dtk_url,
"objdiff-cli": objdiff_cli_url,
"sjiswrap": sjiswrap_url, "sjiswrap": sjiswrap_url,
"wibo": wibo_url, "wibo": wibo_url,
} }

File diff suppressed because it is too large Load Diff