From 309446ec57dc13db0aedcc0114e2a946a534cb6d Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sat, 1 Dec 2018 01:11:07 +0100 Subject: Add project cflags to test --- backend/ninja/Ninja.cpp | 8 ++++---- backend/ninja/Ninja.hpp | 5 ++++- 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'backend/ninja') 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 #include using namespace std; @@ -849,7 +848,7 @@ namespace backend dynamicLinkerFlagCallback(dynamicDependency); } - vector cflags; + vector cflags = customCflags; auto cflagsCallbackFunc = [&cflags](const string &dependencyCflags) { cflags.push_back(ninja::NinjaArg::createRaw(dependencyCflags)); @@ -1680,14 +1679,14 @@ namespace backend } } - Result buildTestResult = buildTests(allLinkerFlags, projectGeneratedBinary, config, savePath, dependencyExportIncludeDirs); + Result buildTestResult = buildTests(allLinkerFlags, projectGeneratedBinary, config, cflags, dependencyExportIncludeDirs); if(!buildTestResult) return buildTestResult; return Result::Ok(true); } - Result Ninja::buildTests(const std::string &parentLinkerFlags, const std::string &parentGeneratedLib, const SibsConfig &config, const _tinydir_char_t *savePath, const string &parentDependencyExportIncludeDirs) + Result Ninja::buildTests(const std::string &parentLinkerFlags, const std::string &parentGeneratedLib, const SibsConfig &config, const vector &parentCflags, const string &parentDependencyExportIncludeDirs) { if(testSourceDir.empty() || !config.shouldBuildTests()) return Result::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 #include #include +#include namespace backend { @@ -49,9 +50,11 @@ namespace backend void addSubProject(Ninja *subProject, sibs::SibsConfig *config, sibs::FileString &&buildPath); const std::vector& getSourceFiles() const; sibs::Result build(const sibs::SibsConfig &config, const _tinydir_char_t *savePath, sibs::LinkerFlagCallbackFunc staticLinkerFlagCallbackFunc = nullptr, sibs::LinkerFlagCallbackFunc dynamicLinkerFlagCallback = nullptr, sibs::GlobalIncludeDirCallbackFunc globalIncludeDirCallback = nullptr); + + std::vector customCflags; private: sibs::Result buildSubProjects(sibs::LinkerFlagCallbackFunc staticLinkerFlagCallbackFunc, sibs::LinkerFlagCallbackFunc dynamicLinkerFlagCallback, sibs::GlobalIncludeDirCallbackFunc globalIncludeDirCallback); - sibs::Result buildTests(const std::string &parentLinkerFlags, const std::string &parentGeneratedLib, const sibs::SibsConfig &config, const _tinydir_char_t *savePath, const std::string &parentDependencyExportIncludeDirs); + sibs::Result buildTests(const std::string &parentLinkerFlags, const std::string &parentGeneratedLib, const sibs::SibsConfig &config, const std::vector &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; -- cgit v1.2.3