diff --git a/tools/invocation_header_gen.py b/tools/invocation_header_gen.py index e36d667d7..3ba760803 100755 --- a/tools/invocation_header_gen.py +++ b/tools/invocation_header_gen.py @@ -156,6 +156,14 @@ def parse_xml(xml_file): def generate(args, invocations): + # We require jinja2 to be at least version 2.10, + # In the past we used the 'namespace' feature from that version. + # other versions of jinja, particularly `minijinja`, don't support + # namespaces. However in case `namespace` is needed in the future require a + # version which supports it. + jinja2_version = version("jinja2") + if jinja2_version < "2.10": + sys.exit("Jinja2 should be >= 2.10") header_title = "API" if args.libsel4: @@ -177,15 +185,6 @@ def generate(args, invocations): if __name__ == "__main__": - # We require jinja2 to be at least version 2.10, - # In the past we used the 'namespace' feature from that version. - # other versions of jinja, particularly `minijinja`, don't support - # namespaces. However in case `namespace` is needed in the future require a - # version which supports it. - jinja2_version = version("jinja2") - if jinja2_version < "2.10": - sys.exit("Jinja2 should be >= 2.10") - args = parse_args() invocations = parse_xml(args.xml) diff --git a/tools/syscall_header_gen.py b/tools/syscall_header_gen.py index 1b5626720..710840080 100755 --- a/tools/syscall_header_gen.py +++ b/tools/syscall_header_gen.py @@ -18,13 +18,6 @@ import sys import xml.dom.minidom from condition import condition_to_cpp -# We require jinja2 to be at least version 2.10, -# In the past we used the 'namespace' feature from that version. -# other versions of jinja, particularly `minijinja`, don't support namespaces. -# However in case `namespace` is needed in the future require a -# version which supports it. -pkg_resources.require("jinja2>=2.10") - COMMON_HEADER = """ /* This header was generated by kernel/tools/syscall_header_gen.py. @@ -210,6 +203,15 @@ def map_syscalls_neg(syscalls): def generate_kernel_file(kernel_header, api, debug): + # We require jinja2 to be at least version 2.10, + # In the past we used the 'namespace' feature from that version. + # other versions of jinja, particularly `minijinja`, don't support + # namespaces. However in case `namespace` is needed in the future require a + # version which supports it. + jinja2_version = version("jinja2") + if jinja2_version < "2.10": + sys.exit("Jinja2 should be >= 2.10") + template = Environment(loader=BaseLoader, trim_blocks=False, lstrip_blocks=False).from_string(KERNEL_HEADER_TEMPLATE) data = template.render({'assembler': map_syscalls_neg(api), @@ -227,15 +229,6 @@ def generate_libsel4_file(libsel4_header, syscalls): if __name__ == "__main__": - # We require jinja2 to be at least version 2.10, - # In the past we used the 'namespace' feature from that version. - # other versions of jinja, particularly `minijinja`, don't support - # namespaces. However in case `namespace` is needed in the future require a - # version which supports it. - jinja2_version = version("jinja2") - if jinja2_version < "2.10": - sys.exit("Jinja2 should be >= 2.10") - args = parse_args() (api, debug) = parse_xml(args.xml, args.mcs)