-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathdep_spec.cppm
More file actions
56 lines (46 loc) · 2.6 KB
/
dep_spec.cppm
File metadata and controls
56 lines (46 loc) · 2.6 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
56
// mcpp.pm.dep_spec — package-management subsystem: dependency data model.
//
// Owns `DependencySpec` and the default-namespace constant. Pure value
// types — no IO, no parsing here. Parsing currently lives in
// `mcpp.manifest`; a follow-up PR-R5 will move the `[dependencies]` /
// `[dev-dependencies]` parsing here, alongside the namespaced subtable
// + flat + legacy-dotted forms already established in PR-A.
//
// See `.agents/docs/2026-05-08-pm-subsystem-architecture.md` for the
// full pm/ subsystem layout.
export module mcpp.pm.dep_spec;
import std;
export namespace mcpp::pm {
struct DependencyCoordinate {
std::string namespace_;
std::string shortName;
auto operator<=>(const DependencyCoordinate&) const = default;
};
// One declared dependency. Path-based deps refer to a sibling mcpp package
// on disk; version-based deps come from a registry; git-based deps clone
// a remote at a fixed ref.
struct DependencySpec {
// xpkg-style namespace. Defaults to `kDefaultNamespace` ("mcpp") for
// the root index. Carried alongside the existing fully-qualified name
// (which the dependencies map keys on) so callers that want the
// structured form — registry lookup, lockfile entries, error
// messages — can pull it out without re-splitting strings.
std::string namespace_; // "mcpp" / "mcpplibs" / ...
std::string shortName; // package name without namespace prefix
std::string version; // "0.0.1" / "^1.2" / "" (req string)
std::string path; // filesystem path, or empty
std::string git; // "https://..." or empty
std::string gitRev; // commit / tag / branch (any one)
std::string gitRefKind; // "rev" / "tag" / "branch" (for clarity)
std::string visibility = "public"; // public / private / interface
std::vector<DependencyCoordinate> candidates; // ordered lookup candidates
bool inheritWorkspace = false; // .workspace = true
bool legacyDottedKey = false; // parsed from legacy "ns.name" flat key
bool isPath() const { return !path.empty(); }
bool isGit() const { return !git.empty(); }
bool isVersion() const { return !isPath() && !isGit() && !version.empty(); }
};
// Default namespace for packages declared without an explicit one — the
// mcpplibs "root". Bare `gtest = "1.15.2"` becomes `(mcpp, gtest)`.
inline constexpr std::string_view kDefaultNamespace = "mcpplibs";
} // namespace mcpp::pm