-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathModuleGraph.hpp
More file actions
55 lines (48 loc) · 1.77 KB
/
Copy pathModuleGraph.hpp
File metadata and controls
55 lines (48 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#ifndef VIX_CLI_MODULES_MODULE_GRAPH_HPP
#define VIX_CLI_MODULES_MODULE_GRAPH_HPP
#include <filesystem>
#include <string>
#include <vector>
#include <vix/cli/app/AppManifest.hpp>
namespace vix::cli::modules
{
struct ModuleNode
{
std::string name;
std::string identity;
std::filesystem::path path;
std::string kind;
bool enabled{true};
std::vector<std::string> dependencies;
};
class ModuleGraph
{
public:
static std::string canonical_identity(const std::string &name);
static std::string case_folded_identity(const std::string &name);
static ModuleGraph from_app_modules(
const std::vector<vix::cli::app::AppModule> &modules,
std::string &error);
bool valid() const { return error_.empty(); }
const std::string &error() const { return error_; }
bool contains(const std::string &name) const;
const ModuleNode *find(const std::string &name) const;
const std::vector<ModuleNode> &nodes() const { return nodes_; }
// Validates paths against a project root without modifying project files.
bool validate_paths(const std::filesystem::path &projectRoot,
bool requireDirectories,
std::string &error) const;
bool topological_order(std::vector<std::string> &order,
bool activeOnly = false,
std::string *error = nullptr) const;
bool dependency_closure(const std::string &name,
std::vector<std::string> &closure,
std::string *error = nullptr) const;
bool active_closure(std::vector<std::string> &closure,
std::string *error = nullptr) const;
private:
std::vector<ModuleNode> nodes_;
std::string error_;
};
}
#endif