Skip to content

Commit f6f5e88

Browse files
Adding check to dependencies if they exist
1 parent dccfb1b commit f6f5e88

File tree

1 file changed

+30
-5
lines changed

1 file changed

+30
-5
lines changed

Src/runcpp2/DependenciesSetupHelper.cpp

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -418,10 +418,11 @@ bool runcpp2::SetupScriptDependencies( const ProfileName& profileName,
418418
{
419419
std::error_code _;
420420

421-
for(int i = 0; i < scriptInfo.Dependencies.size(); ++i)
421+
for(int i = 0; i < outDependenciesLocalCopiesPaths.size(); ++i)
422422
{
423423
//Remove the directory
424-
if(!ghc::filesystem::remove_all(outDependenciesLocalCopiesPaths[i], _))
424+
if( ghc::filesystem::exists(outDependenciesLocalCopiesPaths[i], _) &&
425+
!ghc::filesystem::remove_all(outDependenciesLocalCopiesPaths[i], _))
425426
{
426427
ssLOG_ERROR("Failed to reset dependency directory: " <<
427428
outDependenciesLocalCopiesPaths[i]);
@@ -468,9 +469,21 @@ bool runcpp2::CopyDependenciesBinaries( const std::string& scriptPath,
468469
std::string runcpp2ScriptDir = scriptDirectory + "/.runcpp2";
469470
std::vector<std::string> platformNames = GetPlatformNames();
470471

471-
if(scriptInfo.Dependencies.size() != dependenciesCopiesPaths.size())
472+
int minimumDependenciesCopiesCount = 0;
473+
for(int i = 0; i < scriptInfo.Dependencies.size(); ++i)
474+
{
475+
if( runcpp2::IsDependencyAvailableForThisPlatform(scriptInfo.Dependencies[i]) &&
476+
scriptInfo.Dependencies[i].LibraryType != runcpp2::Data::DependencyLibraryType::HEADER)
477+
{
478+
++minimumDependenciesCopiesCount;
479+
}
480+
}
481+
482+
if(minimumDependenciesCopiesCount > dependenciesCopiesPaths.size())
472483
{
473-
ssLOG_ERROR("The amount of dependencies do not match the amount of dependencies copies paths");
484+
ssLOG_ERROR("The amount of available dependencies do not match" <<
485+
" the amount of dependencies copies paths");
486+
474487
return false;
475488
}
476489

@@ -549,6 +562,7 @@ bool runcpp2::CopyDependenciesBinaries( const std::string& scriptPath,
549562
std::string currentExtension = it.path().extension().string();
550563

551564
ssLOG_DEBUG("currentFileName: " << currentFileName);
565+
ssLOG_DEBUG("currentExtension: " << currentExtension);
552566

553567
//TODO: Make it not case sensitive?
554568
bool nameMatched = false;
@@ -599,11 +613,22 @@ bool runcpp2::CopyDependenciesBinaries( const std::string& scriptPath,
599613
return false;
600614
}
601615

616+
ssLOG_INFO("Copied " << it.path().string());
602617
outCopiedBinariesPaths.push_back(currentFileName + currentExtension);
603618
}
604619
}
605620
}
606621
}
607622

623+
//Do a check to see if any dependencies are copied
624+
if(outCopiedBinariesPaths.size() < minimumDependenciesCopiesCount)
625+
{
626+
ssLOG_WARNING("outCopiedBinariesPaths.size() does not match minimumDependenciesCopiesCount");
627+
ssLOG_WARNING("outCopiedBinariesPaths are");
628+
629+
for(int i = 0; i < outCopiedBinariesPaths.size(); ++i)
630+
ssLOG_WARNING("outCopiedBinariesPaths[" << i << "]: " << outCopiedBinariesPaths[i]);
631+
}
632+
608633
return true;
609-
}
634+
}

0 commit comments

Comments
 (0)