mirror of https://github.com/PrimeDecomp/prime.git
Adjust link_order_callback API
This commit is contained in:
parent
8e17caa35f
commit
5476f3b62e
11
configure.py
11
configure.py
|
@ -15,9 +15,10 @@
|
|||
import argparse
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from typing import List
|
||||
from typing import List, Sequence, Union
|
||||
|
||||
from tools.project import (
|
||||
BuildConfigUnit,
|
||||
Object,
|
||||
ProgressCategory,
|
||||
ProjectConfig,
|
||||
|
@ -1409,9 +1410,13 @@ for lib in config.libs:
|
|||
obj.options["extra_clang_flags"].append("-Wno-return-type")
|
||||
|
||||
|
||||
def link_order_callback(module_id: int, units: List[str]) -> List[str]:
|
||||
def link_order_callback(
|
||||
module_id: int, units: List[str]
|
||||
) -> Sequence[Union[str, BuildConfigUnit]]:
|
||||
if module_id == 0: # DOL
|
||||
return units + ["dummy.c"]
|
||||
return units + [
|
||||
{"object": "dummy.o", "name": "dummy.c", "autogenerated": False}
|
||||
]
|
||||
return units
|
||||
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ from pathlib import Path
|
|||
from typing import (
|
||||
Any,
|
||||
Callable,
|
||||
Sequence,
|
||||
cast,
|
||||
Dict,
|
||||
IO,
|
||||
|
@ -192,9 +193,9 @@ class ProjectConfig:
|
|||
self.scratch_preset_id: Optional[int] = (
|
||||
None # Default decomp.me preset ID for scratches
|
||||
)
|
||||
self.link_order_callback: Optional[Callable[[int, List[str]], List[str]]] = (
|
||||
None # Callback to add/remove/reorder units within a module
|
||||
)
|
||||
self.link_order_callback: Optional[
|
||||
Callable[[int, List[str]], Sequence[Union[str, BuildConfigUnit]]]
|
||||
] = None # Callback to add/remove/reorder units within a module
|
||||
|
||||
# Progress output, progress.json and report.json config
|
||||
self.progress = True # Enable report.json generation and CLI progress output
|
||||
|
@ -371,16 +372,19 @@ def load_build_config(
|
|||
modules: List[BuildConfigModule] = [build_config, *build_config["modules"]]
|
||||
for module in modules:
|
||||
unit_names = list(map(lambda u: u["name"], module["units"]))
|
||||
unit_names = config.link_order_callback(module["module_id"], unit_names)
|
||||
new_units = config.link_order_callback(module["module_id"], unit_names)
|
||||
units: List[BuildConfigUnit] = []
|
||||
for unit_name in unit_names:
|
||||
# Find existing unit or create a new one
|
||||
unit = next(
|
||||
(u for u in module["units"] if u["name"] == unit_name), None
|
||||
)
|
||||
if not unit:
|
||||
unit = {"object": None, "name": unit_name, "autogenerated": False}
|
||||
units.append(unit)
|
||||
for new_unit in new_units:
|
||||
if isinstance(new_unit, str):
|
||||
units.append(
|
||||
# Find existing unit or create a new one
|
||||
next(
|
||||
(u for u in module["units"] if u["name"] == new_unit),
|
||||
{"object": None, "name": new_unit, "autogenerated": False},
|
||||
)
|
||||
)
|
||||
else:
|
||||
units.append(new_unit)
|
||||
module["units"] = units
|
||||
|
||||
return build_config
|
||||
|
|
Loading…
Reference in New Issue