Skip to content

Commit ef73f33

Browse files
committed
Add RPYBUILD_J2_DEBUG environment variable for debugging codegen
1 parent 2e8e278 commit ef73f33

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

robotpy_build/autowrap/writer.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import json
2+
import os
23
from os.path import join
34
import pathlib
5+
import pprint
46
import typing
57

68
import jinja2
@@ -9,6 +11,8 @@
911

1012
templates_path = pathlib.Path(__file__).parent.absolute()
1113

14+
_emit_j2_debug = os.getenv("RPYBUILD_J2_DEBUG") == "1"
15+
1216

1317
class WrapperWriter:
1418
def __init__(self) -> None:
@@ -50,6 +54,10 @@ def write_files(
5054
# Jinja requires input as a dictionary
5155
data = hctx.__dict__
5256

57+
if _emit_j2_debug:
58+
with open(join(cxx_gen_dir, f"{name}.txt"), "w") as fp:
59+
fp.write(pprint.pformat(hctx))
60+
5361
# Write the cpp file first
5462
fname = join(cxx_gen_dir, f"{name}.cpp")
5563
generated_sources.append(fname)

0 commit comments

Comments
 (0)