sourceparagraph changes

This commit is contained in:
Curtis.Bezault 2019-07-17 14:27:18 -07:00
parent f0f615532f
commit 58958eb0ea
2 changed files with 42 additions and 0 deletions

View File

@ -46,6 +46,12 @@ namespace vcpkg
/// </summary> /// </summary>
struct SourceParagraph struct SourceParagraph
{ {
enum TYPE : unsigned
{
PORT = 0,
SYS_TOOL,
};
std::string name; std::string name;
std::string version; std::string version;
std::string description; std::string description;
@ -54,6 +60,10 @@ namespace vcpkg
std::vector<std::string> supports; std::vector<std::string> supports;
std::vector<Dependency> depends; std::vector<Dependency> depends;
std::vector<std::string> default_features; 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> /// <summary>

View File

@ -25,6 +25,7 @@ namespace vcpkg
static const std::string SUPPORTS = "Supports"; static const std::string SUPPORTS = "Supports";
static const std::string VERSION = "Version"; static const std::string VERSION = "Version";
static const std::string HOMEPAGE = "Homepage"; static const std::string HOMEPAGE = "Homepage";
static const std::string TYPE = "Type";
} }
static Span<const std::string> get_list_of_valid_fields() static Span<const std::string> get_list_of_valid_fields()
@ -36,6 +37,7 @@ namespace vcpkg
SourceParagraphFields::MAINTAINER, SourceParagraphFields::MAINTAINER,
SourceParagraphFields::BUILD_DEPENDS, SourceParagraphFields::BUILD_DEPENDS,
SourceParagraphFields::HOMEPAGE, SourceParagraphFields::HOMEPAGE,
SourceParagraphFields::TYPE,
}; };
return valid_fields; 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) static ParseExpected<SourceParagraph> parse_source_paragraph(RawParagraph&& fields)
{ {
ParagraphParser parser(std::move(fields)); ParagraphParser parser(std::move(fields));
@ -114,6 +145,7 @@ namespace vcpkg
parse_comma_list(parser.optional_field(SourceParagraphFields::BUILD_DEPENDS))); parse_comma_list(parser.optional_field(SourceParagraphFields::BUILD_DEPENDS)));
spgh->supports = parse_comma_list(parser.optional_field(SourceParagraphFields::SUPPORTS)); spgh->supports = parse_comma_list(parser.optional_field(SourceParagraphFields::SUPPORTS));
spgh->default_features = parse_comma_list(parser.optional_field(SourceParagraphFields::DEFAULTFEATURES)); 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); auto err = parser.error_info(spgh->name);
if (err) if (err)