Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/pret/pokeemerald into por…
Browse files Browse the repository at this point in the history
…ymap-6
  • Loading branch information
GriffinRichards committed Oct 11, 2024
2 parents 091b726 + b6892f5 commit 6518f1e
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 8 deletions.
4 changes: 1 addition & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -315,10 +315,9 @@ else
@echo -e ".text\n\t.align\t2, 0\n" >> $3.s
$$(AS) $$(ASFLAGS) -o $$@ $3.s
endif
ifneq ($(NODEP),1)
$1.d: $2
$(SCANINC) -M $1.d $(INCLUDE_SCANINC_ARGS) -I tools/agbcc/include $2
ifneq ($(NODEP),1)
$1.o: $1.d
-include $1.d
endif
endef
Expand Down Expand Up @@ -346,7 +345,6 @@ endef

define ASM_SCANINC
ifneq ($(NODEP),1)
$1.o: $1.d
$1.d: $2
$(SCANINC) -M $1.d $(INCLUDE_SCANINC_ARGS) -I "" $2
-include $1.d
Expand Down
11 changes: 11 additions & 0 deletions tools/preproc/asm_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,17 @@ bool AsmFile::ParseEnum()
long enumCounter = 0;
long symbolCount = 0;

if (m_buffer[m_pos] == ':') // : <type>
{
m_pos++;
std::string underlyingType;
do {
currentHeaderLine += SkipWhitespaceAndEol();
underlyingType = ReadIdentifier();
} while (!underlyingType.empty());
currentHeaderLine += SkipWhitespaceAndEol();
}

if (m_buffer[m_pos] != '{') // assume assembly macro, otherwise assume enum and report errors accordingly
{
m_pos = fallbackPosition - 4;
Expand Down
7 changes: 6 additions & 1 deletion tools/scaninc/c_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ CFile::CFile(std::string path)

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[m_size] = 0;

Expand All @@ -49,7 +54,7 @@ CFile::CFile(std::string path)

CFile::~CFile()
{
delete[] m_buffer;
if (m_size > 0) delete[] m_buffer;
}

void CFile::FindIncbins()
Expand Down
18 changes: 14 additions & 4 deletions tools/scaninc/scaninc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,19 +157,29 @@ int main(int argc, char **argv)
// Print a make rule for the object file
size_t ext_pos = make_outfile.find_last_of(".");
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)
{
output << path << " ";
output << " " << path;
}
output << '\n';

// 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.
output << "\n" << make_outfile.c_str() << ": ";
output << make_outfile.c_str() << ":";
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.close();
}
Expand Down

0 comments on commit 6518f1e

Please sign in to comment.