From f3b7b7d34b3bf2b1be18914577c96b66dead379a Mon Sep 17 00:00:00 2001 From: dec05eba Date: Tue, 12 Dec 2017 17:33:03 +0100 Subject: Download and extract missing dependencies from github Using libcurl and libarchive --- backend/ninja/Ninja.cpp | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'backend') 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 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 downloadDependencyResult = GlobalLib::downloadDependency(dependency); + if(downloadDependencyResult.isErr()) + return Result::Err(downloadDependencyResult.getErrMsg()); + + globalLibLinkerFlagsResult = GlobalLib::getStaticLibsLinkerFlags(globalLibDir, dependency.name, dependency.version, linkerFlagCallbackFunc); + if(globalLibLinkerFlagsResult.isErr()) + return globalLibLinkerFlagsResult; + } + else + { + return globalLibLinkerFlagsResult; + } + } globalLibLinkerFlags += " "; globalLibLinkerFlags += globalLibLinkerFlagsResult.unwrap(); -- cgit v1.2.3