Skip to content

Commit

Permalink
Fix duplicate addition of LLVM header
Browse files Browse the repository at this point in the history
  • Loading branch information
Rot127 committed Mar 22, 2024
1 parent 6531819 commit a1a41e4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 6 additions & 1 deletion LLVMImporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
get_generation_timestamp,
src_matches_old_src,
include_file,
gen_c_doxygen,
gen_c_doxygen, get_delimiter_line,
)
import PluginInfo
import HexagonArchInfo
Expand Down Expand Up @@ -504,6 +504,11 @@ def add_license_info_header(self) -> None:
with open(p, "r+") as f:
content = f.read()
f.seek(0, 0)

# If header message is there, skip it.
match = re.search(get_delimiter_line(), content)
if match:
content = content[match.start():]
f.write(get_license() + "\n" + get_generation_timestamp(self.config) + "\n" + content)
if p not in self.edited_files:
log("Write {}".format(p), LogLevel.INFO)
Expand Down
6 changes: 5 additions & 1 deletion helperFunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,13 @@ def set_pos_after_license(file: TextIO) -> None:
return


def get_delimiter_line() -> str:
return "{}\n".format(PluginInfo.GENERATION_WARNING_DELIMITER)


def get_generation_warning_c_code() -> str:
url = PluginInfo.REPO_URL
msg = "{}\n".format(PluginInfo.GENERATION_WARNING_DELIMITER)
msg = get_delimiter_line()
msg += "// The following code is generated.\n"
msg += "// Do not edit. Repository of code generator:\n"
msg += "// {}\n".format(url)
Expand Down

0 comments on commit a1a41e4

Please sign in to comment.