diff options
author | Diegoisawesome <diego@domoreaweso.me> | 2019-09-04 13:18:49 -0700 |
---|---|---|
committer | Diegoisawesome <diego@domoreaweso.me> | 2019-09-04 13:18:49 -0700 |
commit | a7ef6c4cbf5ef481281917685a633ccd842335d5 (patch) | |
tree | 44674b0580f41426eb5112e31cdc0245237d1666 /tools/ramscrgen/main.cpp | |
parent | 1ec2c86089fd933a46ef405da63c131aee52d7e0 (diff) |
Diffstat (limited to 'tools/ramscrgen/main.cpp')
-rw-r--r-- | tools/ramscrgen/main.cpp | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/tools/ramscrgen/main.cpp b/tools/ramscrgen/main.cpp index 6c4f4bb..5e5894f 100644 --- a/tools/ramscrgen/main.cpp +++ b/tools/ramscrgen/main.cpp @@ -27,9 +27,15 @@ void HandleCommonInclude(std::string filename, std::string sourcePath, std::string symOrderPath, std::string lang) { - auto commonSymbols = GetCommonSymbols(sourcePath + "/" + filename); + auto commonSymbols = GetCommonSymbols(sourcePath, filename); + std::size_t dotIndex; - std::size_t dotIndex = filename.find_last_of('.'); + if (filename[0] == '*') { + dotIndex = filename.find_last_of(':'); + filename = filename.substr(dotIndex + 1); + } + + dotIndex = filename.find_last_of('.'); if (dotIndex == std::string::npos) FATAL_ERROR("error: \"%s\" doesn't have a file extension\n", filename.c_str()); @@ -73,7 +79,7 @@ void HandleCommonInclude(std::string filename, std::string sourcePath, std::stri } } -void ConvertSymFile(std::string filename, std::string sectionName, std::string lang, bool common, std::string sourcePath, std::string commonSymPath) +void ConvertSymFile(std::string filename, std::string sectionName, std::string lang, bool common, std::string sourcePath, std::string commonSymPath, std::string libSourcePath) { SymFile symFile(filename); @@ -91,7 +97,7 @@ void ConvertSymFile(std::string filename, std::string sectionName, std::string l symFile.ExpectEmptyRestOfLine(); printf(". = ALIGN(4);\n"); if (common) - HandleCommonInclude(incFilename, sourcePath, commonSymPath, lang); + HandleCommonInclude(incFilename, incFilename[0] == '*' ? libSourcePath : sourcePath, commonSymPath, lang); else printf("%s(%s);\n", incFilename.c_str(), sectionName.c_str()); break; @@ -148,6 +154,7 @@ int main(int argc, char **argv) std::string lang = std::string(argv[3]); std::string sourcePath; std::string commonSymPath; + std::string libSourcePath; if (argc > 4) { @@ -166,8 +173,15 @@ int main(int argc, char **argv) sourcePath = paths.substr(0, commaPos); commonSymPath = paths.substr(commaPos + 1); + commaPos = commonSymPath.find(','); + if (commaPos == std::string::npos) { + libSourcePath = "tools/agbcc/lib"; + } else { + libSourcePath = commonSymPath.substr(commaPos + 1); + commonSymPath = commonSymPath.substr(0, commaPos); + } } - ConvertSymFile(symFileName, sectionName, lang, common, sourcePath, commonSymPath); + ConvertSymFile(symFileName, sectionName, lang, common, sourcePath, commonSymPath, libSourcePath); return 0; } |