Fix relative paths being put in the wrong intermediate directory

This commit is contained in:
Thraix
2026-01-20 23:24:27 +01:00
parent 1edcfb570b
commit b112ab4501
6 changed files with 27 additions and 6 deletions
+9 -3
View File
@@ -54,7 +54,9 @@ void Makefile::Save(ConfigFile& conf, unsigned int flags)
{
std::filesystem::path cppFile(*it);
std::filesystem::path oFile = cppFile.replace_extension("o");
outputFile << "$(OBJPATH)/" << oFile.string() << " ";
std::string oFileStr = oFile.string();
Utils::Replace(oFileStr, "..", "dotdot");
outputFile << "$(OBJPATH)/" << oFileStr << " ";
}
outputFile << std::endl;
if (outputtype == "executable" || outputtype != "sharedlibrary")
@@ -182,7 +184,9 @@ void Makefile::Save(ConfigFile& conf, unsigned int flags)
{
std::filesystem::path cppFile(*it);
std::filesystem::path oFile = cppFile.replace_extension("o");
outputFile << "$(OBJPATH)/" << oFile.string() << ":";
std::string oFileStr = oFile.string();
Utils::Replace(oFileStr, "..", "dotdot");
outputFile << "$(OBJPATH)/" << oFileStr << ":";
if (flags & FLAG_SIMPLE)
{
outputFile << " " << *it;
@@ -206,7 +210,9 @@ std::set<std::string> Makefile::GetIntermediateDirectories(const std::set<std::s
{
std::filesystem::path cppPath{cppFile};
std::filesystem::path oFile = cppPath.replace_extension("o");
intermediateDirectories.emplace("$(OBJPATH)/" + oFile.parent_path().string());
std::string parentPathStr = oFile.parent_path().string();
Utils::Replace(parentPathStr, "..", "dotdot");
intermediateDirectories.emplace("$(OBJPATH)/" + parentPathStr);
}
return intermediateDirectories;
}