aboutsummaryrefslogtreecommitdiff
path: root/backend/ninja
diff options
context:
space:
mode:
Diffstat (limited to 'backend/ninja')
-rw-r--r--backend/ninja/Ninja.cpp24
1 files changed, 23 insertions, 1 deletions
diff --git a/backend/ninja/Ninja.cpp b/backend/ninja/Ninja.cpp
index 1185366..72c1e80 100644
--- a/backend/ninja/Ninja.cpp
+++ b/backend/ninja/Ninja.cpp
@@ -103,7 +103,29 @@ namespace backend
printf("%s, trying global lib\n", pkgConfigDependencyValidation.getErrMsg().c_str());
Result<string> globalLibLinkerFlagsResult = GlobalLib::getStaticLibsLinkerFlags(globalLibDir, dependency.name, dependency.version, linkerFlagCallbackFunc);
if(globalLibLinkerFlagsResult.isErr())
- return globalLibLinkerFlagsResult;
+ {
+ if(globalLibLinkerFlagsResult.getErrorCode() == GlobalLib::DependencyError::DEPENDENCY_NOT_FOUND || globalLibLinkerFlagsResult.getErrorCode() == GlobalLib::DependencyError::DEPENDENCY_VERSION_NO_MATCH)
+ {
+ printf("Dependency not found in global lib, trying to download from github\n");
+ // TODO: Download several dependencies at the same time by adding them to a list
+ // and then iterate them and download them all using several threads.
+
+ // TODO: If return error is invalid url, then the message should be converted to
+ // invalid package name/version. A check should be done if it is the name or version
+ // that is invalid.
+ Result<bool> downloadDependencyResult = GlobalLib::downloadDependency(dependency);
+ if(downloadDependencyResult.isErr())
+ return Result<string>::Err(downloadDependencyResult.getErrMsg());
+
+ globalLibLinkerFlagsResult = GlobalLib::getStaticLibsLinkerFlags(globalLibDir, dependency.name, dependency.version, linkerFlagCallbackFunc);
+ if(globalLibLinkerFlagsResult.isErr())
+ return globalLibLinkerFlagsResult;
+ }
+ else
+ {
+ return globalLibLinkerFlagsResult;
+ }
+ }
globalLibLinkerFlags += " ";
globalLibLinkerFlags += globalLibLinkerFlagsResult.unwrap();