Skip to content

Commit 893e8fd

Browse files
Cruz Monrreal IICruz Monrreal II
authored andcommitted
Merge pull request ARMmbed#10118 from null
null
2 parents 28d06f7 + 19562ff commit 893e8fd

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

tools/export/exporters.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,15 +206,17 @@ def gen_file(self, template_file, data, target_file, **kwargs):
206206
self.generated_files += [target_path]
207207

208208
def gen_file_nonoverwrite(self, template_file, data, target_file, **kwargs):
209-
"""Generates a project file from a template using jinja"""
209+
"""Generates or selectively appends a project file from a template"""
210210
target_text = self._gen_file_inner(template_file, data, target_file, **kwargs)
211211
target_path = self.gen_file_dest(target_file)
212212
if exists(target_path):
213213
with open(target_path) as fdin:
214-
old_text = fdin.read()
215-
if target_text not in old_text:
214+
old_lines_set = set(fdin.read().splitlines())
215+
target_set = set(target_text.splitlines())
216+
to_append = target_set - old_lines_set
217+
if len(to_append) > 0:
216218
with open(target_path, "a") as fdout:
217-
fdout.write(target_text)
219+
fdout.write("\n".join(to_append))
218220
else:
219221
logging.debug("Generating: %s", target_path)
220222
open(target_path, "w").write(target_text)

0 commit comments

Comments
 (0)