Skip to content

Commit

Permalink
hopefully fix compilation for everythign
Browse files Browse the repository at this point in the history
  • Loading branch information
crowell committed Jul 8, 2022
1 parent aaf1632 commit 2b29dbb
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 14 deletions.
2 changes: 1 addition & 1 deletion ZAPDTR/ZAPD/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ int main(int argc, char* argv[])

auto start = std::chrono::steady_clock::now();
int fileListSize = fileList.size();
Globals::Instance->singleThreaded = false;
//Globals::Instance->singleThreaded = false;

for (int i = 0; i < fileListSize; i++)
Globals::Instance->workerData[i] = new FileWorker();
Expand Down
6 changes: 4 additions & 2 deletions ZAPDTR/ZAPD/ZFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -801,9 +801,11 @@ void ZFile::GenerateSourceHeaderFiles()
OutputFormatter formatter;

formatter.Write("#pragma once\n");
bool first = true;
for (ZResource* res : resources)
{
std::string resSrc = res->GetSourceOutputHeader("");
std::string resSrc = res->GetSourceOutputHeader("", first);
first = false;
formatter.Write(resSrc);

if (resSrc != "")
Expand All @@ -812,7 +814,7 @@ void ZFile::GenerateSourceHeaderFiles()

for (auto& sym : symbolResources)
{
formatter.Write(sym.second->GetSourceOutputHeader(""));
formatter.Write(sym.second->GetSourceOutputHeader("", first));
}

formatter.Write(ProcessExterns());
Expand Down
18 changes: 12 additions & 6 deletions ZAPDTR/ZAPD/ZResource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,13 @@ void ZResource::GetSourceOutputCode([[maybe_unused]] const std::string& prefix)
}
}

std::string ZResource::GetSourceOutputHeader([[maybe_unused]] const std::string& prefix)
std::string ZResource::GetSourceOutputHeader([[maybe_unused]] const std::string& prefix, bool first)
{
static std::set<std::string> myset;
static std::set<std::string> totalset;
std::string s2 = name;
if (first) {
totalset.clear();
}
if (Globals::Instance->otrMode && genOTRDef)
{
std::string str = "";;
Expand Down Expand Up @@ -348,11 +352,13 @@ std::string ZResource::GetSourceOutputHeader([[maybe_unused]] const std::string&
else
str += StringHelper::Sprintf("#define d%s \"__OTR__%s/%s\"", name.c_str(), outName.c_str(), nameStr.c_str());

if (myset.find(name) == myset.end()) {
if (totalset.find(name) == totalset.end()) {
#ifdef _WIN32
str += StringHelper::Sprintf("\nstatic const __declspec(align(2)) char %s[] = d%s;", name.c_str(), name.c_str());
#else
str += StringHelper::Sprintf("\nstatic const char %s[] __attribute__((aligned (2))) = d%s;", name.c_str(), name.c_str());
myset.insert(name);
} else {
str += StringHelper::Sprintf("\nextern static const char %s[];", name.c_str());
#endif
totalset.insert(name);
}

return str;
Expand Down
2 changes: 1 addition & 1 deletion ZAPDTR/ZAPD/ZResource.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class ZResource
[[nodiscard]] virtual std::string GetDefaultName(const std::string& prefix) const;

virtual void GetSourceOutputCode(const std::string& prefix);
virtual std::string GetSourceOutputHeader(const std::string& prefix);
virtual std::string GetSourceOutputHeader(const std::string& prefix, bool first=true);
virtual void CalcHash();
/**
* Exports the resource to binary format
Expand Down
2 changes: 1 addition & 1 deletion ZAPDTR/ZAPD/ZString.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ std::string ZString::GetBodySourceCode() const
return StringHelper::Sprintf("\t\"%s\"", strData.data());
}

std::string ZString::GetSourceOutputHeader([[maybe_unused]] const std::string& prefix)
std::string ZString::GetSourceOutputHeader([[maybe_unused]] const std::string& prefix, bool first)
{
return StringHelper::Sprintf("#define %s_macro \"%s\"", name.c_str(), strData.data());
}
Expand Down
2 changes: 1 addition & 1 deletion ZAPDTR/ZAPD/ZString.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class ZString : public ZResource
Declaration* DeclareVar(const std::string& prefix, const std::string& bodyStr) override;
std::string GetBodySourceCode() const override;

std::string GetSourceOutputHeader(const std::string& prefix) override;
std::string GetSourceOutputHeader(const std::string& prefix, bool first = true) override;
std::string GetSourceTypeName() const override;
ZResourceType GetResourceType() const override;

Expand Down
2 changes: 1 addition & 1 deletion ZAPDTR/ZAPD/ZSymbol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ size_t ZSymbol::GetRawDataSize() const
return typeSize;
}

std::string ZSymbol::GetSourceOutputHeader([[maybe_unused]] const std::string& prefix)
std::string ZSymbol::GetSourceOutputHeader([[maybe_unused]] const std::string& prefix, bool first)
{
if (isArray)
{
Expand Down
2 changes: 1 addition & 1 deletion ZAPDTR/ZAPD/ZSymbol.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ZSymbol : public ZResource

Declaration* DeclareVar(const std::string& prefix, const std::string& bodyStr) override;

std::string GetSourceOutputHeader(const std::string& prefix) override;
std::string GetSourceOutputHeader(const std::string& prefix, bool first=true) override;

std::string GetSourceTypeName() const override;
ZResourceType GetResourceType() const override;
Expand Down

0 comments on commit 2b29dbb

Please sign in to comment.