mirror of
https://github.com/microsoft/vcpkg.git
synced 2025-06-07 18:32:47 +08:00
sourceparagraph changes
This commit is contained in:
parent
f0f615532f
commit
58958eb0ea
@ -46,6 +46,12 @@ namespace vcpkg
|
||||
/// </summary>
|
||||
struct SourceParagraph
|
||||
{
|
||||
enum TYPE : unsigned
|
||||
{
|
||||
PORT = 0,
|
||||
SYS_TOOL,
|
||||
};
|
||||
|
||||
std::string name;
|
||||
std::string version;
|
||||
std::string description;
|
||||
@ -54,6 +60,10 @@ namespace vcpkg
|
||||
std::vector<std::string> supports;
|
||||
std::vector<Dependency> depends;
|
||||
std::vector<std::string> default_features;
|
||||
TYPE type;
|
||||
|
||||
static TYPE type_from_string(const std::string& in);
|
||||
static std::string string_from_type(const TYPE& in);
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
|
@ -25,6 +25,7 @@ namespace vcpkg
|
||||
static const std::string SUPPORTS = "Supports";
|
||||
static const std::string VERSION = "Version";
|
||||
static const std::string HOMEPAGE = "Homepage";
|
||||
static const std::string TYPE = "Type";
|
||||
}
|
||||
|
||||
static Span<const std::string> get_list_of_valid_fields()
|
||||
@ -36,6 +37,7 @@ namespace vcpkg
|
||||
SourceParagraphFields::MAINTAINER,
|
||||
SourceParagraphFields::BUILD_DEPENDS,
|
||||
SourceParagraphFields::HOMEPAGE,
|
||||
SourceParagraphFields::TYPE,
|
||||
};
|
||||
|
||||
return valid_fields;
|
||||
@ -98,6 +100,35 @@ namespace vcpkg
|
||||
}
|
||||
}
|
||||
|
||||
static SourceParagraph::TYPE type_from_string(const std::string& in)
|
||||
{
|
||||
if (Strings::equals(in, "port") || Strings::equals(in, ""))
|
||||
{
|
||||
return SourceParagraph::PORT;
|
||||
}
|
||||
|
||||
if (Strings::equals(in, "sys-tool"))
|
||||
{
|
||||
return SourceParagraph::SYS_TOOL;
|
||||
}
|
||||
|
||||
System::print2(
|
||||
in, " is not a valid control file type. Valid types are:",
|
||||
"\n port\n sys-tool");
|
||||
|
||||
Checks::exit_fail(VCPKG_LINE_INFO);
|
||||
}
|
||||
|
||||
static std::string string_from_type(const SourceParagraph::TYPE& in)
|
||||
{
|
||||
switch (in)
|
||||
{
|
||||
case SourceParagraph::PORT : return "port";
|
||||
case SourceParagraph::SYS_TOOL : return "sys-tool";
|
||||
default : Checks::exit_with_message(VCPKG_LINE_INFO, "Invalid CONTROL_TYPE value.");
|
||||
}
|
||||
}
|
||||
|
||||
static ParseExpected<SourceParagraph> parse_source_paragraph(RawParagraph&& fields)
|
||||
{
|
||||
ParagraphParser parser(std::move(fields));
|
||||
@ -114,6 +145,7 @@ namespace vcpkg
|
||||
parse_comma_list(parser.optional_field(SourceParagraphFields::BUILD_DEPENDS)));
|
||||
spgh->supports = parse_comma_list(parser.optional_field(SourceParagraphFields::SUPPORTS));
|
||||
spgh->default_features = parse_comma_list(parser.optional_field(SourceParagraphFields::DEFAULTFEATURES));
|
||||
spgh->type = type_from_string(parser.optional_field(SourceParagraphFields::TYPE));
|
||||
|
||||
auto err = parser.error_info(spgh->name);
|
||||
if (err)
|
||||
|
Loading…
Reference in New Issue
Block a user