aboutsummaryrefslogtreecommitdiff
path: root/backend/ninja
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2017-12-12 19:46:57 +0100
committerdec05eba <dec05eba@protonmail.com>2017-12-12 19:49:29 +0100
commitf2c70dfaba8d6481e86646080c51b6874d95f14e (patch)
tree1ee19bdd5f951b86f2b481c94f969a473a5e57fc /backend/ninja
parentf3b7b7d34b3bf2b1be18914577c96b66dead379a (diff)
Lazily create directories that are needed
Directories such as: ~/.sibs ~/.sibs/archive ~/.sibs/lib And directories for each specific library. Also fix bug in getFileContent and fileOverwrite if file already exists
Diffstat (limited to 'backend/ninja')
-rw-r--r--backend/ninja/Ninja.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/backend/ninja/Ninja.cpp b/backend/ninja/Ninja.cpp
index 72c1e80..7fb07bf 100644
--- a/backend/ninja/Ninja.cpp
+++ b/backend/ninja/Ninja.cpp
@@ -85,9 +85,11 @@ namespace backend
{
if(dependencies.empty()) return Result<string>::Ok("");
- // TODO: Global library dir should be created during sibs installation
string globalLibDir = getHomeDir();
globalLibDir += "/.sibs/lib";
+ Result<bool> createGlobalLibDirResult = createDirectoryRecursive(globalLibDir.c_str());
+ if(createGlobalLibDirResult.isErr())
+ return Result<string>::Err(createGlobalLibDirResult);
string globalLibLinkerFlags;
vector<string> pkgConfigDependencies;
@@ -149,6 +151,10 @@ namespace backend
if(sourceFiles.empty())
return Result<bool>::Err("No source files provided");
+ Result<bool> createBuildDirResult = createDirectoryRecursive(savePath);
+ if(createBuildDirResult.isErr())
+ return createBuildDirResult;
+
string ninjaBuildFilePath = savePath;
ninjaBuildFilePath += "/build.ninja";
@@ -253,13 +259,9 @@ namespace backend
return Result<bool>::Err("NOT IMPLEMENTED YET!");
}
- bool fileOverwritten = sibs::fileOverwrite(ninjaBuildFilePath.c_str(), sibs::StringView(result.data(), result.size()));
- if(!fileOverwritten)
- {
- string errMsg = "Failed to overwrite ninja build file: ";
- errMsg += ninjaBuildFilePath;
- return Result<bool>::Err(errMsg);
- }
+ Result<bool> fileOverwriteResult = sibs::fileOverwrite(ninjaBuildFilePath.c_str(), sibs::StringView(result.data(), result.size()));
+ if(fileOverwriteResult.isErr())
+ return fileOverwriteResult;
printf("Created ninja build file: %s\n", ninjaBuildFilePath.c_str());
return Result<bool>::Ok(true);