Skip to content
Snippets Groups Projects
Commit 3111ccef authored by Dominic Kempf's avatar Dominic Kempf
Browse files

Some doc on file generation

parent ec0fe9e4
No related branches found
No related tags found
No related merge requests found
""" Manages the generation of C++ header files """
from dune.perftool.generation import retrieve_cache_items
def generate_file(filename, tag, content, headerguard=True):
"""
......@@ -8,9 +7,18 @@ def generate_file(filename, tag, content, headerguard=True):
Arguments:
----------
filename : str
The filename to write the generated code to.
tag: str
The tag, that all entries related to this file in the cache have.
content: list
A list of Generables to put into the file.
Keyword Arguments:
------------------
headerguard : bool
Whether a double inclusion protection header should be added to the file.
The name of the macro is mangled from the absolute path. Defaults to True.
"""
with open(filename, 'w') as f:
# Add a double inclusion protection header
......@@ -19,6 +27,7 @@ def generate_file(filename, tag, content, headerguard=True):
f.write("#ifndef {0}\n#define {0}\n\n".format(macro))
# Add the includes from the cache
from dune.perftool.generation import retrieve_cache_items
for inc in retrieve_cache_items((tag, 'include'), union=False):
from cgen import Include
assert isinstance(inc, Include)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment