Commit 673151f4 authored by Stephan Seitz's avatar Stephan Seitz
Browse files

Sort headers/global definitions to enable reproducible code generation

headers and global_declarations are generated by methods that return
sets. So even with the same inputs it is not guaranteed that the same
source code is generated since sets do not guarantee a specific order
when iterating over them.
parent 71b8767b
......@@ -87,7 +87,7 @@ def get_global_declarations(ast):
visit_node(ast)
return set(global_declarations)
return sorted(set(global_declarations), key=lambda x: str(x))
def get_headers(ast_node: Node) -> Set[str]:
......@@ -103,7 +103,7 @@ def get_headers(ast_node: Node) -> Set[str]:
if isinstance(a, Node):
headers.update(get_headers(a))
return headers
return sorted(headers)
# --------------------------------------- Backend Specific Nodes -------------------------------------------------------
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment