diff options
author | dec05eba <dec05eba@protonmail.com> | 2018-12-01 01:11:07 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-07-06 07:39:33 +0200 |
commit | 309446ec57dc13db0aedcc0114e2a946a534cb6d (patch) | |
tree | c34fa77ab22d31b113139917347049496ac97162 | |
parent | 8d0a57ac40e1be62f700df32ec402f9f09eb6946 (diff) |
Add project cflags to test
-rw-r--r-- | backend/ninja/Ninja.cpp | 8 | ||||
-rw-r--r-- | backend/ninja/Ninja.hpp | 5 |
2 files changed, 8 insertions, 5 deletions
diff --git a/backend/ninja/Ninja.cpp b/backend/ninja/Ninja.cpp index bf5ddf3..60c1060 100644 --- a/backend/ninja/Ninja.cpp +++ b/backend/ninja/Ninja.cpp @@ -5,7 +5,6 @@ #include "../../include/Exec.hpp" #include "../../include/PkgConfig.hpp" #include "../../include/GlobalLib.hpp" -#include <ninja/Ninja.hpp> #include <algorithm> using namespace std; @@ -849,7 +848,7 @@ namespace backend dynamicLinkerFlagCallback(dynamicDependency); } - vector<ninja::NinjaArg> cflags; + vector<ninja::NinjaArg> cflags = customCflags; auto cflagsCallbackFunc = [&cflags](const string &dependencyCflags) { cflags.push_back(ninja::NinjaArg::createRaw(dependencyCflags)); @@ -1680,14 +1679,14 @@ namespace backend } } - Result<bool> buildTestResult = buildTests(allLinkerFlags, projectGeneratedBinary, config, savePath, dependencyExportIncludeDirs); + Result<bool> buildTestResult = buildTests(allLinkerFlags, projectGeneratedBinary, config, cflags, dependencyExportIncludeDirs); if(!buildTestResult) return buildTestResult; return Result<bool>::Ok(true); } - Result<bool> Ninja::buildTests(const std::string &parentLinkerFlags, const std::string &parentGeneratedLib, const SibsConfig &config, const _tinydir_char_t *savePath, const string &parentDependencyExportIncludeDirs) + Result<bool> Ninja::buildTests(const std::string &parentLinkerFlags, const std::string &parentGeneratedLib, const SibsConfig &config, const vector<ninja::NinjaArg> &parentCflags, const string &parentDependencyExportIncludeDirs) { if(testSourceDir.empty() || !config.shouldBuildTests()) return Result<bool>::Ok(true); @@ -1730,6 +1729,7 @@ namespace backend backend::Ninja ninja; ninja.addGlobalIncludeDirs(parentExportIncludeDirs); + ninja.customCflags = std::move(parentCflags); if(!parentLinkerFlags.empty()) ninja.addDependency(parentLinkerFlags); diff --git a/backend/ninja/Ninja.hpp b/backend/ninja/Ninja.hpp index 2928fb3..96396d6 100644 --- a/backend/ninja/Ninja.hpp +++ b/backend/ninja/Ninja.hpp @@ -8,6 +8,7 @@ #include <vector> #include <string> #include <functional> +#include <ninja/Ninja.hpp> namespace backend { @@ -49,9 +50,11 @@ namespace backend void addSubProject(Ninja *subProject, sibs::SibsConfig *config, sibs::FileString &&buildPath); const std::vector<sibs::SourceFile>& getSourceFiles() const; sibs::Result<bool> build(const sibs::SibsConfig &config, const _tinydir_char_t *savePath, sibs::LinkerFlagCallbackFunc staticLinkerFlagCallbackFunc = nullptr, sibs::LinkerFlagCallbackFunc dynamicLinkerFlagCallback = nullptr, sibs::GlobalIncludeDirCallbackFunc globalIncludeDirCallback = nullptr); + + std::vector<ninja::NinjaArg> customCflags; private: sibs::Result<bool> buildSubProjects(sibs::LinkerFlagCallbackFunc staticLinkerFlagCallbackFunc, sibs::LinkerFlagCallbackFunc dynamicLinkerFlagCallback, sibs::GlobalIncludeDirCallbackFunc globalIncludeDirCallback); - sibs::Result<bool> buildTests(const std::string &parentLinkerFlags, const std::string &parentGeneratedLib, const sibs::SibsConfig &config, const _tinydir_char_t *savePath, const std::string &parentDependencyExportIncludeDirs); + sibs::Result<bool> buildTests(const std::string &parentLinkerFlags, const std::string &parentGeneratedLib, const sibs::SibsConfig &config, const std::vector<ninja::NinjaArg> &parentCflags, const std::string &parentDependencyExportIncludeDirs); bool containsSourceFile(const std::string &filepath) const; bool containsDependency(const std::string &dependency) const; bool containsDynamicDependency(const std::string &dependency) const; |