diff options
author | dec05eba <dec05eba@protonmail.com> | 2017-12-16 18:23:00 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2017-12-16 18:23:41 +0100 |
commit | 33872fc72e40331c23a82f2b5ec3e509c7191d7a (patch) | |
tree | a6f210b7d264f82a5f2f674291c97d88f5714213 /backend/ninja | |
parent | 9487a0e924a10a1c314cb51afb5f65ced437b1d3 (diff) |
Modify ninja interface to build after creating build file
This setup is needed because we need to build the project
before building tests
Diffstat (limited to 'backend/ninja')
-rw-r--r-- | backend/ninja/Ninja.cpp | 8 | ||||
-rw-r--r-- | backend/ninja/Ninja.hpp | 4 |
2 files changed, 8 insertions, 4 deletions
diff --git a/backend/ninja/Ninja.cpp b/backend/ninja/Ninja.cpp index 2402ec1..6e9079a 100644 --- a/backend/ninja/Ninja.cpp +++ b/backend/ninja/Ninja.cpp @@ -196,7 +196,7 @@ namespace backend return Result<bool>::Ok(true); } - Result<bool> Ninja::createBuildFile(const SibsConfig &config, const char *savePath, LinkerFlagCallbackFunc staticLinkerFlagCallbackFunc, LinkerFlagCallbackFunc dynamicLinkerFlagCallback) + Result<bool> Ninja::build(const SibsConfig &config, const char *savePath, LinkerFlagCallbackFunc staticLinkerFlagCallbackFunc, LinkerFlagCallbackFunc dynamicLinkerFlagCallback) { // TODO: Do not quit here if no source files are provided. The source-less project could have dependencies if(sourceFiles.empty()) @@ -368,6 +368,10 @@ namespace backend printf("Created ninja build file: %s\n", ninjaBuildFilePath.c_str()); + Result<bool> buildResult = build(savePath); + if(!buildResult) + return buildResult; + Result<bool> buildTestResult = buildTests(projectGeneratedBinary); if(!buildTestResult) return buildTestResult; @@ -430,7 +434,7 @@ namespace backend if(!ninja.getSourceFiles().empty()) { string debugBuildPath = testSourceDir + "/sibs-build/debug"; - Result<bool> buildFileResult = ninja.createBuildFile(sibsTestConfig, debugBuildPath.c_str()); + Result<bool> buildFileResult = ninja.build(sibsTestConfig, debugBuildPath.c_str()); if (!buildFileResult) return buildFileResult; diff --git a/backend/ninja/Ninja.hpp b/backend/ninja/Ninja.hpp index 7013f78..ea73c81 100644 --- a/backend/ninja/Ninja.hpp +++ b/backend/ninja/Ninja.hpp @@ -28,14 +28,14 @@ namespace backend void addTestSourceDir(const char *dir); void addDependency(const std::string &binaryFile); const std::vector<std::string>& getSourceFiles() const; - sibs::Result<bool> createBuildFile(const sibs::SibsConfig &config, const char *savePath, sibs::LinkerFlagCallbackFunc staticLinkerFlagCallbackFunc = nullptr, sibs::LinkerFlagCallbackFunc dynamicLinkerFlagCallback = nullptr); - sibs::Result<bool> build(const char *buildFilePath); + sibs::Result<bool> build(const sibs::SibsConfig &config, const char *savePath, sibs::LinkerFlagCallbackFunc staticLinkerFlagCallbackFunc = nullptr, sibs::LinkerFlagCallbackFunc dynamicLinkerFlagCallback = nullptr); private: sibs::Result<bool> buildTests(const std::string &projectGeneratedBinary); bool containsSourceFile(const std::string &filepath) const; bool containsTestSourceDir(const std::string &dir) const; bool containsDependency(const std::string &dependency) const; sibs::Result<bool> getLinkerFlags(const std::vector<sibs::Dependency> &dependencies, sibs::LinkerFlagCallbackFunc staticLinkerFlagCallbackFunc, sibs::LinkerFlagCallbackFunc dynamicLinkerFlagCallback) const; + sibs::Result<bool> build(const char *buildFilePath); private: std::vector<std::string> sourceFiles; std::vector<std::string> testSourceDirs; |