aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/include
diff options
context:
space:
mode:
authorPhil Christensen <philc@microsoft.com>2019-08-02 21:37:49 -0700
committerGitHub <noreply@github.com>2019-08-02 21:37:49 -0700
commit22e0b9f376a66e6717f820e6c382c4112191ef9b (patch)
treee6ebb6be615a84880e65540ce582f3da0916369f /toolsrc/include
parent4d551ff4b3cea2f387b02ed69486a23b1be2fd73 (diff)
downloadvcpkg-22e0b9f376a66e6717f820e6c382c4112191ef9b.tar.gz
vcpkg-22e0b9f376a66e6717f820e6c382c4112191ef9b.zip
improve logic expression evaluation (#7508)
* better logic expression evaluation Improve the logic expression evaluation currently used when filtering dependencies. Biggest improvements: + Allow '|' operator + Support nested '()' + Allow whitespace + Useful error message for malformed expressions Also changed names of types to RawParagraph when that is what the original author was using.
Diffstat (limited to 'toolsrc/include')
-rw-r--r--toolsrc/include/vcpkg/binaryparagraph.h3
-rw-r--r--toolsrc/include/vcpkg/logicexpression.h10
-rw-r--r--toolsrc/include/vcpkg/paragraphs.h1
-rw-r--r--toolsrc/include/vcpkg/statusparagraph.h2
4 files changed, 13 insertions, 3 deletions
diff --git a/toolsrc/include/vcpkg/binaryparagraph.h b/toolsrc/include/vcpkg/binaryparagraph.h
index 3315151c6..4052da6d1 100644
--- a/toolsrc/include/vcpkg/binaryparagraph.h
+++ b/toolsrc/include/vcpkg/binaryparagraph.h
@@ -2,6 +2,7 @@
#include <vcpkg/packagespec.h>
#include <vcpkg/sourceparagraph.h>
+#include <vcpkg/parse.h>
#include <unordered_map>
@@ -13,7 +14,7 @@ namespace vcpkg
struct BinaryParagraph
{
BinaryParagraph();
- explicit BinaryParagraph(std::unordered_map<std::string, std::string> fields);
+ explicit BinaryParagraph(Parse::RawParagraph fields);
BinaryParagraph(const SourceParagraph& spgh, const Triplet& triplet, const std::string& abi_tag);
BinaryParagraph(const SourceParagraph& spgh, const FeatureParagraph& fpgh, const Triplet& triplet);
diff --git a/toolsrc/include/vcpkg/logicexpression.h b/toolsrc/include/vcpkg/logicexpression.h
new file mode 100644
index 000000000..4e6367b90
--- /dev/null
+++ b/toolsrc/include/vcpkg/logicexpression.h
@@ -0,0 +1,10 @@
+#pragma once
+
+#include <string>
+
+namespace vcpkg
+{
+ // Evaluate simple vcpkg logic expressions. An identifier in the expression is considered 'true'
+ // if it is a substring of the evaluation_context (typically the name of the triplet)
+ bool evaluate_expression(const std::string& expression, const std::string& evaluation_context);
+} \ No newline at end of file
diff --git a/toolsrc/include/vcpkg/paragraphs.h b/toolsrc/include/vcpkg/paragraphs.h
index 56f09387a..7e2410aef 100644
--- a/toolsrc/include/vcpkg/paragraphs.h
+++ b/toolsrc/include/vcpkg/paragraphs.h
@@ -12,7 +12,6 @@ namespace vcpkg::Paragraphs
Expected<RawParagraph> get_single_paragraph(const Files::Filesystem& fs, const fs::path& control_path);
Expected<std::vector<RawParagraph>> get_paragraphs(const Files::Filesystem& fs, const fs::path& control_path);
- Expected<RawParagraph> parse_single_paragraph(const std::string& str);
Expected<std::vector<RawParagraph>> parse_paragraphs(const std::string& str);
Parse::ParseExpected<SourceControlFile> try_load_port(const Files::Filesystem& fs, const fs::path& control_path);
diff --git a/toolsrc/include/vcpkg/statusparagraph.h b/toolsrc/include/vcpkg/statusparagraph.h
index e79c946cc..6e832fe2f 100644
--- a/toolsrc/include/vcpkg/statusparagraph.h
+++ b/toolsrc/include/vcpkg/statusparagraph.h
@@ -30,7 +30,7 @@ namespace vcpkg
struct StatusParagraph
{
StatusParagraph() noexcept;
- explicit StatusParagraph(std::unordered_map<std::string, std::string>&& fields);
+ explicit StatusParagraph(Parse::RawParagraph&& fields);
bool is_installed() const { return want == Want::INSTALL && state == InstallState::INSTALLED; }