Fix relative paths not being included as include dependency
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# This Makefile was generated using MakeGen v1.3.0 made by Tim Håkansson
|
||||
# This Makefile was generated using MakeGen v1.3.1 made by Tim Håkansson
|
||||
# and is licensed under MIT. Full source of the project can be found at
|
||||
# https://github.com/Thraix/MakeGen
|
||||
CC=@g++
|
||||
@@ -51,7 +51,7 @@ $(OBJPATH)/Makefile.o : src/Makefile.cpp src/IncludeDeps.h src/ConfigFile.h src/
|
||||
$(OBJPATH)/Utils.o : src/Utils.cpp src/ConfigFile.h src/ConfigUtils.h src/Common.h src/FileUtils.h src/Utils.h src/xml/XMLObject.h
|
||||
$(info -[60%]- $<)
|
||||
$(CC) $(CFLAGS) -o $@ $<
|
||||
$(OBJPATH)/ConfigFileConf.o : src/compatibility/ConfigFileConf.cpp src/compatibility/ConfigFileConf.h
|
||||
$(OBJPATH)/ConfigFileConf.o : src/compatibility/ConfigFileConf.cpp src/ConfigFile.h src/ConfigUtils.h src/Common.h src/FileUtils.h src/Utils.h src/xml/XMLObject.h src/compatibility/ConfigFileConf.h
|
||||
$(info -[70%]- $<)
|
||||
$(CC) $(CFLAGS) -o $@ $<
|
||||
$(OBJPATH)/main.o : src/main.cpp src/Common.h src/ConfigCLI.h src/ConfigFile.h src/ConfigUtils.h src/FileUtils.h src/Utils.h src/xml/XMLObject.h src/HFileGen.h src/Makefile.h src/Timer.h
|
||||
@@ -60,6 +60,6 @@ $(OBJPATH)/main.o : src/main.cpp src/Common.h src/ConfigCLI.h src/ConfigFile.h s
|
||||
$(OBJPATH)/XML.o : src/xml/XML.cpp src/xml/XML.h src/xml/XMLObject.h src/xml/XMLException.h
|
||||
$(info -[90%]- $<)
|
||||
$(CC) $(CFLAGS) -o $@ $<
|
||||
$(OBJPATH)/XMLObject.o : src/xml/XMLObject.cpp src/xml/XMLException.h src/xml/XMLObject.h
|
||||
$(OBJPATH)/XMLObject.o : src/xml/XMLObject.cpp src/Common.h src/Utils.h src/xml/XMLException.h src/xml/XMLObject.h
|
||||
$(info -[100%]- $<)
|
||||
$(CC) $(CFLAGS) -o $@ $<
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@
|
||||
// Release, should be backwards compatible with any minor version
|
||||
#define MAKEGEN_VERSION_RELEASE 3
|
||||
// Minor changes, generally bug fixes
|
||||
#define MAKEGEN_VERSION_MINOR 0
|
||||
#define MAKEGEN_VERSION_MINOR 1
|
||||
|
||||
#define MAKEGEN_VERSION ("v" STR(MAKEGEN_VERSION_MAJOR) "." STR(MAKEGEN_VERSION_RELEASE) "." STR(MAKEGEN_VERSION_MINOR))
|
||||
|
||||
|
||||
@@ -37,6 +37,40 @@ struct FileUtils
|
||||
return GetTopDirectory(path);
|
||||
}
|
||||
|
||||
// Collapsed "..", ie "example/../file.h" -> "file.h"
|
||||
static std::string CollapseDirectory(const std::string& dir)
|
||||
{
|
||||
std::string ret = dir;
|
||||
size_t pos2 = dir.find_last_of("/");
|
||||
size_t pos1 = dir.find_last_of("/", pos2-1);
|
||||
size_t collapse = 0;
|
||||
size_t collapsePos = 0;
|
||||
while(pos2 != std::string::npos)
|
||||
{
|
||||
if(pos1 == std::string::npos)
|
||||
pos1 = 0;
|
||||
|
||||
if(std::string_view(dir.c_str()+pos1, pos2 - pos1 + 1) == "/../")
|
||||
{
|
||||
if(collapse == 0)
|
||||
collapsePos = pos2;
|
||||
collapse++;
|
||||
}
|
||||
else if(collapse > 0)
|
||||
{
|
||||
collapse--;
|
||||
ret = ret.substr(0, pos1) + ret.substr(pos2 + 3);
|
||||
}
|
||||
if(pos1 == 0)
|
||||
break;
|
||||
pos2 = pos1;
|
||||
pos1 = dir.find_last_of("/", pos1-1);
|
||||
}
|
||||
if(ret[0] == '/' && dir[0] != '/')
|
||||
ret = ret.substr(1);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static std::string GetTopDirectory(const std::string& dir)
|
||||
{
|
||||
if(dir.size() == 0)
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ IncludeDeps::IncludeDeps(const std::string& filename, const std::string& dir, bo
|
||||
size_t pos = line.find("#include");
|
||||
if(pos != std::string::npos)
|
||||
{
|
||||
std::string include = GetIncludeFile(line, pos, filename);
|
||||
std::string include = FileUtils::CollapseDirectory(GetIncludeFile(line, pos, filename));
|
||||
auto it = files.find({include, "", false});
|
||||
if(it != files.end())
|
||||
{
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ class IncludeDeps
|
||||
{
|
||||
if(printSet.find(filepath) != printSet.end())
|
||||
return stream;
|
||||
printCounter++;
|
||||
printCounter++;
|
||||
printSet.emplace(filepath);
|
||||
if(!projectHFile)
|
||||
stream << FileUtils::GetRelativePath(conf.GetConfigPath(), filepath);
|
||||
|
||||
Reference in New Issue
Block a user