Sync toolchain fixes from pokeemerald

This commit is contained in:
GriffinR
2024-10-11 15:21:06 -04:00
parent 99de06de5f
commit d2c592030d
3 changed files with 21 additions and 8 deletions
+1 -3
View File
@@ -305,10 +305,9 @@ else
@echo -e ".text\n\t.align\t2, 0 @ Don't pad with nop\n" >> $3.s @echo -e ".text\n\t.align\t2, 0 @ Don't pad with nop\n" >> $3.s
$$(AS) $$(ASFLAGS) -o $$@ $3.s $$(AS) $$(ASFLAGS) -o $$@ $3.s
endif endif
ifneq ($(NODEP),1)
$1.d: $2 $1.d: $2
$(SCANINC) -M $1.d $(INCLUDE_SCANINC_ARGS) -I tools/agbcc/include $2 $(SCANINC) -M $1.d $(INCLUDE_SCANINC_ARGS) -I tools/agbcc/include $2
ifneq ($(NODEP),1)
$1.o: $1.d
-include $1.d -include $1.d
endif endif
endef endef
@@ -336,7 +335,6 @@ endef
define ASM_SCANINC define ASM_SCANINC
ifneq ($(NODEP),1) ifneq ($(NODEP),1)
$1.o: $1.d
$1.d: $2 $1.d: $2
$(SCANINC) -M $1.d $(INCLUDE_SCANINC_ARGS) -I "" $2 $(SCANINC) -M $1.d $(INCLUDE_SCANINC_ARGS) -I "" $2
-include $1.d -include $1.d
+6 -1
View File
@@ -33,6 +33,11 @@ CFile::CFile(std::string path)
m_size = std::ftell(fp); m_size = std::ftell(fp);
if (m_size < 0)
FATAL_ERROR("File size of \"%s\" is less than zero.\n", path.c_str());
else if (m_size == 0)
return; // Empty file
m_buffer = new char[m_size + 1]; m_buffer = new char[m_size + 1];
m_buffer[m_size] = 0; m_buffer[m_size] = 0;
@@ -49,7 +54,7 @@ CFile::CFile(std::string path)
CFile::~CFile() CFile::~CFile()
{ {
delete[] m_buffer; if (m_size > 0) delete[] m_buffer;
} }
void CFile::FindIncbins() void CFile::FindIncbins()
+14 -4
View File
@@ -157,19 +157,29 @@ int main(int argc, char **argv)
// Print a make rule for the object file // Print a make rule for the object file
size_t ext_pos = make_outfile.find_last_of("."); size_t ext_pos = make_outfile.find_last_of(".");
auto object_file = make_outfile.substr(0, ext_pos + 1) + "o"; auto object_file = make_outfile.substr(0, ext_pos + 1) + "o";
output << object_file.c_str() << ": "; output << object_file.c_str() << ":";
for (const std::string &path : dependencies) for (const std::string &path : dependencies)
{ {
output << path << " "; output << " " << path;
} }
output << '\n';
// Dependency list rule. // Dependency list rule.
// Although these rules are identical, they need to be separate, else make will trigger the rule again after the file is created for the first time. // Although these rules are identical, they need to be separate, else make will trigger the rule again after the file is created for the first time.
output << "\n" << make_outfile.c_str() << ": "; output << make_outfile.c_str() << ":";
for (const std::string &path : dependencies_includes) for (const std::string &path : dependencies_includes)
{ {
output << path << " "; output << " " << path;
} }
output << '\n';
// Dummy rules
// If a dependency is deleted, make will try to make it, instead of rescanning the dependencies before trying to do that.
for (const std::string &path : dependencies)
{
output << path << ":\n";
}
output.flush(); output.flush();
output.close(); output.close();
} }