36 using namespace Parser;
37 using namespace Data_Structure;
40 std::map<std::string, DependencyTree> DependenciesGenerator::cachedTrees;
48 if (cachedTrees.count(packageName))
50 return cachedTrees[packageName];
54 std::vector<std::string> dependencies =
parser.getDependencies();
55 std::vector<std::string> depsConcat = dependencies;
57 if (!dependencies.empty() && !dependencies.at(0).empty())
59 for (
auto package : dependencies)
61 std::vector<std::string> deps = getDependencieTree(package);
64 if (std::find(depsConcat.begin(), depsConcat.end(), dep) == depsConcat.end())
66 depsConcat.push_back(dep);
73 ARMARX_DEBUG <<
"The package `" << packageName <<
"` does not have any dependencies.";
76 dependencies.push_back(packageName);
77 cachedTrees[packageName] = dependencies;
81 depsConcat.push_back(packageName);
83 cachedTrees[packageName] = depsConcat;
90 if (package.get() ==
nullptr)
92 ARMARX_WARNING_S <<
"Unable to generate Dependencies cfg for unknown package";
94 std::filesystem::path cacheFolderPath = std::filesystem::path(ArmarXDataPath::GetCachePath()) /
"ComponentFiles";
96 if (!std::filesystem::exists(cacheFolderPath))
98 std::filesystem::create_directories(cacheFolderPath);
100 if (!std::filesystem::exists(cacheFolderPath))
102 ARMARX_ERROR_S <<
"Could not create Cache folder for ScenarioManagerPlugin at " << cacheFolderPath.string();
106 std::filesystem::path cacheFilePath = cacheFolderPath / std::filesystem::path(
"./" + package->getName() +
".dependencies.cfg");
108 std::ofstream out(cacheFilePath.string());
110 out <<
"ArmarX.ProjectName=" << package->getName() << std::endl;
113 std::string dataPaths =
"";
114 std::string depsString =
"";
117 for (
auto dep : deps)
123 if (pos != deps.size() - 1)
132 out <<
"ArmarX.ProjectDatapath=" << dataPaths << std::endl;
133 out <<
"ArmarX.ProjectDependencies=" << depsString << std::endl;