summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2021-06-19 14:33:34 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2021-06-19 14:33:34 +0200
commit1585cf0bab4fc20dd999b40da3a91d298dcbcdb8 (patch)
tree9e2e38ae89e061b374e182628f2b7fc671bac8c0
parent154ce9b1ce22532a68f95f2291fa12fd90c49fde (diff)
Make include paths work relative to the build config files.
-rw-r--r--subdir/cppbuild.cc14
-rw-r--r--task_cc.cc23
-rw-r--r--task_cc.h1
3 files changed, 29 insertions, 9 deletions
diff --git a/subdir/cppbuild.cc b/subdir/cppbuild.cc
index 808ac41..083ccc0 100644
--- a/subdir/cppbuild.cc
+++ b/subdir/cppbuild.cc
@@ -107,13 +107,13 @@ std::vector<BuildConfiguration> myConfigs()
"-Wall",
"-Werror",
"-std=c++11",
- "-Idrumgizmo/getoptpp",
- "-Idrumgizmo/",
- "-Idrumgizmo/hugin",
- "-Idrumgizmo/plugingui/",
- "-Idrumgizmo/src/",
- "-Idrumgizmo/zita-resampler/libs",
- "-Idrumgizmo/pugixml/src",
+ "-I../drumgizmo/getoptpp",
+ "-I../drumgizmo/",
+ "-I../drumgizmo/hugin",
+ "-I../drumgizmo/plugingui/",
+ "-I ../drumgizmo/src/",
+ "-I ../drumgizmo/zita-resampler/libs",
+ "-I ../drumgizmo/pugixml/src",
},
.cflags = {},
.ldflags = {}
diff --git a/task_cc.cc b/task_cc.cc
index f827c25..b5cc768 100644
--- a/task_cc.cc
+++ b/task_cc.cc
@@ -88,6 +88,7 @@ TaskCC::TaskCC(const BuildConfiguration& config, const Settings& settings,
: Task({})
, config(config)
, settings(settings)
+ , sourceDir(sourceDir)
{
sourceFile = sourceDir;
sourceFile /= source;
@@ -193,6 +194,23 @@ int TaskCC::runInner()
for(const auto& flag : compiler_flags)
{
+ // Is arg an added include path?
+ if(flag.substr(0, 2) == "-I")
+ {
+ std::string include_path = flag.substr(2);
+ include_path.erase(0, include_path.find_first_not_of(' '));
+ std::filesystem::path path(include_path);
+
+ // Is it relative?
+ if(path.is_relative())
+ {
+ path = (sourceDir / path).lexically_normal();
+ std::string new_include_path = "-I" + path.string();
+ args.push_back(new_include_path);
+ continue;
+ }
+ }
+
args.push_back(flag);
}
@@ -203,8 +221,9 @@ int TaskCC::runInner()
if(settings.verbose == 0)
{
- std::cout << compiler() << " " << sourceFile.string() << " => " <<
- targetFile.string() << "\n";
+ std::cout << compiler() << " " <<
+ sourceFile.lexically_normal().string() << " => " <<
+ targetFile.lexically_normal().string() << "\n";
}
return execute(comp, args, settings.verbose > 0);
}
diff --git a/task_cc.h b/task_cc.h
index f88433f..538188f 100644
--- a/task_cc.h
+++ b/task_cc.h
@@ -40,4 +40,5 @@ private:
const BuildConfiguration& config;
const Settings& settings;
+ std::filesystem::path sourceDir;
};