mirror of https://github.com/zeldaret/tp
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:
parent
8815bd5da9
commit
cb08a259a5
16
README.md
16
README.md
|
|
@ -48,24 +48,14 @@ macOS
|
|||
brew install ninja
|
||||
```
|
||||
|
||||
- Install [wine-crossover](https://github.com/Gcenx/homebrew-wine):
|
||||
|
||||
```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'
|
||||
```
|
||||
[wibo](https://github.com/decompals/wibo), a minimal 32-bit Windows binary wrapper, will be automatically downloaded and used.
|
||||
|
||||
Linux
|
||||
------
|
||||
|
||||
- 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
|
||||
========
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ parser.add_argument(
|
|||
"--ninja",
|
||||
metavar="BINARY",
|
||||
type=Path,
|
||||
help="path to ninja binary (optional)"
|
||||
help="path to ninja binary (optional)",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--verbose",
|
||||
|
|
@ -188,10 +188,10 @@ if not config.non_matching:
|
|||
# Tool versions
|
||||
config.binutils_tag = "2.42-1"
|
||||
config.compilers_tag = "20251118"
|
||||
config.dtk_tag = "v1.6.2"
|
||||
config.objdiff_tag = "v3.0.1"
|
||||
config.dtk_tag = "v1.7.1"
|
||||
config.objdiff_tag = "v3.4.1"
|
||||
config.sjiswrap_tag = "v1.2.2"
|
||||
config.wibo_tag = "0.7.0"
|
||||
config.wibo_tag = "1.0.0-beta.5"
|
||||
|
||||
# Project
|
||||
config.config_path = Path("config") / config.version / "config.yml"
|
||||
|
|
|
|||
|
|
@ -78,8 +78,14 @@ def sjiswrap_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"
|
||||
return f"{repo}/releases/download/{tag}/wibo"
|
||||
return f"{repo}/releases/download/{tag}/wibo-{arch}"
|
||||
|
||||
|
||||
TOOLS: Dict[str, Callable[[str], str]] = {
|
||||
|
|
|
|||
|
|
@ -18,11 +18,10 @@ import platform
|
|||
import sys
|
||||
from pathlib import Path
|
||||
from typing import (
|
||||
IO,
|
||||
Any,
|
||||
Callable,
|
||||
cast,
|
||||
Dict,
|
||||
IO,
|
||||
Iterable,
|
||||
List,
|
||||
Optional,
|
||||
|
|
@ -30,6 +29,7 @@ from typing import (
|
|||
Tuple,
|
||||
TypedDict,
|
||||
Union,
|
||||
cast,
|
||||
)
|
||||
|
||||
from . import ninja_syntax
|
||||
|
|
@ -167,7 +167,9 @@ class ProjectConfig:
|
|||
self.asflags: Optional[List[str]] = None # Assembler flags
|
||||
self.ldflags: Optional[List[str]] = None # Linker flags
|
||||
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.version: Optional[str] = None # Version name
|
||||
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]]] = (
|
||||
None # Callback to add/remove/reorder units within a module
|
||||
)
|
||||
self.context_exclude_globs: List[str] = (
|
||||
[] # Globs to exclude from context files
|
||||
)
|
||||
self.context_defines: List[str] = (
|
||||
[] # Macros to define at the top of context files
|
||||
)
|
||||
self.context_exclude_globs: List[
|
||||
str
|
||||
] = [] # Globs to exclude from context files
|
||||
self.context_defines: List[
|
||||
str
|
||||
] = [] # Macros to define at the top of context files
|
||||
|
||||
# Progress output and report.json config
|
||||
self.progress = True # Enable report.json generation and CLI progress output
|
||||
|
|
@ -283,8 +285,8 @@ class ProjectConfig:
|
|||
def use_wibo(self) -> bool:
|
||||
return (
|
||||
self.wibo_tag is not None
|
||||
and sys.platform == "linux"
|
||||
and platform.machine() in ("i386", "x86_64")
|
||||
and (sys.platform == "linux" or sys.platform == "darwin")
|
||||
and platform.machine() in ("i386", "x86_64", "aarch64", "arm64")
|
||||
and self.wrapper is None
|
||||
)
|
||||
|
||||
|
|
@ -595,10 +597,7 @@ def generate_build_ninja(
|
|||
sys.exit("ProjectConfig.sjiswrap_tag missing")
|
||||
|
||||
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():
|
||||
wrapper_implicit = wrapper
|
||||
n.build(
|
||||
outputs=wrapper,
|
||||
rule="download_tool",
|
||||
|
|
@ -608,6 +607,11 @@ def generate_build_ninja(
|
|||
"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 ""
|
||||
|
||||
compilers = config.compilers()
|
||||
|
|
@ -678,9 +682,11 @@ def generate_build_ninja(
|
|||
mwcc_pch_sjis_implicit: List[Optional[Path]] = [*mwcc_implicit, sjiswrap]
|
||||
|
||||
# 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_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]
|
||||
|
||||
# MWLD
|
||||
|
|
@ -818,7 +824,11 @@ def generate_build_ninja(
|
|||
)
|
||||
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]] = []
|
||||
if config.custom_build_steps and step in config.custom_build_steps:
|
||||
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)
|
||||
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)
|
||||
|
||||
###
|
||||
|
|
@ -968,11 +980,12 @@ def generate_build_ninja(
|
|||
cflags.insert(0, "-lang=c")
|
||||
|
||||
cflags_str = make_flags_str(cflags)
|
||||
shift_jis = pch.get("shift_jis", config.shift_jis)
|
||||
|
||||
n.comment(f"Precompiled header {pch_out_name}")
|
||||
n.build(
|
||||
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}",
|
||||
variables={
|
||||
"mw_version": Path(pch["mw_version"]),
|
||||
|
|
@ -981,7 +994,7 @@ def generate_build_ninja(
|
|||
"basefile": pch_out_abs_path.with_suffix(""),
|
||||
"basefilestem": pch_out_abs_path.stem,
|
||||
},
|
||||
implicit=[*mwcc_implicit],
|
||||
implicit=mwcc_pch_sjis_implicit if shift_jis else mwcc_pch_implicit,
|
||||
)
|
||||
n.newline()
|
||||
|
||||
|
|
@ -1025,14 +1038,18 @@ def generate_build_ninja(
|
|||
if obj.options["shift_jis"] and obj.options["extab_padding"] is not None:
|
||||
build_rule = "mwcc_sjis_extab"
|
||||
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"]:
|
||||
build_rule = "mwcc_sjis"
|
||||
build_implcit = mwcc_sjis_implicit
|
||||
elif obj.options["extab_padding"] is not None:
|
||||
build_rule = "mwcc_extab"
|
||||
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.build(
|
||||
outputs=obj.src_obj_path,
|
||||
|
|
|
|||
Loading…
Reference in New Issue