[M2] add curated linkdb + semver matcher
This commit is contained in:
@@ -1,3 +1,56 @@
|
||||
export module cargoxx.linkdb;
|
||||
|
||||
import std;
|
||||
import cargoxx.util;
|
||||
|
||||
export namespace cargoxx::linkdb {
|
||||
|
||||
struct Recipe {
|
||||
std::string nixpkgs_attr;
|
||||
std::string find_package; // post-substitution
|
||||
std::vector<std::string> targets; // post-substitution
|
||||
std::string source; // 'curated' | 'manual' | etc.
|
||||
|
||||
bool operator==(const Recipe&) const = default;
|
||||
};
|
||||
|
||||
} // namespace cargoxx::linkdb
|
||||
|
||||
namespace cargoxx::linkdb::detail {
|
||||
|
||||
struct CuratedRecipe {
|
||||
std::string version_range;
|
||||
std::string nixpkgs_attr;
|
||||
std::string find_package;
|
||||
std::vector<std::string> targets;
|
||||
bool components_supported = false;
|
||||
};
|
||||
|
||||
} // namespace cargoxx::linkdb::detail
|
||||
|
||||
export namespace cargoxx::linkdb {
|
||||
|
||||
class Database {
|
||||
public:
|
||||
static auto open() -> util::Result<Database>;
|
||||
|
||||
auto resolve(const std::string& package, const std::string& version,
|
||||
const std::vector<std::string>& components = {})
|
||||
-> util::Result<Recipe>;
|
||||
|
||||
auto add_manual(const std::string& package, const std::string& version_range,
|
||||
const Recipe& r) -> util::Result<void>;
|
||||
|
||||
private:
|
||||
Database() = default;
|
||||
std::map<std::string, std::vector<detail::CuratedRecipe>> curated_;
|
||||
};
|
||||
|
||||
// Pure helpers exported for unit testing.
|
||||
auto substitute_components(std::string find_package, const std::vector<std::string>& components)
|
||||
-> std::string;
|
||||
|
||||
auto expand_targets(const std::vector<std::string>& templates,
|
||||
const std::vector<std::string>& components) -> std::vector<std::string>;
|
||||
|
||||
} // namespace cargoxx::linkdb
|
||||
|
||||
Reference in New Issue
Block a user