summaryrefslogtreecommitdiff
path: root/ZAPDTR
diff options
context:
space:
mode:
authorAdam Bird <Archez@users.noreply.github.com>2023-09-01 12:47:51 -0400
committerGitHub <noreply@github.com>2023-09-01 11:47:51 -0500
commitdd37d4f9b8b6dfe9984b0607e4006e9f251ab397 (patch)
treed36b147e54b86c9be4791f841ae7aeecaf45a362 /ZAPDTR
parent45b7520dcb79d5accb717e9bfda13e0e0ce2a9af (diff)
regenerate asset headers with include guards (#3132)
Diffstat (limited to 'ZAPDTR')
-rw-r--r--ZAPDTR/ZAPD/ZFile.cpp8
1 files changed, 3 insertions, 5 deletions
diff --git a/ZAPDTR/ZAPD/ZFile.cpp b/ZAPDTR/ZAPD/ZFile.cpp
index d04f3b7e3..04032e575 100644
--- a/ZAPDTR/ZAPD/ZFile.cpp
+++ b/ZAPDTR/ZAPD/ZFile.cpp
@@ -811,10 +811,10 @@ void ZFile::GenerateSourceFiles()
void ZFile::GenerateSourceHeaderFiles()
{
OutputFormatter formatter;
- std::string guard = outName.stem().string();
+ // Use parent folder and output name as guard as some headers have the same output name
+ std::string guard = xmlFilePath.parent_path().stem().string() + "_" + outName.stem().string();
std::transform(guard.begin(), guard.end(), guard.begin(), ::toupper);
- formatter.Write("#pragma once\n\n");
formatter.Write(
StringHelper::Sprintf("#ifndef %s_H\n#define %s_H 1\n\n", guard.c_str(), guard.c_str()));
formatter.Write("#include \"align_asset_macro.h\"\n");
@@ -838,7 +838,7 @@ void ZFile::GenerateSourceHeaderFiles()
formatter.Write(ProcessExterns());
- formatter.Write("#endif\n");
+ formatter.Write(StringHelper::Sprintf("\n#endif // %s_H\n", guard.c_str()));
fs::path headerFilename = GetSourceOutputFolderPath() / outName.stem().concat(".h");
@@ -846,8 +846,6 @@ void ZFile::GenerateSourceHeaderFiles()
printf("Writing H file: %s\n", headerFilename.c_str());
std::string output = formatter.GetOutput();
- while (output.back() == '\n')
- output.pop_back();
if (Globals::Instance->fileMode != ZFileMode::ExtractDirectory)
DiskFile::WriteAllText(headerFilename, output);