mirror of
https://github.com/Druthulu/BFM-decomp
synced 2026-09-29 07:10:32 -04:00
feat(phase-15): #3 types-header propagation — +8 struct-using shared fns; fleet 51.77% -> 52.08%
- fix tools/build_engine_types.py to be ADDITIVE: merge new source types with the types already in engine_types.h (a re-run after a prior --strip was destructive — it dropped the ~34 already-migrated types and broke the build; caught + reverted) - engine_types.h 34 -> 42 named types (the 8 from wave-1's struct-using matches); inline defs stripped from ov_SC01_077.c (byte-neutral) - dedup_propagate --auto-from: 8 of 15 struct-blocked matches now self-contained -> propagated across all 134 overlays (byte-gated); 7 remain (anonymous/typedef'd types) - R22 CLEAN fleet rebuild: 136/136 byte-identical; dedup-check 1333/0 - zero agent tokens (deterministic)
This commit is contained in:
@@ -60,6 +60,7 @@ def main():
|
||||
args = ap.parse_args()
|
||||
|
||||
c_path = os.path.join(REPO, f'src/{args.source}/{args.source}.c')
|
||||
out_path = os.path.join(REPO, args.out)
|
||||
text = open(c_path).read()
|
||||
defs = find_defs(text)
|
||||
if not defs:
|
||||
@@ -75,6 +76,21 @@ def main():
|
||||
seen.add(key)
|
||||
ordered.append((kind, name, body))
|
||||
|
||||
# ADDITIVE merge: keep the types already in the existing header so a re-run after a prior
|
||||
# --strip does NOT drop earlier migrations. The header is the cumulative record; the source
|
||||
# only ever holds the NEW inline defs (the older ones were stripped in a previous pass).
|
||||
# Existing header types keep their (compile-valid) order; new source types append after.
|
||||
if os.path.exists(out_path):
|
||||
htext = open(out_path).read()
|
||||
existing = [(k, n, htext[s:e]) for k, n, s, e in find_defs(htext)]
|
||||
merged, mseen = [], set()
|
||||
for kind, name, body in existing + ordered:
|
||||
if (kind, name) in mseen:
|
||||
continue
|
||||
mseen.add((kind, name))
|
||||
merged.append((kind, name, body))
|
||||
ordered = merged
|
||||
|
||||
guard = 'BFM_ENGINE_TYPES_H'
|
||||
out = [f'#ifndef {guard}', f'#define {guard}',
|
||||
'/* src/shared/engine_types.h — shared engine struct/union types (Phase 15 §14c).',
|
||||
@@ -91,7 +107,6 @@ def main():
|
||||
out.append(body if body.rstrip().endswith(';') else body + ';')
|
||||
out.append('')
|
||||
out.append(f'#endif /* {guard} */')
|
||||
out_path = os.path.join(REPO, args.out)
|
||||
os.makedirs(os.path.dirname(out_path), exist_ok=True)
|
||||
open(out_path, 'w').write('\n'.join(out) + '\n')
|
||||
print(f'wrote {args.out}: {len(ordered)} named types (forward decls + defs, source order)')
|
||||
|
||||
Reference in New Issue
Block a user