Update dtk-template & use wibo on macOS (#2829)

* Update dtk-template & use wibo on macOS

* Update to wibo 1.0.0-beta.5

* Fix implicit dependencies for pch rules
This commit is contained in:
Luke Street 2025-11-20 02:16:44 -07:00 committed by GitHub
parent 8815bd5da9
commit cb08a259a5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 53 additions and 40 deletions

View File

@ -48,24 +48,14 @@ macOS
brew install ninja brew install ninja
``` ```
- Install [wine-crossover](https://github.com/Gcenx/homebrew-wine): [wibo](https://github.com/decompals/wibo), a minimal 32-bit Windows binary wrapper, will be automatically downloaded and used.
```sh
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:
```sh
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 x86(_64), [wibo](https://github.com/decompals/wibo), a minimal 32-bit Windows binary wrapper, will be automatically downloaded and used. [wibo](https://github.com/decompals/wibo), a minimal 32-bit Windows binary wrapper, will be automatically downloaded and used.
Building Building
======== ========

View File

@ -131,7 +131,7 @@ parser.add_argument(
"--ninja", "--ninja",
metavar="BINARY", metavar="BINARY",
type=Path, type=Path,
help="path to ninja binary (optional)" help="path to ninja binary (optional)",
) )
parser.add_argument( parser.add_argument(
"--verbose", "--verbose",
@ -188,10 +188,10 @@ if not config.non_matching:
# Tool versions # Tool versions
config.binutils_tag = "2.42-1" config.binutils_tag = "2.42-1"
config.compilers_tag = "20251118" config.compilers_tag = "20251118"
config.dtk_tag = "v1.6.2" config.dtk_tag = "v1.7.1"
config.objdiff_tag = "v3.0.1" config.objdiff_tag = "v3.4.1"
config.sjiswrap_tag = "v1.2.2" config.sjiswrap_tag = "v1.2.2"
config.wibo_tag = "0.7.0" config.wibo_tag = "1.0.0-beta.5"
# Project # Project
config.config_path = Path("config") / config.version / "config.yml" config.config_path = Path("config") / config.version / "config.yml"

View File

@ -78,8 +78,14 @@ def sjiswrap_url(tag: str) -> str:
def wibo_url(tag: str) -> str: def wibo_url(tag: str) -> str:
uname = platform.uname()
arch = uname.machine.lower()
system = uname.system.lower()
if system == "darwin":
arch = "macos"
repo = "https://github.com/decompals/wibo" repo = "https://github.com/decompals/wibo"
return f"{repo}/releases/download/{tag}/wibo" return f"{repo}/releases/download/{tag}/wibo-{arch}"
TOOLS: Dict[str, Callable[[str], str]] = { TOOLS: Dict[str, Callable[[str], str]] = {

View File

@ -18,11 +18,10 @@ import platform
import sys import sys
from pathlib import Path from pathlib import Path
from typing import ( from typing import (
IO,
Any, Any,
Callable, Callable,
cast,
Dict, Dict,
IO,
Iterable, Iterable,
List, List,
Optional, Optional,
@ -30,6 +29,7 @@ from typing import (
Tuple, Tuple,
TypedDict, TypedDict,
Union, Union,
cast,
) )
from . import ninja_syntax from . import ninja_syntax
@ -167,7 +167,9 @@ class ProjectConfig:
self.asflags: Optional[List[str]] = None # Assembler flags self.asflags: Optional[List[str]] = None # Assembler flags
self.ldflags: Optional[List[str]] = None # Linker flags self.ldflags: Optional[List[str]] = None # Linker flags
self.libs: Optional[List[Library]] = None # List of libraries self.libs: Optional[List[Library]] = None # List of libraries
self.precompiled_headers: Optional[List[PrecompiledHeader]] = None # List of precompiled headers self.precompiled_headers: Optional[List[PrecompiledHeader]] = (
None # List of precompiled headers
)
self.linker_version: Optional[str] = None # mwld version self.linker_version: Optional[str] = None # mwld version
self.version: Optional[str] = None # Version name self.version: Optional[str] = None # Version name
self.warn_missing_config: bool = False # Warn on missing unit configuration self.warn_missing_config: bool = False # Warn on missing unit configuration
@ -198,12 +200,12 @@ class ProjectConfig:
self.link_order_callback: Optional[Callable[[int, List[str]], List[str]]] = ( self.link_order_callback: Optional[Callable[[int, List[str]], List[str]]] = (
None # Callback to add/remove/reorder units within a module None # Callback to add/remove/reorder units within a module
) )
self.context_exclude_globs: List[str] = ( self.context_exclude_globs: List[
[] # Globs to exclude from context files str
) ] = [] # Globs to exclude from context files
self.context_defines: List[str] = ( self.context_defines: List[
[] # Macros to define at the top of context files str
) ] = [] # Macros to define at the top of context files
# Progress output and report.json config # Progress output and report.json config
self.progress = True # Enable report.json generation and CLI progress output self.progress = True # Enable report.json generation and CLI progress output
@ -283,8 +285,8 @@ class ProjectConfig:
def use_wibo(self) -> bool: def use_wibo(self) -> bool:
return ( return (
self.wibo_tag is not None self.wibo_tag is not None
and sys.platform == "linux" and (sys.platform == "linux" or sys.platform == "darwin")
and platform.machine() in ("i386", "x86_64") and platform.machine() in ("i386", "x86_64", "aarch64", "arm64")
and self.wrapper is None and self.wrapper is None
) )
@ -595,10 +597,7 @@ def generate_build_ninja(
sys.exit("ProjectConfig.sjiswrap_tag missing") sys.exit("ProjectConfig.sjiswrap_tag missing")
wrapper = config.compiler_wrapper() wrapper = config.compiler_wrapper()
# Only add an implicit dependency on wibo if we download it
wrapper_implicit: Optional[Path] = None
if wrapper is not None and config.use_wibo(): if wrapper is not None and config.use_wibo():
wrapper_implicit = wrapper
n.build( n.build(
outputs=wrapper, outputs=wrapper,
rule="download_tool", rule="download_tool",
@ -608,6 +607,11 @@ def generate_build_ninja(
"tag": config.wibo_tag, "tag": config.wibo_tag,
}, },
) )
wrapper_implicit: Optional[Path] = None
if wrapper is not None and (wrapper.exists() or config.use_wibo()):
wrapper_implicit = wrapper
wrapper_cmd = f"{wrapper} " if wrapper else "" wrapper_cmd = f"{wrapper} " if wrapper else ""
compilers = config.compilers() compilers = config.compilers()
@ -678,9 +682,11 @@ def generate_build_ninja(
mwcc_pch_sjis_implicit: List[Optional[Path]] = [*mwcc_implicit, sjiswrap] mwcc_pch_sjis_implicit: List[Optional[Path]] = [*mwcc_implicit, sjiswrap]
# MWCC with extab post-processing # MWCC with extab post-processing
mwcc_extab_cmd = f"{CHAIN}{mwcc_cmd} && {dtk} extab clean --padding \"$extab_padding\" $out $out" mwcc_extab_cmd = (
f'{CHAIN}{mwcc_cmd} && {dtk} extab clean --padding "$extab_padding" $out $out'
)
mwcc_extab_implicit: List[Optional[Path]] = [*mwcc_implicit, dtk] mwcc_extab_implicit: List[Optional[Path]] = [*mwcc_implicit, dtk]
mwcc_sjis_extab_cmd = f"{CHAIN}{mwcc_sjis_cmd} && {dtk} extab clean --padding \"$extab_padding\" $out $out" mwcc_sjis_extab_cmd = f'{CHAIN}{mwcc_sjis_cmd} && {dtk} extab clean --padding "$extab_padding" $out $out'
mwcc_sjis_extab_implicit: List[Optional[Path]] = [*mwcc_sjis_implicit, dtk] mwcc_sjis_extab_implicit: List[Optional[Path]] = [*mwcc_sjis_implicit, dtk]
# MWLD # MWLD
@ -818,7 +824,11 @@ def generate_build_ninja(
) )
n.newline() n.newline()
def write_custom_step(step: str, prev_step: Optional[str] = None, extra_inputs: Optional[List[str]] = None) -> None: def write_custom_step(
step: str,
prev_step: Optional[str] = None,
extra_inputs: Optional[List[str]] = None,
) -> None:
implicit: List[Union[str, Path]] = [] implicit: List[Union[str, Path]] = []
if config.custom_build_steps and step in config.custom_build_steps: if config.custom_build_steps and step in config.custom_build_steps:
n.comment(f"Custom build steps ({step})") n.comment(f"Custom build steps ({step})")
@ -852,7 +862,9 @@ def generate_build_ninja(
) )
# Add all build steps needed before we compile (e.g. processing assets) # Add all build steps needed before we compile (e.g. processing assets)
pch_out_names = [get_pch_out_name(config, pch) for pch in config.precompiled_headers or []] pch_out_names = [
get_pch_out_name(config, pch) for pch in config.precompiled_headers or []
]
write_custom_step("pre-compile", extra_inputs=pch_out_names) write_custom_step("pre-compile", extra_inputs=pch_out_names)
### ###
@ -968,11 +980,12 @@ def generate_build_ninja(
cflags.insert(0, "-lang=c") cflags.insert(0, "-lang=c")
cflags_str = make_flags_str(cflags) cflags_str = make_flags_str(cflags)
shift_jis = pch.get("shift_jis", config.shift_jis)
n.comment(f"Precompiled header {pch_out_name}") n.comment(f"Precompiled header {pch_out_name}")
n.build( n.build(
outputs=pch_out_abs_path, outputs=pch_out_abs_path,
rule="mwcc_pch_sjis" if pch.get("shift_jis", config.shift_jis) else "mwcc_pch", rule="mwcc_pch_sjis" if shift_jis else "mwcc_pch",
inputs=f"include/{src_path_rel_str}", inputs=f"include/{src_path_rel_str}",
variables={ variables={
"mw_version": Path(pch["mw_version"]), "mw_version": Path(pch["mw_version"]),
@ -981,7 +994,7 @@ def generate_build_ninja(
"basefile": pch_out_abs_path.with_suffix(""), "basefile": pch_out_abs_path.with_suffix(""),
"basefilestem": pch_out_abs_path.stem, "basefilestem": pch_out_abs_path.stem,
}, },
implicit=[*mwcc_implicit], implicit=mwcc_pch_sjis_implicit if shift_jis else mwcc_pch_implicit,
) )
n.newline() n.newline()
@ -1025,14 +1038,18 @@ def generate_build_ninja(
if obj.options["shift_jis"] and obj.options["extab_padding"] is not None: if obj.options["shift_jis"] and obj.options["extab_padding"] is not None:
build_rule = "mwcc_sjis_extab" build_rule = "mwcc_sjis_extab"
build_implcit = mwcc_sjis_extab_implicit build_implcit = mwcc_sjis_extab_implicit
variables["extab_padding"] = "".join(f"{i:02x}" for i in obj.options["extab_padding"]) variables["extab_padding"] = "".join(
f"{i:02x}" for i in obj.options["extab_padding"]
)
elif obj.options["shift_jis"]: elif obj.options["shift_jis"]:
build_rule = "mwcc_sjis" build_rule = "mwcc_sjis"
build_implcit = mwcc_sjis_implicit build_implcit = mwcc_sjis_implicit
elif obj.options["extab_padding"] is not None: elif obj.options["extab_padding"] is not None:
build_rule = "mwcc_extab" build_rule = "mwcc_extab"
build_implcit = mwcc_extab_implicit build_implcit = mwcc_extab_implicit
variables["extab_padding"] = "".join(f"{i:02x}" for i in obj.options["extab_padding"]) variables["extab_padding"] = "".join(
f"{i:02x}" for i in obj.options["extab_padding"]
)
n.comment(f"{obj.name}: {lib_name} (linked {obj.completed})") n.comment(f"{obj.name}: {lib_name} (linked {obj.completed})")
n.build( n.build(
outputs=obj.src_obj_path, outputs=obj.src_obj_path,