11#include " runcpp2/DependenciesHelper.hpp"
22#include " ghc/filesystem.hpp"
33#include " runcpp2/PlatformUtil.hpp"
4+ #include " runcpp2/StringUtil.hpp"
45#include " ssLogger/ssLog.hpp"
56
67#include < unordered_set>
@@ -345,7 +346,8 @@ bool runcpp2::IsDependencyAvailableForThisPlatform(const Data::DependencyInfo& d
345346bool runcpp2::CleanupDependencies ( const runcpp2::Data::Profile& profile,
346347 const Data::ScriptInfo& scriptInfo,
347348 const std::vector<Data::DependencyInfo*>& availableDependencies,
348- const std::vector<std::string>& dependenciesLocalCopiesPaths)
349+ const std::vector<std::string>& dependenciesLocalCopiesPaths,
350+ const std::string& dependenciesToReset)
349351{
350352 ssLOG_FUNC_DEBUG ();
351353
@@ -354,8 +356,52 @@ bool runcpp2::CleanupDependencies( const runcpp2::Data::Profile& profile,
354356 return true ;
355357
356358 assert (availableDependencies.size () == dependenciesLocalCopiesPaths.size ());
359+
360+ // Split dependency names if not "all"
361+ std::unordered_set<std::string> dependencyNames;
362+ if (dependenciesToReset != " all" )
363+ {
364+ std::string currentName;
365+ for (int i = 0 ; i < dependenciesToReset.size (); ++i)
366+ {
367+ if (dependenciesToReset[i] == ' ,' || i == dependenciesToReset.size () - 1 )
368+ {
369+ if (dependenciesToReset[i] != ' ,' )
370+ currentName += dependenciesToReset[i];
371+
372+ if (!currentName.empty ())
373+ {
374+ runcpp2::Trim (currentName);
375+ // Convert to lowercase for case-insensitive comparison
376+ for (int j = 0 ; j < currentName.size (); ++j)
377+ currentName[j] = std::tolower (currentName[j]);
378+
379+ dependencyNames.insert (currentName);
380+ currentName.clear ();
381+ }
382+ }
383+ else
384+ currentName += dependenciesToReset[i];
385+ }
386+ }
387+
357388 for (int i = 0 ; i < availableDependencies.size (); ++i)
358389 {
390+ // Skip if not in the list of dependencies to reset
391+ if (!dependencyNames.empty ())
392+ {
393+ // Convert dependency name to lowercase for comparison
394+ std::string depName = availableDependencies.at (i)->Name ;
395+ for (int j = 0 ; j < depName.size (); ++j)
396+ depName[j] = std::tolower (depName[j]);
397+
398+ if (dependencyNames.count (depName) == 0 )
399+ {
400+ ssLOG_DEBUG (availableDependencies.at (i)->Name << " not in list to remove" );
401+ continue ;
402+ }
403+ }
404+
359405 std::error_code e;
360406 ssLOG_INFO (" Running cleanup commands for " << availableDependencies.at (i)->Name );
361407
@@ -377,6 +423,8 @@ bool runcpp2::CleanupDependencies( const runcpp2::Data::Profile& profile,
377423
378424 return false ;
379425 }
426+
427+ ssLOG_DEBUG (availableDependencies.at (i)->Name << " removed" );
380428 }
381429
382430 return true ;
0 commit comments