diff options
| author | nicole mazzuca <mazzucan@outlook.com> | 2020-07-14 08:50:19 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-07-14 08:50:19 -0700 |
| commit | d2620cf02bf01bb3cd6873aa2ba7687644019ed0 (patch) | |
| tree | fda361dda33da62d10553519d4bb1acc2f49caf7 /toolsrc/include | |
| parent | e55460813578f6a8633bbf76ef96e10c1fa22382 (diff) | |
| download | vcpkg-d2620cf02bf01bb3cd6873aa2ba7687644019ed0.tar.gz vcpkg-d2620cf02bf01bb3cd6873aa2ba7687644019ed0.zip | |
[vcpkg formatting] Turn off DeriveLineEnding (#12368)
* [vcpkg formatting] Turn off DeriveLineEnding
* format
* Add newlines to the end of files
Since we're reformatting anyways
Diffstat (limited to 'toolsrc/include')
| -rw-r--r-- | toolsrc/include/vcpkg-test/mockcmakevarprovider.h | 76 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/base/cache.h | 42 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/base/ignore_errors.h | 20 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/base/span.h | 114 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/base/view.h | 18 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/binarycaching.h | 106 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/binarycaching.private.h | 120 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/buildenvironment.h | 26 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/export.chocolatey.h | 38 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/platform-expression.h | 148 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/textrowcol.h | 34 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/visualstudio.h | 28 |
12 files changed, 385 insertions, 385 deletions
diff --git a/toolsrc/include/vcpkg-test/mockcmakevarprovider.h b/toolsrc/include/vcpkg-test/mockcmakevarprovider.h index 21207c856..482f9ea40 100644 --- a/toolsrc/include/vcpkg-test/mockcmakevarprovider.h +++ b/toolsrc/include/vcpkg-test/mockcmakevarprovider.h @@ -1,38 +1,38 @@ -#pragma once
-
-#include <vcpkg/cmakevars.h>
-
-namespace vcpkg::Test
-{
- struct MockCMakeVarProvider : CMakeVars::CMakeVarProvider
- {
- void load_generic_triplet_vars(Triplet triplet) const override { generic_triplet_vars[triplet] = {}; }
-
- void load_dep_info_vars(Span<const PackageSpec> specs) const override
- {
- for (auto&& spec : specs)
- dep_info_vars[spec] = {};
- }
-
- void load_tag_vars(Span<const FullPackageSpec> specs,
- const PortFileProvider::PortFileProvider& port_provider) const override
- {
- for (auto&& spec : specs)
- tag_vars[spec.package_spec] = {};
- Util::unused(port_provider);
- }
-
- Optional<const std::unordered_map<std::string, std::string>&> get_generic_triplet_vars(
- Triplet triplet) const override;
-
- Optional<const std::unordered_map<std::string, std::string>&> get_dep_info_vars(
- const PackageSpec& spec) const override;
-
- Optional<const std::unordered_map<std::string, std::string>&> get_tag_vars(
- const PackageSpec& spec) const override;
-
- mutable std::unordered_map<PackageSpec, std::unordered_map<std::string, std::string>> dep_info_vars;
- mutable std::unordered_map<PackageSpec, std::unordered_map<std::string, std::string>> tag_vars;
- mutable std::unordered_map<Triplet, std::unordered_map<std::string, std::string>> generic_triplet_vars;
- };
-}
+#pragma once + +#include <vcpkg/cmakevars.h> + +namespace vcpkg::Test +{ + struct MockCMakeVarProvider : CMakeVars::CMakeVarProvider + { + void load_generic_triplet_vars(Triplet triplet) const override { generic_triplet_vars[triplet] = {}; } + + void load_dep_info_vars(Span<const PackageSpec> specs) const override + { + for (auto&& spec : specs) + dep_info_vars[spec] = {}; + } + + void load_tag_vars(Span<const FullPackageSpec> specs, + const PortFileProvider::PortFileProvider& port_provider) const override + { + for (auto&& spec : specs) + tag_vars[spec.package_spec] = {}; + Util::unused(port_provider); + } + + Optional<const std::unordered_map<std::string, std::string>&> get_generic_triplet_vars( + Triplet triplet) const override; + + Optional<const std::unordered_map<std::string, std::string>&> get_dep_info_vars( + const PackageSpec& spec) const override; + + Optional<const std::unordered_map<std::string, std::string>&> get_tag_vars( + const PackageSpec& spec) const override; + + mutable std::unordered_map<PackageSpec, std::unordered_map<std::string, std::string>> dep_info_vars; + mutable std::unordered_map<PackageSpec, std::unordered_map<std::string, std::string>> tag_vars; + mutable std::unordered_map<Triplet, std::unordered_map<std::string, std::string>> generic_triplet_vars; + }; +} diff --git a/toolsrc/include/vcpkg/base/cache.h b/toolsrc/include/vcpkg/base/cache.h index dfc7565b8..1996f2587 100644 --- a/toolsrc/include/vcpkg/base/cache.h +++ b/toolsrc/include/vcpkg/base/cache.h @@ -1,21 +1,21 @@ -#pragma once
-
-#include <map>
-
-namespace vcpkg
-{
- template<class Key, class Value>
- struct Cache
- {
- template<class F>
- Value const& get_lazy(const Key& k, const F& f) const
- {
- auto it = m_cache.find(k);
- if (it != m_cache.end()) return it->second;
- return m_cache.emplace(k, f()).first->second;
- }
-
- private:
- mutable std::map<Key, Value> m_cache;
- };
-}
+#pragma once + +#include <map> + +namespace vcpkg +{ + template<class Key, class Value> + struct Cache + { + template<class F> + Value const& get_lazy(const Key& k, const F& f) const + { + auto it = m_cache.find(k); + if (it != m_cache.end()) return it->second; + return m_cache.emplace(k, f()).first->second; + } + + private: + mutable std::map<Key, Value> m_cache; + }; +} diff --git a/toolsrc/include/vcpkg/base/ignore_errors.h b/toolsrc/include/vcpkg/base/ignore_errors.h index 44077059a..ed8b38c56 100644 --- a/toolsrc/include/vcpkg/base/ignore_errors.h +++ b/toolsrc/include/vcpkg/base/ignore_errors.h @@ -1,10 +1,10 @@ -#pragma once
-
-namespace vcpkg
-{
- struct ignore_errors_t
- {
- };
-
- constexpr ignore_errors_t ignore_errors;
-}
+#pragma once + +namespace vcpkg +{ + struct ignore_errors_t + { + }; + + constexpr ignore_errors_t ignore_errors; +} diff --git a/toolsrc/include/vcpkg/base/span.h b/toolsrc/include/vcpkg/base/span.h index 482fe1b00..221cccc8c 100644 --- a/toolsrc/include/vcpkg/base/span.h +++ b/toolsrc/include/vcpkg/base/span.h @@ -1,57 +1,57 @@ -#pragma once
-
-#include <array>
-#include <cstddef>
-#include <initializer_list>
-#include <vector>
-
-namespace vcpkg
-{
- template<class T>
- struct Span
- {
- public:
- static_assert(std::is_object<T>::value, "Span<non-object-type> is illegal");
-
- using value_type = std::decay_t<T>;
- using element_type = T;
- using pointer = std::add_pointer_t<T>;
- using reference = std::add_lvalue_reference_t<T>;
- using iterator = pointer;
-
- constexpr Span() noexcept : m_ptr(nullptr), m_count(0) { }
- constexpr Span(std::nullptr_t) noexcept : m_ptr(nullptr), m_count(0) { }
- constexpr Span(pointer ptr, size_t count) noexcept : m_ptr(ptr), m_count(count) { }
- constexpr Span(pointer ptr_begin, pointer ptr_end) noexcept : m_ptr(ptr_begin), m_count(ptr_end - ptr_begin) { }
-
- template<size_t N>
- constexpr Span(T (&arr)[N]) noexcept : m_ptr(arr), m_count(N)
- {
- }
-
- template<size_t N, class = std::enable_if_t<std::is_const_v<T>>>
- constexpr Span(std::remove_const_t<T> (&arr)[N]) noexcept : m_ptr(arr), m_count(N)
- {
- }
-
- template<class Range,
- class = decltype(std::declval<Range>().data()),
- class = std::enable_if_t<!std::is_same<std::decay_t<Range>, Span>::value>>
- constexpr Span(Range&& v) noexcept : Span(v.data(), v.size())
- {
- static_assert(std::is_same<typename std::decay_t<Range>::value_type, value_type>::value,
- "Cannot convert incompatible ranges");
- }
-
- constexpr iterator begin() const { return m_ptr; }
- constexpr iterator end() const { return m_ptr + m_count; }
-
- constexpr reference operator[](size_t i) const { return m_ptr[i]; }
- constexpr pointer data() const { return m_ptr; }
- constexpr size_t size() const { return m_count; }
-
- private:
- pointer m_ptr;
- size_t m_count;
- };
-}
+#pragma once + +#include <array> +#include <cstddef> +#include <initializer_list> +#include <vector> + +namespace vcpkg +{ + template<class T> + struct Span + { + public: + static_assert(std::is_object<T>::value, "Span<non-object-type> is illegal"); + + using value_type = std::decay_t<T>; + using element_type = T; + using pointer = std::add_pointer_t<T>; + using reference = std::add_lvalue_reference_t<T>; + using iterator = pointer; + + constexpr Span() noexcept : m_ptr(nullptr), m_count(0) { } + constexpr Span(std::nullptr_t) noexcept : m_ptr(nullptr), m_count(0) { } + constexpr Span(pointer ptr, size_t count) noexcept : m_ptr(ptr), m_count(count) { } + constexpr Span(pointer ptr_begin, pointer ptr_end) noexcept : m_ptr(ptr_begin), m_count(ptr_end - ptr_begin) { } + + template<size_t N> + constexpr Span(T (&arr)[N]) noexcept : m_ptr(arr), m_count(N) + { + } + + template<size_t N, class = std::enable_if_t<std::is_const_v<T>>> + constexpr Span(std::remove_const_t<T> (&arr)[N]) noexcept : m_ptr(arr), m_count(N) + { + } + + template<class Range, + class = decltype(std::declval<Range>().data()), + class = std::enable_if_t<!std::is_same<std::decay_t<Range>, Span>::value>> + constexpr Span(Range&& v) noexcept : Span(v.data(), v.size()) + { + static_assert(std::is_same<typename std::decay_t<Range>::value_type, value_type>::value, + "Cannot convert incompatible ranges"); + } + + constexpr iterator begin() const { return m_ptr; } + constexpr iterator end() const { return m_ptr + m_count; } + + constexpr reference operator[](size_t i) const { return m_ptr[i]; } + constexpr pointer data() const { return m_ptr; } + constexpr size_t size() const { return m_count; } + + private: + pointer m_ptr; + size_t m_count; + }; +} diff --git a/toolsrc/include/vcpkg/base/view.h b/toolsrc/include/vcpkg/base/view.h index 8a9c40994..491e8351b 100644 --- a/toolsrc/include/vcpkg/base/view.h +++ b/toolsrc/include/vcpkg/base/view.h @@ -1,9 +1,9 @@ -#pragma once
-
-#include <vcpkg/base/span.h>
-
-namespace vcpkg
-{
- template<class T>
- using View = Span<const T>;
-}
+#pragma once + +#include <vcpkg/base/span.h> + +namespace vcpkg +{ + template<class T> + using View = Span<const T>; +} diff --git a/toolsrc/include/vcpkg/binarycaching.h b/toolsrc/include/vcpkg/binarycaching.h index 44c223084..be52d1e49 100644 --- a/toolsrc/include/vcpkg/binarycaching.h +++ b/toolsrc/include/vcpkg/binarycaching.h @@ -1,53 +1,53 @@ -#pragma once
-
-#include <vcpkg/base/expected.h>
-#include <vcpkg/base/files.h>
-
-#include <vcpkg/packagespec.h>
-#include <vcpkg/vcpkgpaths.h>
-
-namespace vcpkg::Dependencies
-{
- struct InstallPlanAction;
- struct ActionPlan;
-}
-namespace vcpkg::Build
-{
- struct AbiTagAndFile;
- struct BuildPackageOptions;
-}
-
-namespace vcpkg
-{
- enum class RestoreResult
- {
- missing,
- success,
- build_failed,
- };
-
- struct IBinaryProvider
- {
- virtual ~IBinaryProvider() = default;
- /// Gives the BinaryProvider an opportunity to batch any downloading or server communication for executing
- /// `plan`.
- virtual void prefetch(const VcpkgPaths& paths, const Dependencies::ActionPlan& plan) = 0;
- /// Attempts to restore the package referenced by `action` into the packages directory.
- virtual RestoreResult try_restore(const VcpkgPaths& paths, const Dependencies::InstallPlanAction& action) = 0;
- /// Called upon a successful build of `action`
- virtual void push_success(const VcpkgPaths& paths, const Dependencies::InstallPlanAction& action) = 0;
- /// Requests the result of `try_restore()` without actually downloading the package. Used by CI to determine
- /// missing packages.
- virtual RestoreResult precheck(const VcpkgPaths& paths, const Dependencies::InstallPlanAction& action) = 0;
- };
-
- IBinaryProvider& null_binary_provider();
-
- ExpectedS<std::unique_ptr<IBinaryProvider>> create_binary_provider_from_configs(View<std::string> args);
- ExpectedS<std::unique_ptr<IBinaryProvider>> create_binary_provider_from_configs_pure(const std::string& env_string,
- View<std::string> args);
-
- std::string generate_nuget_packages_config(const Dependencies::ActionPlan& action);
-
- void help_topic_binary_caching(const VcpkgPaths& paths);
-}
+#pragma once + +#include <vcpkg/base/expected.h> +#include <vcpkg/base/files.h> + +#include <vcpkg/packagespec.h> +#include <vcpkg/vcpkgpaths.h> + +namespace vcpkg::Dependencies +{ + struct InstallPlanAction; + struct ActionPlan; +} +namespace vcpkg::Build +{ + struct AbiTagAndFile; + struct BuildPackageOptions; +} + +namespace vcpkg +{ + enum class RestoreResult + { + missing, + success, + build_failed, + }; + + struct IBinaryProvider + { + virtual ~IBinaryProvider() = default; + /// Gives the BinaryProvider an opportunity to batch any downloading or server communication for executing + /// `plan`. + virtual void prefetch(const VcpkgPaths& paths, const Dependencies::ActionPlan& plan) = 0; + /// Attempts to restore the package referenced by `action` into the packages directory. + virtual RestoreResult try_restore(const VcpkgPaths& paths, const Dependencies::InstallPlanAction& action) = 0; + /// Called upon a successful build of `action` + virtual void push_success(const VcpkgPaths& paths, const Dependencies::InstallPlanAction& action) = 0; + /// Requests the result of `try_restore()` without actually downloading the package. Used by CI to determine + /// missing packages. + virtual RestoreResult precheck(const VcpkgPaths& paths, const Dependencies::InstallPlanAction& action) = 0; + }; + + IBinaryProvider& null_binary_provider(); + + ExpectedS<std::unique_ptr<IBinaryProvider>> create_binary_provider_from_configs(View<std::string> args); + ExpectedS<std::unique_ptr<IBinaryProvider>> create_binary_provider_from_configs_pure(const std::string& env_string, + View<std::string> args); + + std::string generate_nuget_packages_config(const Dependencies::ActionPlan& action); + + void help_topic_binary_caching(const VcpkgPaths& paths); +} diff --git a/toolsrc/include/vcpkg/binarycaching.private.h b/toolsrc/include/vcpkg/binarycaching.private.h index 040b34597..1b5d587de 100644 --- a/toolsrc/include/vcpkg/binarycaching.private.h +++ b/toolsrc/include/vcpkg/binarycaching.private.h @@ -1,60 +1,60 @@ -#pragma once
-
-#include <vcpkg/dependencies.h>
-#include <vcpkg/packagespec.h>
-#include <vcpkg/vcpkgpaths.h>
-
-#include <string>
-
-namespace vcpkg
-{
- std::string reformat_version(const std::string& version, const std::string& abi_tag);
-
- struct NugetReference
- {
- explicit NugetReference(const Dependencies::InstallPlanAction& action)
- : NugetReference(action.spec,
- action.source_control_file_location.value_or_exit(VCPKG_LINE_INFO)
- .source_control_file->core_paragraph->version,
- action.abi_info.value_or_exit(VCPKG_LINE_INFO).package_abi)
- {
- }
-
- NugetReference(const PackageSpec& spec, const std::string& raw_version, const std::string& abi_tag)
- : id(spec.dir()), version(reformat_version(raw_version, abi_tag))
- {
- }
-
- std::string id;
- std::string version;
-
- std::string nupkg_filename() const { return Strings::concat(id, '.', version, ".nupkg"); }
- };
-
- std::string generate_nuspec(const VcpkgPaths& paths,
- const Dependencies::InstallPlanAction& action,
- const NugetReference& ref);
-
- struct XmlSerializer
- {
- XmlSerializer& emit_declaration();
- XmlSerializer& open_tag(StringLiteral sl);
- XmlSerializer& start_complex_open_tag(StringLiteral sl);
- XmlSerializer& text_attr(StringLiteral name, StringView content);
- XmlSerializer& finish_complex_open_tag();
- XmlSerializer& finish_self_closing_complex_tag();
- XmlSerializer& close_tag(StringLiteral sl);
- XmlSerializer& text(StringView sv);
- XmlSerializer& simple_tag(StringLiteral tag, StringView content);
- XmlSerializer& line_break();
-
- std::string buf;
-
- private:
- XmlSerializer& emit_pending_indent();
-
- int m_indent = 0;
- bool m_pending_indent = false;
- };
-
-}
\ No newline at end of file +#pragma once + +#include <vcpkg/dependencies.h> +#include <vcpkg/packagespec.h> +#include <vcpkg/vcpkgpaths.h> + +#include <string> + +namespace vcpkg +{ + std::string reformat_version(const std::string& version, const std::string& abi_tag); + + struct NugetReference + { + explicit NugetReference(const Dependencies::InstallPlanAction& action) + : NugetReference(action.spec, + action.source_control_file_location.value_or_exit(VCPKG_LINE_INFO) + .source_control_file->core_paragraph->version, + action.abi_info.value_or_exit(VCPKG_LINE_INFO).package_abi) + { + } + + NugetReference(const PackageSpec& spec, const std::string& raw_version, const std::string& abi_tag) + : id(spec.dir()), version(reformat_version(raw_version, abi_tag)) + { + } + + std::string id; + std::string version; + + std::string nupkg_filename() const { return Strings::concat(id, '.', version, ".nupkg"); } + }; + + std::string generate_nuspec(const VcpkgPaths& paths, + const Dependencies::InstallPlanAction& action, + const NugetReference& ref); + + struct XmlSerializer + { + XmlSerializer& emit_declaration(); + XmlSerializer& open_tag(StringLiteral sl); + XmlSerializer& start_complex_open_tag(StringLiteral sl); + XmlSerializer& text_attr(StringLiteral name, StringView content); + XmlSerializer& finish_complex_open_tag(); + XmlSerializer& finish_self_closing_complex_tag(); + XmlSerializer& close_tag(StringLiteral sl); + XmlSerializer& text(StringView sv); + XmlSerializer& simple_tag(StringLiteral tag, StringView content); + XmlSerializer& line_break(); + + std::string buf; + + private: + XmlSerializer& emit_pending_indent(); + + int m_indent = 0; + bool m_pending_indent = false; + }; + +} diff --git a/toolsrc/include/vcpkg/buildenvironment.h b/toolsrc/include/vcpkg/buildenvironment.h index 921fb419d..1216caa2a 100644 --- a/toolsrc/include/vcpkg/buildenvironment.h +++ b/toolsrc/include/vcpkg/buildenvironment.h @@ -1,13 +1,13 @@ -#include <vcpkg/base/system.process.h>
-
-#include <vcpkg/vcpkgpaths.h>
-
-#include <string>
-#include <vector>
-
-namespace vcpkg
-{
- std::string make_cmake_cmd(const VcpkgPaths& paths,
- const fs::path& cmake_script,
- std::vector<System::CMakeVariable>&& pass_variables);
-}
+#include <vcpkg/base/system.process.h> + +#include <vcpkg/vcpkgpaths.h> + +#include <string> +#include <vector> + +namespace vcpkg +{ + std::string make_cmake_cmd(const VcpkgPaths& paths, + const fs::path& cmake_script, + std::vector<System::CMakeVariable>&& pass_variables); +} diff --git a/toolsrc/include/vcpkg/export.chocolatey.h b/toolsrc/include/vcpkg/export.chocolatey.h index 7804108fd..1e6f9a12b 100644 --- a/toolsrc/include/vcpkg/export.chocolatey.h +++ b/toolsrc/include/vcpkg/export.chocolatey.h @@ -1,19 +1,19 @@ -#pragma once
-
-#include <vcpkg/dependencies.h>
-#include <vcpkg/vcpkgpaths.h>
-
-#include <vector>
-
-namespace vcpkg::Export::Chocolatey
-{
- struct Options
- {
- Optional<std::string> maybe_maintainer;
- Optional<std::string> maybe_version_suffix;
- };
-
- void do_export(const std::vector<Dependencies::ExportPlanAction>& export_plan,
- const VcpkgPaths& paths,
- const Options& chocolatey_options);
-}
+#pragma once + +#include <vcpkg/dependencies.h> +#include <vcpkg/vcpkgpaths.h> + +#include <vector> + +namespace vcpkg::Export::Chocolatey +{ + struct Options + { + Optional<std::string> maybe_maintainer; + Optional<std::string> maybe_version_suffix; + }; + + void do_export(const std::vector<Dependencies::ExportPlanAction>& export_plan, + const VcpkgPaths& paths, + const Options& chocolatey_options); +} diff --git a/toolsrc/include/vcpkg/platform-expression.h b/toolsrc/include/vcpkg/platform-expression.h index b9a6f6a88..fd2bb8589 100644 --- a/toolsrc/include/vcpkg/platform-expression.h +++ b/toolsrc/include/vcpkg/platform-expression.h @@ -1,74 +1,74 @@ -#pragma once
-
-#include <vcpkg/base/expected.h>
-#include <vcpkg/base/stringview.h>
-
-#include <string>
-#include <unordered_map>
-
-namespace vcpkg::PlatformExpression
-{
- // map of cmake variables and their values.
- using Context = std::unordered_map<std::string, std::string>;
-
- namespace detail
- {
- struct ExprImpl;
- }
- struct Expr
- {
- static Expr Identifier(StringView id);
- static Expr Not(Expr&& e);
- static Expr And(std::vector<Expr>&& exprs);
- static Expr Or(std::vector<Expr>&& exprs);
-
- // The empty expression is always true
- static Expr Empty() { return Expr(); }
-
- // since ExprImpl is not yet defined, we need to define the ctor and dtor in the C++ file
- Expr();
- Expr(const Expr&);
- Expr(Expr&&);
- Expr& operator=(const Expr& e);
- Expr& operator=(Expr&&);
-
- explicit Expr(std::unique_ptr<detail::ExprImpl>&& e);
- ~Expr();
-
- bool evaluate(const Context& context) const;
- bool is_empty() const { return !static_cast<bool>(underlying_); }
-
- private:
- std::unique_ptr<detail::ExprImpl> underlying_;
- };
-
- // Note: for backwards compatibility, in CONTROL files,
- // multiple binary operators are allowed to be next to one another; i.e.
- // (windows & arm) = (windows && arm) = (windows &&& arm), etc.
- enum class MultipleBinaryOperators
- {
- Deny,
- Allow,
- };
-
- // platform expression parses the following :
- // <platform-expression>:
- // <platform-expression.not>
- // <platform-expression.and>
- // <platform-expression.or>
- // <platform-expression.simple>:
- // ( <platform-expression> )
- // <platform-expression.identifier>
- // <platform-expression.identifier>:
- // A lowercase alpha-numeric string
- // <platform-expression.not>:
- // <platform-expression.simple>
- // ! <platform-expression.simple>
- // <platform-expression.and>
- // <platform-expression.not>
- // <platform-expression.and> & <platform-expression.not>
- // <platform-expression.or>
- // <platform-expression.not>
- // <platform-expression.or> | <platform-expression.not>
- ExpectedS<Expr> parse_platform_expression(StringView expression, MultipleBinaryOperators multiple_binary_operators);
-}
+#pragma once + +#include <vcpkg/base/expected.h> +#include <vcpkg/base/stringview.h> + +#include <string> +#include <unordered_map> + +namespace vcpkg::PlatformExpression +{ + // map of cmake variables and their values. + using Context = std::unordered_map<std::string, std::string>; + + namespace detail + { + struct ExprImpl; + } + struct Expr + { + static Expr Identifier(StringView id); + static Expr Not(Expr&& e); + static Expr And(std::vector<Expr>&& exprs); + static Expr Or(std::vector<Expr>&& exprs); + + // The empty expression is always true + static Expr Empty() { return Expr(); } + + // since ExprImpl is not yet defined, we need to define the ctor and dtor in the C++ file + Expr(); + Expr(const Expr&); + Expr(Expr&&); + Expr& operator=(const Expr& e); + Expr& operator=(Expr&&); + + explicit Expr(std::unique_ptr<detail::ExprImpl>&& e); + ~Expr(); + + bool evaluate(const Context& context) const; + bool is_empty() const { return !static_cast<bool>(underlying_); } + + private: + std::unique_ptr<detail::ExprImpl> underlying_; + }; + + // Note: for backwards compatibility, in CONTROL files, + // multiple binary operators are allowed to be next to one another; i.e. + // (windows & arm) = (windows && arm) = (windows &&& arm), etc. + enum class MultipleBinaryOperators + { + Deny, + Allow, + }; + + // platform expression parses the following : + // <platform-expression>: + // <platform-expression.not> + // <platform-expression.and> + // <platform-expression.or> + // <platform-expression.simple>: + // ( <platform-expression> ) + // <platform-expression.identifier> + // <platform-expression.identifier>: + // A lowercase alpha-numeric string + // <platform-expression.not>: + // <platform-expression.simple> + // ! <platform-expression.simple> + // <platform-expression.and> + // <platform-expression.not> + // <platform-expression.and> & <platform-expression.not> + // <platform-expression.or> + // <platform-expression.not> + // <platform-expression.or> | <platform-expression.not> + ExpectedS<Expr> parse_platform_expression(StringView expression, MultipleBinaryOperators multiple_binary_operators); +} diff --git a/toolsrc/include/vcpkg/textrowcol.h b/toolsrc/include/vcpkg/textrowcol.h index bf6f31d7c..b8269f697 100644 --- a/toolsrc/include/vcpkg/textrowcol.h +++ b/toolsrc/include/vcpkg/textrowcol.h @@ -1,17 +1,17 @@ -#pragma once
-
-namespace vcpkg::Parse
-{
- struct TextRowCol
- {
- constexpr TextRowCol() noexcept = default;
- constexpr TextRowCol(int row, int column) noexcept : row(row), column(column) { }
- /// '0' indicates uninitialized; '1' is the first row.
- int row = 0;
- /// '0' indicates uninitialized; '1' is the first column.
- int column = 0;
-
- constexpr int row_or(int def) const noexcept { return row ? row : def; }
- constexpr int column_or(int def) const noexcept { return column ? column : def; }
- };
-}
+#pragma once + +namespace vcpkg::Parse +{ + struct TextRowCol + { + constexpr TextRowCol() noexcept = default; + constexpr TextRowCol(int row, int column) noexcept : row(row), column(column) { } + /// '0' indicates uninitialized; '1' is the first row. + int row = 0; + /// '0' indicates uninitialized; '1' is the first column. + int column = 0; + + constexpr int row_or(int def) const noexcept { return row ? row : def; } + constexpr int column_or(int def) const noexcept { return column ? column : def; } + }; +} diff --git a/toolsrc/include/vcpkg/visualstudio.h b/toolsrc/include/vcpkg/visualstudio.h index cd99db352..da6652b3e 100644 --- a/toolsrc/include/vcpkg/visualstudio.h +++ b/toolsrc/include/vcpkg/visualstudio.h @@ -1,14 +1,14 @@ -#pragma once
-
-#if defined(_WIN32)
-
-#include <vcpkg/vcpkgpaths.h>
-
-namespace vcpkg::VisualStudio
-{
- std::vector<std::string> get_visual_studio_instances(const VcpkgPaths& paths);
-
- std::vector<Toolset> find_toolset_instances_preferred_first(const VcpkgPaths& paths);
-}
-
-#endif
+#pragma once + +#if defined(_WIN32) + +#include <vcpkg/vcpkgpaths.h> + +namespace vcpkg::VisualStudio +{ + std::vector<std::string> get_visual_studio_instances(const VcpkgPaths& paths); + + std::vector<Toolset> find_toolset_instances_preferred_first(const VcpkgPaths& paths); +} + +#endif |
