From aec0ef3cbfafb79c32592c1ee39832c787f4f202 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Wed, 24 Mar 2021 17:10:54 -0700 Subject: Switch devices.h to nvm.toml data --- tools/gen_nvm_devices.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 tools/gen_nvm_devices.py (limited to 'tools') diff --git a/tools/gen_nvm_devices.py b/tools/gen_nvm_devices.py new file mode 100644 index 000000000..3cda8671f --- /dev/null +++ b/tools/gen_nvm_devices.py @@ -0,0 +1,23 @@ +import sys +import cascadetoml +import pathlib +import typer +from jinja2 import Template + + +def main(input_template: pathlib.Path, output_path: pathlib.Path): + flashes = cascadetoml.filter_toml(pathlib.Path("../../data/nvm.toml"), []) + + template = Template(input_template.read_text()) + + settings = {"nvms": []} + for flash in flashes["nvm"]: + if "sku" not in flash or flash["sku"] == flash["manufacturer"]: + continue + settings["nvms"].append(dict(flash)) + + output_path.write_text(template.render(settings)) + + +if __name__ == "__main__": + typer.run(main) -- cgit v1.2.3