aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/src/SourceParagraph.cpp
diff options
context:
space:
mode:
authorRobert Schumacher <roschuma@microsoft.com>2016-11-05 01:02:15 -0700
committerRobert Schumacher <roschuma@microsoft.com>2016-11-05 01:02:15 -0700
commit7f336c746776daf2af95914ed25ff3d50a96b387 (patch)
tree2251824d5db437212c34dd80229e8241964dd774 /toolsrc/src/SourceParagraph.cpp
parente5152851f2bb070eb4bcc2b8968d40d48226b04e (diff)
downloadvcpkg-7f336c746776daf2af95914ed25ff3d50a96b387.tar.gz
vcpkg-7f336c746776daf2af95914ed25ff3d50a96b387.zip
Enable qualified dependencies. Fix bug in internal 'build' command.
Added capability for CONTROL files to specify qualified dependencies, which are substring searched inside triplet names. Fixed bug in internal 'build' command where if a package is already built, that built package's dependencies will be used to determine requirements for the build instead of the port directory's CONTROL file.
Diffstat (limited to 'toolsrc/src/SourceParagraph.cpp')
-rw-r--r--toolsrc/src/SourceParagraph.cpp83
1 files changed, 82 insertions, 1 deletions
diff --git a/toolsrc/src/SourceParagraph.cpp b/toolsrc/src/SourceParagraph.cpp
index 6f25dbded..bdf15a737 100644
--- a/toolsrc/src/SourceParagraph.cpp
+++ b/toolsrc/src/SourceParagraph.cpp
@@ -2,6 +2,7 @@
#include "vcpkglib_helpers.h"
#include "vcpkg_System.h"
#include "vcpkg_Maps.h"
+#include "triplet.h"
namespace vcpkg
{
@@ -44,7 +45,7 @@ namespace vcpkg
this->maintainer = details::remove_optional_field(&fields, SourceParagraphOptionalField::MAINTAINER);
std::string deps = details::remove_optional_field(&fields, SourceParagraphOptionalField::BUILD_DEPENDS);
- this->depends = details::parse_depends(deps);
+ this->depends = expand_qualified_dependencies(parse_depends(deps));
if (!fields.empty())
{
@@ -60,4 +61,84 @@ namespace vcpkg
exit(EXIT_FAILURE);
}
}
+
+ std::vector<dependency> vcpkg::expand_qualified_dependencies(const std::vector<std::string>& depends)
+ {
+ auto convert = [&](const std::string& depend_string) -> dependency {
+ auto pos = depend_string.find(' ');
+ if (pos == std::string::npos)
+ return{ depend_string, "" };
+ // expect of the form "\w+ \[\w+\]"
+ dependency dep;
+ dep.name = depend_string.substr(0, pos);
+ if (depend_string.c_str()[pos + 1] != '[' || depend_string[depend_string.size() - 1] != ']')
+ {
+ // Error, but for now just slurp the entire string.
+ return{ depend_string, "" };
+ }
+ dep.qualifier = depend_string.substr(pos + 2, depend_string.size() - pos - 3);
+ return dep;
+ };
+
+ std::vector<vcpkg::dependency> ret;
+
+ for (auto&& depend_string : depends)
+ {
+ ret.push_back(convert(depend_string));
+ }
+
+ return ret;
+ }
+
+ std::vector<std::string> parse_depends(const std::string& depends_string)
+ {
+ if (depends_string.empty())
+ {
+ return{};
+ }
+
+ std::vector<std::string> out;
+
+ size_t cur = 0;
+ do
+ {
+ auto pos = depends_string.find(',', cur);
+ if (pos == std::string::npos)
+ {
+ out.push_back(depends_string.substr(cur));
+ break;
+ }
+ out.push_back(depends_string.substr(cur, pos - cur));
+
+ // skip comma and space
+ ++pos;
+ if (depends_string[pos] == ' ')
+ {
+ ++pos;
+ }
+
+ cur = pos;
+ } while (cur != std::string::npos);
+
+ return out;
+ }
+
+ std::vector<std::string> filter_dependencies(const std::vector<vcpkg::dependency>& deps, const triplet& t)
+ {
+ std::vector<std::string> ret;
+ for (auto&& dep : deps)
+ {
+ if (dep.qualifier.empty() || t.canonical_name().find(dep.qualifier) != std::string::npos)
+ {
+ ret.push_back(dep.name);
+ }
+ }
+ return ret;
+ }
+
+ std::ostream & operator<<(std::ostream & os, const dependency & p)
+ {
+ os << p.name;
+ return os;
+ }
}