|
1 | | -// mcpp.pm.compat — backward-compatibility shims for evolving package |
2 | | -// conventions. Centralises all migration logic so it can be retired |
3 | | -// cleanly in a future major version. |
| 1 | +// mcpp.pm.compat - compatibility facade for evolving package conventions. |
| 2 | +// Legacy-only behavior lives under src/pm/compat/legacy.cppm so it has an |
| 3 | +// explicit retirement boundary. |
4 | 4 | // |
5 | 5 | // DEPRECATION SCHEDULE: |
6 | 6 | // The shims in this module are slated for removal in mcpp 1.0.0. |
|
20 | 20 |
|
21 | 21 | export module mcpp.pm.compat; |
22 | 22 |
|
| 23 | +export import mcpp.pm.compat.legacy; |
| 24 | + |
23 | 25 | import std; |
24 | 26 | import mcpp.pm.dep_spec; |
25 | 27 |
|
@@ -82,69 +84,6 @@ inline std::string qualified_name(std::string_view ns, |
82 | 84 | return std::format("{}.{}", ns, shortName); |
83 | 85 | } |
84 | 86 |
|
85 | | -// ─── Legacy dependency key parsing ───────────────────────────────── |
86 | | -// |
87 | | -// COMPAT: legacy flat dependency keys used quoted dotted names under a |
88 | | -// dependency table: |
89 | | -// |
90 | | -// [dependencies] |
91 | | -// "mcpplibs.cmdline" = "0.0.2" |
92 | | -// |
93 | | -// Canonical projects should use namespaced TOML tables instead: |
94 | | -// |
95 | | -// [dependencies.mcpplibs] |
96 | | -// cmdline = "0.0.2" |
97 | | -// |
98 | | -// Nested default-namespace packages can also be written without quotes: |
99 | | -// |
100 | | -// [dependencies] |
101 | | -// capi.lua = "0.0.3" |
102 | | -// |
103 | | -// This compatibility parser is slated for removal in mcpp 1.0.0. |
104 | | - |
105 | | -struct LegacyDependencyKey { |
106 | | - std::string namespace_; |
107 | | - std::string shortName; |
108 | | - bool legacyDottedKey = false; |
109 | | -}; |
110 | | - |
111 | | -inline LegacyDependencyKey split_legacy_dependency_key(std::string_view key) |
112 | | -{ |
113 | | - auto dot = key.find('.'); |
114 | | - if (dot == std::string_view::npos) { |
115 | | - return LegacyDependencyKey { |
116 | | - .namespace_ = std::string(mcpp::pm::kDefaultNamespace), |
117 | | - .shortName = std::string(key), |
118 | | - .legacyDottedKey = false, |
119 | | - }; |
120 | | - } |
121 | | - |
122 | | - return LegacyDependencyKey { |
123 | | - .namespace_ = std::string(key.substr(0, dot)), |
124 | | - .shortName = std::string(key.substr(dot + 1)), |
125 | | - .legacyDottedKey = true, |
126 | | - }; |
127 | | -} |
128 | | - |
129 | | -// Normalize legacy nested names after the first-dot split: |
130 | | -// ns="mcpplibs", shortName="capi.lua" → ns="mcpplibs.capi", shortName="lua". |
131 | | -// |
132 | | -// This preserves the fully qualified name while making dependency de-dup use |
133 | | -// the same structured key as canonical [dependencies.mcpplibs] capi.lua. |
134 | | -inline void normalize_nested_namespace(std::string& ns, |
135 | | - std::string& shortName, |
136 | | - bool legacyDottedKey) |
137 | | -{ |
138 | | - if (!legacyDottedKey) return; |
139 | | - if (ns.empty()) return; |
140 | | - auto dot = shortName.rfind('.'); |
141 | | - if (dot == std::string::npos || dot + 1 >= shortName.size()) return; |
142 | | - |
143 | | - ns += "."; |
144 | | - ns += shortName.substr(0, dot); |
145 | | - shortName = shortName.substr(dot + 1); |
146 | | -} |
147 | | - |
148 | 87 | // ─── Index directory naming ────────────────────────────────────────── |
149 | 88 | // |
150 | 89 | // Maps (indexName, namespace, shortName) → the xpkgs subdirectory name |
|
0 commit comments