Tensor Tiling Library
 
Loading...
Searching...
No Matches
split_doxgen.py
Go to the documentation of this file.
1#!/usr/bin/env python3
2
3# To update the generated files From the src directory run this command.
4# in the src directory
5#
6# find . -name *.h -exec python ../scripts/generate_enum_strings.py {} \;
7#
8# The script generate_enum_strings.sh will do this for you.
9
10import sys
11import os
12import re
13
14def ProcessFile(input_filename):
15 output_file_names = set()
16 output_file_stream = None
17
18 with open(input_filename, "r") as input_file_stream:
19 for line in input_file_stream.readlines():
20 regex = re.search("# [0-9]* \"([A-Za-z_0-9-\./]*h)\"", line)
21 if regex:
22 if output_file_stream:
23 output_file_stream.close()
24 output_file_stream = None
25
26 output_file_name = os.path.relpath(os.path.abspath(regex.group(1)))
27 print(output_file_name)
28
29 if output_file_name in output_file_names:
30 output_file_stream = open(output_file_name, "r+")
31 else:
32 output_path = os.path.dirname(output_file_name)
33
34 if (output_path != "") and (not os.path.exists(output_path)):
35 os.makedirs(output_path)
36 output_file_stream = open(output_file_name, "w+")
37 output_file_names.add(output_file_name)
38
39 output_file_stream.seek(0, 2)
40 else:
41 if output_file_stream is not None:
42 output_file_stream.write(line)
43
44 output_file_stream.close()
45 output_file_stream = None
46
47 for output_file_name in output_file_names:
48 os.system("clang-format -i " + output_file_name)
49
50if __name__ == "__main__":
51 ProcessFile(sys.argv[1])
ProcessFile(input_filename)