mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-14 15:46:28 +00:00
Generators: main.py is now dawn_json_generator.py
This merges all the files for main.py together again except generator_lib.py because there doesn't seeem to be a good way to separate the pure dawn.json generators and the dawn wire generator. Also updates the GN templates to make it easier to define new generators based on generator_lib, and move the Jinja2 template "stdlib" to generator_lib.py BUG=dawn:165 Change-Id: I1b5b2ef0a59cb142e214f3af9a58048a88ae949a Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/7880 Commit-Queue: Kai Ninomiya <kainino@chromium.org> Reviewed-by: Austin Eng <enga@chromium.org> Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
committed by
Commit Bot service account
parent
88860d1ced
commit
031fbbbaa1
@@ -96,9 +96,25 @@ def _do_renders(renders, template_dir):
|
||||
loader = PreprocessingLoader(template_dir)
|
||||
env = jinja2.Environment(loader=loader, lstrip_blocks=True, trim_blocks=True, line_comment_prefix='//*')
|
||||
|
||||
def do_assert(expr):
|
||||
assert expr
|
||||
return ''
|
||||
|
||||
def debug(text):
|
||||
print(text)
|
||||
|
||||
base_params = {
|
||||
'enumerate': enumerate,
|
||||
'format': format,
|
||||
'len': len,
|
||||
'debug': debug,
|
||||
'assert': do_assert,
|
||||
}
|
||||
|
||||
outputs = []
|
||||
for render in renders:
|
||||
params = {}
|
||||
params.update(base_params)
|
||||
for param_dict in render.params_dicts:
|
||||
params.update(param_dict)
|
||||
content = env.get_template(render.template).render(**params)
|
||||
|
||||
Reference in New Issue
Block a user