add support for clang compiler (#592)
* hacks to align strings for clang... wow just wow * start work to getting built with clang * fix issues with struct constructors, all builds, doesn't link still * fix some narrowing issues that clang complains about * fix compliation of zapd * fix null deref in VersionInfo * builds with clang * make stringbuilding use StringHelper instead of addition * fix linking * add CLANG SHIP overlay on clang built versions * doesn't need to be volatile * mark unknown strings as extern * rename some stuff * can't align extern * hopefully fix compilation for everythign * expandtab * allow setting LD * Revert "allow setting LD" This reverts commit 711aba6db2c41bab476bd34e878af6a37a7f5559. maybe to use lld it should be a LDFLAG? * -Wno-deprecated-declarations is required for newer versions of clang on macOS 13 beta sdk, the version of apple clang requires this * Add jenkins support for clang * Forward CXX flags to stormlib compilation * Move GCC only flags to check * use exports to set multiarch setup * Fix Jenkins forever * use make instead of cmake --build add some flags to build with clang-11 as well * address review coments - rework extraction to allow multi thread - misc readability cleanup * update makefile to add WARN on linux+clang Co-authored-by: David Chavez <david@dcvz.io>
This commit is contained in:
@@ -461,8 +461,8 @@ char* OldMain(char* infilename)
|
||||
else
|
||||
{
|
||||
char comprType[5] = {
|
||||
CommChunk.compressionTypeH >> 8, CommChunk.compressionTypeH & 0xFF,
|
||||
CommChunk.compressionTypeL >> 8, CommChunk.compressionTypeL & 0xFF, 0};
|
||||
static_cast<char>(CommChunk.compressionTypeH >> 8), static_cast<char>(CommChunk.compressionTypeH & 0xFF),
|
||||
static_cast<char>(CommChunk.compressionTypeL >> 8), static_cast<char>(CommChunk.compressionTypeL & 0xFF), 0};
|
||||
fail_parse("file is of the wrong compression type [got %s (%08x)]", &comprType,
|
||||
cType);
|
||||
}
|
||||
@@ -603,8 +603,8 @@ char* OldMain(char* infilename)
|
||||
{
|
||||
s32 startPos = aloops[0].start, endPos = aloops[0].end;
|
||||
const char* markerNames[2] = {"start", "end"};
|
||||
Marker markers[2] = {{1, startPos >> 16, startPos & 0xffff},
|
||||
{2, endPos >> 16, endPos & 0xffff}};
|
||||
Marker markers[2] = {{1, static_cast<u16>(startPos >> 16), static_cast<u16>(startPos & 0xffff)},
|
||||
{2, static_cast<u16>(endPos >> 16), static_cast<u16>(endPos & 0xffff)}};
|
||||
write_header(ofile, "MARK", 2 + 2 * sizeof(Marker) + 1 + 5 + 1 + 3);
|
||||
s16 numMarkers = bswap16(2);
|
||||
fwrite(&numMarkers, sizeof(s16), 1, ofile);
|
||||
@@ -666,4 +666,4 @@ char* OldMain(char* infilename)
|
||||
fclose(ifile);
|
||||
fclose(ofile);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -800,9 +800,11 @@ void ZFile::GenerateSourceHeaderFiles()
|
||||
{
|
||||
OutputFormatter formatter;
|
||||
|
||||
formatter.Write("#pragma once\n");
|
||||
std::set<std::string> nameSet;
|
||||
for (ZResource* res : resources)
|
||||
{
|
||||
std::string resSrc = res->GetSourceOutputHeader("");
|
||||
std::string resSrc = res->GetSourceOutputHeader("", &nameSet);
|
||||
formatter.Write(resSrc);
|
||||
|
||||
if (resSrc != "")
|
||||
@@ -811,7 +813,7 @@ void ZFile::GenerateSourceHeaderFiles()
|
||||
|
||||
for (auto& sym : symbolResources)
|
||||
{
|
||||
formatter.Write(sym.second->GetSourceOutputHeader(""));
|
||||
formatter.Write(sym.second->GetSourceOutputHeader("", &nameSet));
|
||||
}
|
||||
|
||||
formatter.Write(ProcessExterns());
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "WarningHandler.h"
|
||||
#include "ZFile.h"
|
||||
#include <Globals.h>
|
||||
#include <set>
|
||||
#include <ZDisplayList.h>
|
||||
#include <ZArray.h>
|
||||
|
||||
@@ -304,7 +305,7 @@ 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, std::set<std::string> *nameSet)
|
||||
{
|
||||
if (Globals::Instance->otrMode && genOTRDef)
|
||||
{
|
||||
@@ -342,9 +343,20 @@ std::string ZResource::GetSourceOutputHeader([[maybe_unused]] const std::string&
|
||||
prefix = "text";
|
||||
|
||||
if (prefix != "")
|
||||
str += StringHelper::Sprintf("#define %s \"__OTR__%s/%s/%s\"", name.c_str(), prefix.c_str(), outName.c_str(), nameStr.c_str());
|
||||
str += StringHelper::Sprintf("#define d%s \"__OTR__%s/%s/%s\"", name.c_str(), prefix.c_str(), outName.c_str(), nameStr.c_str());
|
||||
else
|
||||
str += StringHelper::Sprintf("#define %s \"__OTR__%s/%s\"", name.c_str(), outName.c_str(), nameStr.c_str());
|
||||
str += StringHelper::Sprintf("#define d%s \"__OTR__%s/%s\"", name.c_str(), outName.c_str(), nameStr.c_str());
|
||||
|
||||
if (nameSet && nameSet->find(name) == nameSet->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());
|
||||
#endif
|
||||
if (nameSet) {
|
||||
nameSet->insert(name);
|
||||
}
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <cstdint>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@@ -116,7 +117,7 @@ public:
|
||||
[[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, std::set<std::string> *nameSet);
|
||||
virtual void CalcHash();
|
||||
/**
|
||||
* Exports the resource to binary format
|
||||
|
||||
@@ -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, std::set<std::string> *nameSet)
|
||||
{
|
||||
return StringHelper::Sprintf("#define %s_macro \"%s\"", name.c_str(), strData.data());
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ public:
|
||||
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, std::set<std::string> *nameSet) override;
|
||||
std::string GetSourceTypeName() const override;
|
||||
ZResourceType GetResourceType() const override;
|
||||
|
||||
|
||||
@@ -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, std::set<std::string> *nameSet)
|
||||
{
|
||||
if (isArray)
|
||||
{
|
||||
|
||||
@@ -18,7 +18,7 @@ public:
|
||||
|
||||
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, std::set<std::string> *nameSet) override;
|
||||
|
||||
std::string GetSourceTypeName() const override;
|
||||
ZResourceType GetResourceType() const override;
|
||||
|
||||
Reference in New Issue
Block a user