46 FileEntry = collections.namedtuple(
'FileEntry',
'target_name file_contents')
49 pattern = re.compile(
"#include \"(.*)\"")
53 for i
in range(len(source)):
59 contents = cts.splitlines()
60 entry = FileEntry(target_name=dst, file_contents=contents)
61 files.append((os.path.basename(src), entry))
64 files_dict = dict(files)
70 tmp_file = file[1].file_contents
71 print(file[1].target_name)
76 found = pattern.search(line)
78 include_file = found.group(1)
79 data = files_dict[include_file].file_contents
80 updated_file.extend(data)
82 updated_file.append(line)
86 if file_count == len(tmp_file):
90 tmp_file = updated_file
93 tmp_file.insert(0,
"R\"(\n")
94 tmp_file.append(
"\n)\"")
95 entry = FileEntry(target_name=file[1].target_name, file_contents=tmp_file)
96 final_files.append((file[0], entry))
99 for file
in final_files:
100 with open(file[1].target_name,
'w+')
as out_file:
101 out_file.write(
"\n".join(file[1].file_contents))