Skip to content

Commit 92c9fae

Browse files
authored
CGEN command in ner_environment (#359)
1 parent 95bd265 commit 92c9fae

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

ner_environment/build_system/build_system.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,32 @@ def build(profile: str = typer.Option(None, "--profile", "-p", callback=unsuppor
7676
if not clean and is_cmake:
7777
fix_compile_commands()
7878

79+
# ==============================================================================
80+
# CGEN command
81+
# ==============================================================================
82+
83+
@app.command(help="Generate CGEN code for your project")
84+
def cgen(path: Path = typer.Option(Path("./Core"), "--output-path","-o", help="Output path for generated files (must contain Inc and Src subdirectories"),
85+
project: str | None = typer.Option(None, "--project", "-p", help="The project/node to generate for. This will autodetect project if unset.")):
86+
def generate_project() -> str:
87+
curr_project = os.path.basename(os.getcwd())
88+
if curr_project == "TSECU-Shepherd":
89+
return "BMS"
90+
if curr_project == "Cerberus-2.0":
91+
return "VCU"
92+
if curr_project == "Lightning":
93+
return "Lightning"
94+
if curr_project == "MSB-FW-2":
95+
return "MSB"
96+
print("[bold red] Error: No valid project found")
97+
sys.exit(1)
98+
99+
if project is None:
100+
project = generate_project()
101+
102+
run_command(["python3", "./Drivers/Odyssey-Definitions/code-gen/codegen.py", project, path], stream_output=True)
103+
104+
79105
# ==============================================================================
80106
# Clang command
81107
# ==============================================================================

0 commit comments

Comments
 (0)