summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorLagoLunatic <LagoLunatic@users.noreply.github.com>2024-10-10 14:30:13 -0400
committerLagoLunatic <LagoLunatic@users.noreply.github.com>2024-10-10 14:30:13 -0400
commit2310bc5557363a1edc18584d4ece79f62369deb9 (patch)
treefb7ad9e634968d05c27b7d91b4526a682c2025ee /tools
parentd27806bcd1caf4c372b98f4d040d718b0540f1be (diff)
Update dtk-template
Diffstat (limited to 'tools')
-rw-r--r--tools/project.py35
1 files changed, 31 insertions, 4 deletions
diff --git a/tools/project.py b/tools/project.py
index 727d45c5..cee55835 100644
--- a/tools/project.py
+++ b/tools/project.py
@@ -1177,6 +1177,13 @@ def generate_objdiff_config(
if build_config is None:
return
+ # Load existing objdiff.json
+ existing_units = {}
+ if Path("objdiff.json").is_file():
+ with open("objdiff.json", "r", encoding="utf-8") as r:
+ existing_config = json.load(r)
+ existing_units = {unit["name"]: unit for unit in existing_config["units"]}
+
objdiff_config: Dict[str, Any] = {
"min_version": "2.0.0-beta.5",
"custom_make": "ninja",
@@ -1234,15 +1241,27 @@ def generate_objdiff_config(
) -> None:
obj_path, obj_name = build_obj["object"], build_obj["name"]
base_object = Path(obj_name).with_suffix("")
+ name = str(Path(module_name) / base_object).replace(os.sep, "/")
unit_config: Dict[str, Any] = {
- "name": Path(module_name) / base_object,
+ "name": name,
"target_path": obj_path,
+ "base_path": None,
+ "scratch": None,
"metadata": {
- "auto_generated": build_obj["autogenerated"],
+ "complete": None,
+ "reverse_fn_order": None,
+ "source_path": None,
"progress_categories": progress_categories,
+ "auto_generated": build_obj["autogenerated"],
},
+ "symbol_mappings": None,
}
+ # Preserve existing symbol mappings
+ existing_unit = existing_units.get(name)
+ if existing_unit is not None:
+ unit_config["symbol_mappings"] = existing_unit.get("symbol_mappings")
+
obj = objects.get(obj_name)
if obj is None:
objdiff_config["units"].append(unit_config)
@@ -1352,13 +1371,21 @@ def generate_objdiff_config(
for category in config.progress_categories:
add_category(category.id, category.name)
+ def cleandict(d):
+ if isinstance(d, dict):
+ return {k: cleandict(v) for k, v in d.items() if v is not None}
+ elif isinstance(d, list):
+ return [cleandict(v) for v in d]
+ else:
+ return d
+
# Write objdiff.json
with open("objdiff.json", "w", encoding="utf-8") as w:
def unix_path(input: Any) -> str:
return str(input).replace(os.sep, "/") if input else ""
- json.dump(objdiff_config, w, indent=4, default=unix_path)
+ json.dump(cleandict(objdiff_config), w, indent=2, default=unix_path)
# Calculate, print and write progress to progress.json
@@ -1480,4 +1507,4 @@ def calculate_progress(config: ProjectConfig) -> None:
add_category(category["id"], category["measures"])
with open(out_path / "progress.json", "w", encoding="utf-8") as w:
- json.dump(progress_json, w, indent=4)
+ json.dump(progress_json, w, indent=2)