mirror of
https://github.com/PrimeDecomp/prime.git
synced 2025-09-21 01:09:36 +00:00
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 argparse
|
||||||
import sys
|
import sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import List
|
from typing import List, Sequence, Union
|
||||||
|
|
||||||
from tools.project import (
|
from tools.project import (
|
||||||
|
BuildConfigUnit,
|
||||||
Object,
|
Object,
|
||||||
ProgressCategory,
|
ProgressCategory,
|
||||||
ProjectConfig,
|
ProjectConfig,
|
||||||
@ -1409,9 +1410,13 @@ for lib in config.libs:
|
|||||||
obj.options["extra_clang_flags"].append("-Wno-return-type")
|
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
|
if module_id == 0: # DOL
|
||||||
return units + ["dummy.c"]
|
return units + [
|
||||||
|
{"object": "dummy.o", "name": "dummy.c", "autogenerated": False}
|
||||||
|
]
|
||||||
return units
|
return units
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@ from pathlib import Path
|
|||||||
from typing import (
|
from typing import (
|
||||||
Any,
|
Any,
|
||||||
Callable,
|
Callable,
|
||||||
|
Sequence,
|
||||||
cast,
|
cast,
|
||||||
Dict,
|
Dict,
|
||||||
IO,
|
IO,
|
||||||
@ -192,9 +193,9 @@ class ProjectConfig:
|
|||||||
self.scratch_preset_id: Optional[int] = (
|
self.scratch_preset_id: Optional[int] = (
|
||||||
None # Default decomp.me preset ID for scratches
|
None # Default decomp.me preset ID for scratches
|
||||||
)
|
)
|
||||||
self.link_order_callback: Optional[Callable[[int, List[str]], List[str]]] = (
|
self.link_order_callback: Optional[
|
||||||
None # Callback to add/remove/reorder units within a module
|
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
|
# Progress output, progress.json 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
|
||||||
@ -371,16 +372,19 @@ def load_build_config(
|
|||||||
modules: List[BuildConfigModule] = [build_config, *build_config["modules"]]
|
modules: List[BuildConfigModule] = [build_config, *build_config["modules"]]
|
||||||
for module in modules:
|
for module in modules:
|
||||||
unit_names = list(map(lambda u: u["name"], module["units"]))
|
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] = []
|
units: List[BuildConfigUnit] = []
|
||||||
for unit_name in unit_names:
|
for new_unit in new_units:
|
||||||
# Find existing unit or create a new one
|
if isinstance(new_unit, str):
|
||||||
unit = next(
|
units.append(
|
||||||
(u for u in module["units"] if u["name"] == unit_name), None
|
# Find existing unit or create a new one
|
||||||
)
|
next(
|
||||||
if not unit:
|
(u for u in module["units"] if u["name"] == new_unit),
|
||||||
unit = {"object": None, "name": unit_name, "autogenerated": False}
|
{"object": None, "name": new_unit, "autogenerated": False},
|
||||||
units.append(unit)
|
)
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
units.append(new_unit)
|
||||||
module["units"] = units
|
module["units"] = units
|
||||||
|
|
||||||
return build_config
|
return build_config
|
||||||
|
Loading…
x
Reference in New Issue
Block a user