mirror of
https://github.com/encounter/dtk-template.git
synced 2025-12-17 00:47:23 +00:00
Update tools & format with ruff
This commit is contained in:
@@ -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
|
||||
@@ -680,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
|
||||
@@ -820,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})")
|
||||
@@ -854,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)
|
||||
|
||||
###
|
||||
@@ -974,7 +984,11 @@ def generate_build_ninja(
|
||||
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 pch.get("shift_jis", config.shift_jis)
|
||||
else "mwcc_pch"
|
||||
),
|
||||
inputs=f"include/{src_path_rel_str}",
|
||||
variables={
|
||||
"mw_version": Path(pch["mw_version"]),
|
||||
@@ -1027,14 +1041,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,
|
||||
|
||||
Reference in New Issue
Block a user