diff options
author | dec05eba <dec05eba@protonmail.com> | 2017-12-12 17:33:03 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2017-12-12 17:34:16 +0100 |
commit | f3b7b7d34b3bf2b1be18914577c96b66dead379a (patch) | |
tree | f24a08256bc959929d51045eb49283fcab7e8b54 /backend | |
parent | cfe578ec12198d09a9a89a2e0b40bccaa06aa8ae (diff) |
Download and extract missing dependencies from github
Using libcurl and libarchive
Diffstat (limited to 'backend')
-rw-r--r-- | backend/ninja/Ninja.cpp | 24 |
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(); |