Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions dev_scripts/codegen/codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
def _generate_sdk(
meta_model_path: pathlib.Path,
snippet_path: pathlib.Path,
sdk_path: pathlib.Path,
target_path: pathlib.Path,
) -> None:
subprocess.run(
[
Expand All @@ -20,7 +20,7 @@ def _generate_sdk(
"--snippets_dir",
str(snippet_path),
"--output_dir",
str(sdk_path / "src"),
target_path,
"--target",
"cpp",
],
Expand All @@ -39,7 +39,7 @@ def main() -> int:

snippet_dir = this_dir / "snippets"

_generate_sdk(args.meta_model, snippet_dir, this_dir.parent.parent)
_generate_sdk(args.meta_model, snippet_dir, args.target)

return 0

Expand Down
56 changes: 36 additions & 20 deletions dev_scripts/update_to_aas_core_meta_codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,29 +57,45 @@ def _regenerate_code(our_repo: pathlib.Path) -> Optional[int]:

meta_model_path = our_repo / "dev_scripts/codegen/meta_model.py"

target_dir = our_repo

print("Starting to run codegen script")
start = time.perf_counter()

proc = subprocess.run(
[
sys.executable,
"codegen.py",
"--meta_model",
str(meta_model_path),
"--target",
str(target_dir),
],
check=True,
cwd=str(codegen_dir),
)

if proc.returncode != 0:
return proc.returncode
with tempfile.TemporaryDirectory() as generate_dir_path:
start = time.perf_counter()

generate_dir = pathlib.Path(generate_dir_path)

proc = subprocess.run(
[
sys.executable,
"codegen.py",
"--meta_model",
str(meta_model_path),
"--target",
str(generate_dir),
],
check=True,
cwd=str(codegen_dir),
)

if proc.returncode != 0:
return proc.returncode

duration = time.perf_counter() - start
print(f"Generating the code took: {duration:.2f} seconds.")

for pth in generate_dir.glob("**/*.cpp"):
target_dir = our_repo / "src"
tgt_pth = target_dir / pth.relative_to(generate_dir)

print(f"Copying the code: from {pth} to {tgt_pth} ...")
shutil.copy(pth, tgt_pth)

for pth in generate_dir.glob("**/*.hpp"):
target_dir = our_repo / "include/aas_core/aas_3_0"
tgt_pth = target_dir / pth.relative_to(generate_dir)

duration = time.perf_counter() - start
print(f"Generating the code took: {duration:.2f} seconds.")
print(f"Copying the code: from {pth} to {tgt_pth} ...")
shutil.copy(pth, tgt_pth)

return None

Expand Down