-
Notifications
You must be signed in to change notification settings - Fork 252
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"<unknown>" and "<command>" are not origins #1346
Changes from all commits
58eb07e
bc2ac20
bd20e7a
062c7f8
a20bd57
f3c87e8
084839b
a5d8d05
3135acd
1125064
097cf87
4ecdba4
bdeba4d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,8 @@ | |
#include <vcpkg/fwd/triplet.h> | ||
#include <vcpkg/fwd/vcpkgpaths.h> | ||
|
||
#include <vcpkg/base/expected.h> | ||
|
||
namespace vcpkg | ||
{ | ||
// Parse a package spec without features; typically used by commands which | ||
|
@@ -15,24 +17,20 @@ namespace vcpkg | |
// Does not assert that the package spec has a valid triplet. This allows | ||
// such commands to refer to entities that were installed with an overlay | ||
// triplet or similar which is no longer active. | ||
PackageSpec parse_package_spec(StringView spec_string, | ||
Triplet default_triplet, | ||
const LocalizedString& example_text); | ||
[[nodiscard]] ExpectedL<PackageSpec> parse_package_spec(StringView spec_string, Triplet default_triplet); | ||
|
||
// Same as the above but checks the validity of the triplet. | ||
PackageSpec check_and_get_package_spec(StringView spec_string, | ||
Triplet default_triplet, | ||
const LocalizedString& example_text, | ||
const TripletDatabase& database); | ||
[[nodiscard]] ExpectedL<PackageSpec> check_and_get_package_spec(StringView spec_string, | ||
Triplet default_triplet, | ||
const TripletDatabase& database); | ||
|
||
// Parse a package spec with features, typically used by commands which will | ||
// install or modify a port. | ||
// | ||
// Asserts that the package spec has a valid triplet. | ||
FullPackageSpec check_and_get_full_package_spec(StringView spec_string, | ||
Triplet default_triplet, | ||
const LocalizedString& example_text, | ||
const TripletDatabase& database); | ||
[[nodiscard]] ExpectedL<FullPackageSpec> check_and_get_full_package_spec(StringView spec_string, | ||
Triplet default_triplet, | ||
const TripletDatabase& database); | ||
|
||
void check_triplet(StringView name, const TripletDatabase& database); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since this function is changing from a side effect to a return value, I think it should at least gain a |
||
[[nodiscard]] ExpectedL<Unit> check_triplet(StringView name, const TripletDatabase& database); | ||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -142,17 +142,24 @@ namespace vcpkg | |||||||||||||||||||
Optional<PlatformExpression::Expr> platform; | ||||||||||||||||||||
|
||||||||||||||||||||
/// @param id add "default" if "core" is not present | ||||||||||||||||||||
/// @return nullopt on success. On failure, caller should supplement returned string with more context. | ||||||||||||||||||||
ExpectedL<FullPackageSpec> to_full_spec(Triplet default_triplet, ImplicitDefault id) const; | ||||||||||||||||||||
// Assumes AllowPlatformSpec::No | ||||||||||||||||||||
FullPackageSpec to_full_spec(Triplet default_triplet, ImplicitDefault id) const; | ||||||||||||||||||||
|
||||||||||||||||||||
ExpectedL<PackageSpec> to_package_spec(Triplet default_triplet) const; | ||||||||||||||||||||
// Assumes AllowFeatures::No, AllowPlatformSpec::No | ||||||||||||||||||||
PackageSpec to_package_spec(Triplet default_triplet) const; | ||||||||||||||||||||
}; | ||||||||||||||||||||
|
||||||||||||||||||||
Optional<std::string> parse_feature_name(ParserBase& parser); | ||||||||||||||||||||
Optional<std::string> parse_package_name(ParserBase& parser); | ||||||||||||||||||||
ExpectedL<ParsedQualifiedSpecifier> parse_qualified_specifier(StringView input); | ||||||||||||||||||||
Optional<ParsedQualifiedSpecifier> parse_qualified_specifier(ParserBase& parser); | ||||||||||||||||||||
} | ||||||||||||||||||||
ExpectedL<ParsedQualifiedSpecifier> parse_qualified_specifier(StringView input, | ||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because all of the "finalizer" functions on It seems like it would be better to just remove them and supply type-safe free functions: ExpectedL<FullPackageSpec> parse_full_spec(StringView input, AllowFeatures allow_features, ParseExplicitTriplet parse_explicit_triplet, ImplicitDefault id, Triplet default_triplet);
ExpectedL<PackageSpec> parse_full_spec(StringView input, ParseExplicitTriplet parse_explicit_triplet, Triplet default_triplet); (This could be done in a follow-up PR) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree and tried to do this, but there are 2 problems:
vcpkg-tool/src/vcpkg/binaryparagraph.cpp Lines 46 to 54 in 56b4a5b
|
||||||||||||||||||||
AllowFeatures allow_features, | ||||||||||||||||||||
ParseExplicitTriplet parse_explicit_triplet, | ||||||||||||||||||||
AllowPlatformSpec allow_platform_spec); | ||||||||||||||||||||
Optional<ParsedQualifiedSpecifier> parse_qualified_specifier(ParserBase& parser, | ||||||||||||||||||||
AllowFeatures allow_features, | ||||||||||||||||||||
ParseExplicitTriplet parse_explicit_triplet, | ||||||||||||||||||||
AllowPlatformSpec allow_platform_spec); | ||||||||||||||||||||
} // namespace vcpkg | ||||||||||||||||||||
|
||||||||||||||||||||
template<> | ||||||||||||||||||||
struct std::hash<vcpkg::PackageSpec> | ||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is
origin
forParserBase
anOptional<StringView>
but forJsonReader
aStringView
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ParserBase is reasonably used for things that don't have origins, like content from environment variables or command lines. At least at present, JSON only comes from honest to goodness files which always have origins, so making the parameter nullable is unnecessary.