MCPcopy Create free account
hub / github.com/URLab-Sim/UnrealRoboticsLab / main

Function main

Scripts/codegen/regen_all.py:54–102  ·  view source on GitHub ↗
(argv: list[str] | None = None)

Source from the content-addressed store, hash-verified

52
53
54def main(argv: list[str] | None = None) -> int:
55 ap = argparse.ArgumentParser()
56 ap.add_argument(
57 "--skip-codegen", action="store_true",
58 help="Only rebuild the three snapshot JSONs; skip generate_ue_components.py.",
59 )
60 args = ap.parse_args(argv)
61
62 py = sys.executable
63
64 steps: list[tuple[str, list[str]]] = [
65 ("mjxmacro snapshot",
66 [py, os.path.join(HERE, "build_mjxmacro_snapshot.py")]),
67 ("MJCF schema snapshot",
68 [py, os.path.join(HERE, "build_mjcf_schema_snapshot.py")]),
69 ]
70 # Introspect snapshot needs libclang and now also supplies the data
71 # build_mjspec_snapshot.py used to scrape via regex (mjsX struct
72 # fields, mjt* enums, mjs_setTo* sigs). Optional only in the sense
73 # that a stale on-disk snapshot still drives the codegen — the
74 # --require-introspect default in generate_ue_components.py makes
75 # the gate fatal at next run if the snapshot really is missing.
76 introspect_step = (
77 "introspect snapshot (clang AST — supersedes mjspec snapshot)",
78 [py, os.path.join(HERE, "build_introspect_snapshot.py")],
79 )
80 steps.append(introspect_step)
81 if not args.skip_codegen:
82 steps.append(("UE component codegen",
83 [py, os.path.join(HERE, "generate_ue_components.py")]))
84
85 for label, cmd in steps:
86 rc = _run(label, cmd)
87 if rc != 0:
88 # Introspect is optional — warn but continue when it's the
89 # one that failed (most commonly: libclang not on PATH).
90 if label.startswith("introspect snapshot"):
91 print(
92 " (introspect is optional; codegen will use the "
93 "existing snapshot — type-shape drift may be stale "
94 "until you install libclang.)",
95 flush=True,
96 )
97 continue
98 return rc
99
100 print("\nAll regen steps completed.", flush=True)
101 print("Next: close the editor, run the URLab build + test cycle to verify.", flush=True)
102 return 0
103
104
105if __name__ == "__main__":

Callers 1

regen_all.pyFile · 0.70

Calls 1

_runFunction · 0.70

Tested by

no test coverage detected