summaryrefslogtreecommitdiff
path: root/tools/project.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/project.py')
-rw-r--r--tools/project.py61
1 files changed, 39 insertions, 22 deletions
diff --git a/tools/project.py b/tools/project.py
index 9c8bcb342c..b1417ae69a 100644
--- a/tools/project.py
+++ b/tools/project.py
@@ -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,