2016-09-18 20:50:08 -07:00
|
|
|
#pragma once
|
|
|
|
|
2017-10-13 18:37:41 -07:00
|
|
|
#include <vcpkg/base/checks.h>
|
2019-04-08 23:26:18 -07:00
|
|
|
#include <vcpkg/base/stringliteral.h>
|
2017-10-13 18:37:41 -07:00
|
|
|
|
2017-04-27 17:56:06 -07:00
|
|
|
#include <system_error>
|
2016-09-18 20:50:08 -07:00
|
|
|
|
|
|
|
namespace vcpkg
|
|
|
|
{
|
2017-06-05 15:58:47 -07:00
|
|
|
template<class Err>
|
|
|
|
struct ErrorHolder
|
2016-09-18 20:50:08 -07:00
|
|
|
{
|
2020-06-22 14:14:36 -07:00
|
|
|
ErrorHolder() : m_is_error(false), m_err{} {}
|
2017-06-17 02:39:14 -07:00
|
|
|
template<class U>
|
|
|
|
ErrorHolder(U&& err) : m_is_error(true), m_err(std::forward<U>(err))
|
|
|
|
{
|
|
|
|
}
|
2017-06-05 15:58:47 -07:00
|
|
|
|
|
|
|
constexpr bool has_error() const { return m_is_error; }
|
|
|
|
|
|
|
|
const Err& error() const { return m_err; }
|
|
|
|
Err& error() { return m_err; }
|
|
|
|
|
2019-04-08 23:26:18 -07:00
|
|
|
StringLiteral to_string() const { return "value was error"; }
|
2017-06-05 15:58:47 -07:00
|
|
|
|
|
|
|
private:
|
|
|
|
bool m_is_error;
|
|
|
|
Err m_err;
|
|
|
|
};
|
|
|
|
|
2019-04-08 23:26:18 -07:00
|
|
|
template<>
|
|
|
|
struct ErrorHolder<std::string>
|
|
|
|
{
|
[vcpkg manifest] Manifest Implementation (#11757)
==== Changes Related to manifests ====
* Add the `manifests` feature flag
* This only says whether we look for a `vcpkg.json` in the cwd, not
whether we support parsing manifests (for ports, for example)
* Changes to the manifests RFC
* `"authors"` -> `"maintainers"`
* `--x-classic-mode` -> `-manifests` \in `vcpkg_feature_flags`
* reserve `"core"` in addition to `"default"`, since that's already
reserved for features
* Add a small helper note about what identifiers must look like
* `<license-string>`: SPDX v3.8 -> v3.9
* `"feature"."description"` is allowed to be an array of strings as well
* `"version"` -> `"version-string"` for forward-compat with versions
RFC
* Add the `--feature-flags` option
* Add the ability to turn off feature flags via passing
`-<feature-flag>` to `VCPKG_FEATURE_FLAGS` or `--feature-flags`
* Add CMake toolchain support for manifests
* Requires either:
* a feature flag of `manifests` in either `Env{VCPKG_FEATURE_FLAGS}`
or `VCPKG_FEATURE_FLAGS`
* Passing the `VCPKG_ENABLE_MANIFESTS` option
* The toolchain will install your packages to
`${VCPKG_MANIFEST_DIR}/vcpkg_installed`.
* Add MSBuild `vcpkg integrate install` support for manifests
* Requires `VcpkgEnableManifest` to be true
* `vcpkg create` creates a port that has a `vcpkg.json` instead of a
`CONTROL`
* argparse, abseil, 3fd, and avisynthplus ports switched to manifest
from CONTROL
* Add support for `--x-manifest-root`, as well as code for finding it if
not passed
* Add support for parsing manifests!
* Add a filesystem lock!
==== Important Changes which are somewhat unrelated to manifests ====
* Rename `logicexpression.{h,cpp}` to `platform-expression.{h,cpp}`
* Add `PlatformExpression` type which takes the place of the old logic
expression
* Split the parsing of platform expressions from checking whether
they're true or not
* Eagerly parse PlatformExpressions as opposed to leaving them as
strings
* Add checking for feature flag consistency
* i.e., if `-binarycaching` is passed, you shouldn't be passing
`--binarysource`
* Add the `Json::Reader` type which, with the help of user-defined
visitors, converts JSON to your internal type
* VcpkgArgParser: place the switch names into a constant as opposed to
using magic constants
* In general update the parsing code so that this ^ works
* Add `Port-Version` fields to CONTROL files
* This replaces the existing practice of
`Version: <my-version>-<port-version>`
==== Smaller changes ====
* small drive-by cleanups to some CMake
* `${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}` ->
`${CURRENT_INSTALLED_DIR}`
* Remove `-analyze` when compiling with clang-cl, since that's not a
supported flag (vcpkg's build system)
* Add a message about which compiler is detected by vcpkg's build
system machinery
* Fix `Expected::then`
* Convert `""` to `{}` for `std::string` and `fs::path`, to avoid a
`strlen` (additionally, `.empty()` instead of `== ""`, and `.clear()`)
* Add `Strings::strto` which converts strings to numeric types
* Support built-in arrays and `StringView` for `Strings::join`
* Add `operator<` and friends to `StringView`
* Add `substr` to `StringView`
* SourceParagraphParser gets some new errors
2020-06-30 10:40:18 -07:00
|
|
|
ErrorHolder() : m_is_error(false) { }
|
2019-04-08 23:26:18 -07:00
|
|
|
template<class U>
|
|
|
|
ErrorHolder(U&& err) : m_is_error(true), m_err(std::forward<U>(err))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool has_error() const { return m_is_error; }
|
|
|
|
|
|
|
|
const std::string& error() const { return m_err; }
|
|
|
|
std::string& error() { return m_err; }
|
|
|
|
|
|
|
|
const std::string& to_string() const { return m_err; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool m_is_error;
|
|
|
|
std::string m_err;
|
|
|
|
};
|
|
|
|
|
2017-06-05 15:58:47 -07:00
|
|
|
template<>
|
|
|
|
struct ErrorHolder<std::error_code>
|
|
|
|
{
|
|
|
|
ErrorHolder() = default;
|
[vcpkg manifest] Manifest Implementation (#11757)
==== Changes Related to manifests ====
* Add the `manifests` feature flag
* This only says whether we look for a `vcpkg.json` in the cwd, not
whether we support parsing manifests (for ports, for example)
* Changes to the manifests RFC
* `"authors"` -> `"maintainers"`
* `--x-classic-mode` -> `-manifests` \in `vcpkg_feature_flags`
* reserve `"core"` in addition to `"default"`, since that's already
reserved for features
* Add a small helper note about what identifiers must look like
* `<license-string>`: SPDX v3.8 -> v3.9
* `"feature"."description"` is allowed to be an array of strings as well
* `"version"` -> `"version-string"` for forward-compat with versions
RFC
* Add the `--feature-flags` option
* Add the ability to turn off feature flags via passing
`-<feature-flag>` to `VCPKG_FEATURE_FLAGS` or `--feature-flags`
* Add CMake toolchain support for manifests
* Requires either:
* a feature flag of `manifests` in either `Env{VCPKG_FEATURE_FLAGS}`
or `VCPKG_FEATURE_FLAGS`
* Passing the `VCPKG_ENABLE_MANIFESTS` option
* The toolchain will install your packages to
`${VCPKG_MANIFEST_DIR}/vcpkg_installed`.
* Add MSBuild `vcpkg integrate install` support for manifests
* Requires `VcpkgEnableManifest` to be true
* `vcpkg create` creates a port that has a `vcpkg.json` instead of a
`CONTROL`
* argparse, abseil, 3fd, and avisynthplus ports switched to manifest
from CONTROL
* Add support for `--x-manifest-root`, as well as code for finding it if
not passed
* Add support for parsing manifests!
* Add a filesystem lock!
==== Important Changes which are somewhat unrelated to manifests ====
* Rename `logicexpression.{h,cpp}` to `platform-expression.{h,cpp}`
* Add `PlatformExpression` type which takes the place of the old logic
expression
* Split the parsing of platform expressions from checking whether
they're true or not
* Eagerly parse PlatformExpressions as opposed to leaving them as
strings
* Add checking for feature flag consistency
* i.e., if `-binarycaching` is passed, you shouldn't be passing
`--binarysource`
* Add the `Json::Reader` type which, with the help of user-defined
visitors, converts JSON to your internal type
* VcpkgArgParser: place the switch names into a constant as opposed to
using magic constants
* In general update the parsing code so that this ^ works
* Add `Port-Version` fields to CONTROL files
* This replaces the existing practice of
`Version: <my-version>-<port-version>`
==== Smaller changes ====
* small drive-by cleanups to some CMake
* `${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}` ->
`${CURRENT_INSTALLED_DIR}`
* Remove `-analyze` when compiling with clang-cl, since that's not a
supported flag (vcpkg's build system)
* Add a message about which compiler is detected by vcpkg's build
system machinery
* Fix `Expected::then`
* Convert `""` to `{}` for `std::string` and `fs::path`, to avoid a
`strlen` (additionally, `.empty()` instead of `== ""`, and `.clear()`)
* Add `Strings::strto` which converts strings to numeric types
* Support built-in arrays and `StringView` for `Strings::join`
* Add `operator<` and friends to `StringView`
* Add `substr` to `StringView`
* SourceParagraphParser gets some new errors
2020-06-30 10:40:18 -07:00
|
|
|
ErrorHolder(const std::error_code& err) : m_err(err) { }
|
2017-06-05 15:58:47 -07:00
|
|
|
|
2017-10-16 11:44:04 -07:00
|
|
|
bool has_error() const { return bool(m_err); }
|
2016-09-18 20:50:08 -07:00
|
|
|
|
2017-06-05 15:58:47 -07:00
|
|
|
const std::error_code& error() const { return m_err; }
|
|
|
|
std::error_code& error() { return m_err; }
|
2016-09-18 20:50:08 -07:00
|
|
|
|
2019-04-08 23:26:18 -07:00
|
|
|
std::string to_string() const { return m_err.message(); }
|
2016-09-18 20:50:08 -07:00
|
|
|
|
2017-06-05 15:58:47 -07:00
|
|
|
private:
|
|
|
|
std::error_code m_err;
|
|
|
|
};
|
|
|
|
|
2019-04-08 23:26:18 -07:00
|
|
|
struct ExpectedLeftTag
|
|
|
|
{
|
|
|
|
};
|
|
|
|
struct ExpectedRightTag
|
|
|
|
{
|
|
|
|
};
|
|
|
|
constexpr ExpectedLeftTag expected_left_tag;
|
|
|
|
constexpr ExpectedRightTag expected_right_tag;
|
|
|
|
|
2020-02-07 11:24:35 -08:00
|
|
|
template<class T>
|
|
|
|
struct ExpectedHolder
|
|
|
|
{
|
|
|
|
ExpectedHolder() = default;
|
[vcpkg manifest] Manifest Implementation (#11757)
==== Changes Related to manifests ====
* Add the `manifests` feature flag
* This only says whether we look for a `vcpkg.json` in the cwd, not
whether we support parsing manifests (for ports, for example)
* Changes to the manifests RFC
* `"authors"` -> `"maintainers"`
* `--x-classic-mode` -> `-manifests` \in `vcpkg_feature_flags`
* reserve `"core"` in addition to `"default"`, since that's already
reserved for features
* Add a small helper note about what identifiers must look like
* `<license-string>`: SPDX v3.8 -> v3.9
* `"feature"."description"` is allowed to be an array of strings as well
* `"version"` -> `"version-string"` for forward-compat with versions
RFC
* Add the `--feature-flags` option
* Add the ability to turn off feature flags via passing
`-<feature-flag>` to `VCPKG_FEATURE_FLAGS` or `--feature-flags`
* Add CMake toolchain support for manifests
* Requires either:
* a feature flag of `manifests` in either `Env{VCPKG_FEATURE_FLAGS}`
or `VCPKG_FEATURE_FLAGS`
* Passing the `VCPKG_ENABLE_MANIFESTS` option
* The toolchain will install your packages to
`${VCPKG_MANIFEST_DIR}/vcpkg_installed`.
* Add MSBuild `vcpkg integrate install` support for manifests
* Requires `VcpkgEnableManifest` to be true
* `vcpkg create` creates a port that has a `vcpkg.json` instead of a
`CONTROL`
* argparse, abseil, 3fd, and avisynthplus ports switched to manifest
from CONTROL
* Add support for `--x-manifest-root`, as well as code for finding it if
not passed
* Add support for parsing manifests!
* Add a filesystem lock!
==== Important Changes which are somewhat unrelated to manifests ====
* Rename `logicexpression.{h,cpp}` to `platform-expression.{h,cpp}`
* Add `PlatformExpression` type which takes the place of the old logic
expression
* Split the parsing of platform expressions from checking whether
they're true or not
* Eagerly parse PlatformExpressions as opposed to leaving them as
strings
* Add checking for feature flag consistency
* i.e., if `-binarycaching` is passed, you shouldn't be passing
`--binarysource`
* Add the `Json::Reader` type which, with the help of user-defined
visitors, converts JSON to your internal type
* VcpkgArgParser: place the switch names into a constant as opposed to
using magic constants
* In general update the parsing code so that this ^ works
* Add `Port-Version` fields to CONTROL files
* This replaces the existing practice of
`Version: <my-version>-<port-version>`
==== Smaller changes ====
* small drive-by cleanups to some CMake
* `${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}` ->
`${CURRENT_INSTALLED_DIR}`
* Remove `-analyze` when compiling with clang-cl, since that's not a
supported flag (vcpkg's build system)
* Add a message about which compiler is detected by vcpkg's build
system machinery
* Fix `Expected::then`
* Convert `""` to `{}` for `std::string` and `fs::path`, to avoid a
`strlen` (additionally, `.empty()` instead of `== ""`, and `.clear()`)
* Add `Strings::strto` which converts strings to numeric types
* Support built-in arrays and `StringView` for `Strings::join`
* Add `operator<` and friends to `StringView`
* Add `substr` to `StringView`
* SourceParagraphParser gets some new errors
2020-06-30 10:40:18 -07:00
|
|
|
ExpectedHolder(const T& t) : t(t) { }
|
|
|
|
ExpectedHolder(T&& t) : t(std::move(t)) { }
|
2020-02-07 11:24:35 -08:00
|
|
|
using pointer = T*;
|
|
|
|
using const_pointer = const T*;
|
|
|
|
T* get() { return &t; }
|
|
|
|
const T* get() const { return &t; }
|
|
|
|
T t;
|
|
|
|
};
|
|
|
|
template<class T>
|
|
|
|
struct ExpectedHolder<T&>
|
|
|
|
{
|
[vcpkg manifest] Manifest Implementation (#11757)
==== Changes Related to manifests ====
* Add the `manifests` feature flag
* This only says whether we look for a `vcpkg.json` in the cwd, not
whether we support parsing manifests (for ports, for example)
* Changes to the manifests RFC
* `"authors"` -> `"maintainers"`
* `--x-classic-mode` -> `-manifests` \in `vcpkg_feature_flags`
* reserve `"core"` in addition to `"default"`, since that's already
reserved for features
* Add a small helper note about what identifiers must look like
* `<license-string>`: SPDX v3.8 -> v3.9
* `"feature"."description"` is allowed to be an array of strings as well
* `"version"` -> `"version-string"` for forward-compat with versions
RFC
* Add the `--feature-flags` option
* Add the ability to turn off feature flags via passing
`-<feature-flag>` to `VCPKG_FEATURE_FLAGS` or `--feature-flags`
* Add CMake toolchain support for manifests
* Requires either:
* a feature flag of `manifests` in either `Env{VCPKG_FEATURE_FLAGS}`
or `VCPKG_FEATURE_FLAGS`
* Passing the `VCPKG_ENABLE_MANIFESTS` option
* The toolchain will install your packages to
`${VCPKG_MANIFEST_DIR}/vcpkg_installed`.
* Add MSBuild `vcpkg integrate install` support for manifests
* Requires `VcpkgEnableManifest` to be true
* `vcpkg create` creates a port that has a `vcpkg.json` instead of a
`CONTROL`
* argparse, abseil, 3fd, and avisynthplus ports switched to manifest
from CONTROL
* Add support for `--x-manifest-root`, as well as code for finding it if
not passed
* Add support for parsing manifests!
* Add a filesystem lock!
==== Important Changes which are somewhat unrelated to manifests ====
* Rename `logicexpression.{h,cpp}` to `platform-expression.{h,cpp}`
* Add `PlatformExpression` type which takes the place of the old logic
expression
* Split the parsing of platform expressions from checking whether
they're true or not
* Eagerly parse PlatformExpressions as opposed to leaving them as
strings
* Add checking for feature flag consistency
* i.e., if `-binarycaching` is passed, you shouldn't be passing
`--binarysource`
* Add the `Json::Reader` type which, with the help of user-defined
visitors, converts JSON to your internal type
* VcpkgArgParser: place the switch names into a constant as opposed to
using magic constants
* In general update the parsing code so that this ^ works
* Add `Port-Version` fields to CONTROL files
* This replaces the existing practice of
`Version: <my-version>-<port-version>`
==== Smaller changes ====
* small drive-by cleanups to some CMake
* `${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}` ->
`${CURRENT_INSTALLED_DIR}`
* Remove `-analyze` when compiling with clang-cl, since that's not a
supported flag (vcpkg's build system)
* Add a message about which compiler is detected by vcpkg's build
system machinery
* Fix `Expected::then`
* Convert `""` to `{}` for `std::string` and `fs::path`, to avoid a
`strlen` (additionally, `.empty()` instead of `== ""`, and `.clear()`)
* Add `Strings::strto` which converts strings to numeric types
* Support built-in arrays and `StringView` for `Strings::join`
* Add `operator<` and friends to `StringView`
* Add `substr` to `StringView`
* SourceParagraphParser gets some new errors
2020-06-30 10:40:18 -07:00
|
|
|
ExpectedHolder(T& t) : t(&t) { }
|
|
|
|
ExpectedHolder() : t(nullptr) { }
|
2020-02-07 11:24:35 -08:00
|
|
|
using pointer = T*;
|
|
|
|
using const_pointer = T*;
|
|
|
|
T* get() { return t; }
|
|
|
|
T* get() const { return t; }
|
|
|
|
T* t;
|
|
|
|
};
|
|
|
|
|
2017-06-05 15:58:47 -07:00
|
|
|
template<class T, class S>
|
|
|
|
class ExpectedT
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
constexpr ExpectedT() = default;
|
|
|
|
|
|
|
|
// Constructors are intentionally implicit
|
|
|
|
|
[vcpkg manifest] Manifest Implementation (#11757)
==== Changes Related to manifests ====
* Add the `manifests` feature flag
* This only says whether we look for a `vcpkg.json` in the cwd, not
whether we support parsing manifests (for ports, for example)
* Changes to the manifests RFC
* `"authors"` -> `"maintainers"`
* `--x-classic-mode` -> `-manifests` \in `vcpkg_feature_flags`
* reserve `"core"` in addition to `"default"`, since that's already
reserved for features
* Add a small helper note about what identifiers must look like
* `<license-string>`: SPDX v3.8 -> v3.9
* `"feature"."description"` is allowed to be an array of strings as well
* `"version"` -> `"version-string"` for forward-compat with versions
RFC
* Add the `--feature-flags` option
* Add the ability to turn off feature flags via passing
`-<feature-flag>` to `VCPKG_FEATURE_FLAGS` or `--feature-flags`
* Add CMake toolchain support for manifests
* Requires either:
* a feature flag of `manifests` in either `Env{VCPKG_FEATURE_FLAGS}`
or `VCPKG_FEATURE_FLAGS`
* Passing the `VCPKG_ENABLE_MANIFESTS` option
* The toolchain will install your packages to
`${VCPKG_MANIFEST_DIR}/vcpkg_installed`.
* Add MSBuild `vcpkg integrate install` support for manifests
* Requires `VcpkgEnableManifest` to be true
* `vcpkg create` creates a port that has a `vcpkg.json` instead of a
`CONTROL`
* argparse, abseil, 3fd, and avisynthplus ports switched to manifest
from CONTROL
* Add support for `--x-manifest-root`, as well as code for finding it if
not passed
* Add support for parsing manifests!
* Add a filesystem lock!
==== Important Changes which are somewhat unrelated to manifests ====
* Rename `logicexpression.{h,cpp}` to `platform-expression.{h,cpp}`
* Add `PlatformExpression` type which takes the place of the old logic
expression
* Split the parsing of platform expressions from checking whether
they're true or not
* Eagerly parse PlatformExpressions as opposed to leaving them as
strings
* Add checking for feature flag consistency
* i.e., if `-binarycaching` is passed, you shouldn't be passing
`--binarysource`
* Add the `Json::Reader` type which, with the help of user-defined
visitors, converts JSON to your internal type
* VcpkgArgParser: place the switch names into a constant as opposed to
using magic constants
* In general update the parsing code so that this ^ works
* Add `Port-Version` fields to CONTROL files
* This replaces the existing practice of
`Version: <my-version>-<port-version>`
==== Smaller changes ====
* small drive-by cleanups to some CMake
* `${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}` ->
`${CURRENT_INSTALLED_DIR}`
* Remove `-analyze` when compiling with clang-cl, since that's not a
supported flag (vcpkg's build system)
* Add a message about which compiler is detected by vcpkg's build
system machinery
* Fix `Expected::then`
* Convert `""` to `{}` for `std::string` and `fs::path`, to avoid a
`strlen` (additionally, `.empty()` instead of `== ""`, and `.clear()`)
* Add `Strings::strto` which converts strings to numeric types
* Support built-in arrays and `StringView` for `Strings::join`
* Add `operator<` and friends to `StringView`
* Add `substr` to `StringView`
* SourceParagraphParser gets some new errors
2020-06-30 10:40:18 -07:00
|
|
|
ExpectedT(const S& s, ExpectedRightTag = {}) : m_s(s) { }
|
|
|
|
ExpectedT(S&& s, ExpectedRightTag = {}) : m_s(std::move(s)) { }
|
2016-09-18 20:50:08 -07:00
|
|
|
|
[vcpkg manifest] Manifest Implementation (#11757)
==== Changes Related to manifests ====
* Add the `manifests` feature flag
* This only says whether we look for a `vcpkg.json` in the cwd, not
whether we support parsing manifests (for ports, for example)
* Changes to the manifests RFC
* `"authors"` -> `"maintainers"`
* `--x-classic-mode` -> `-manifests` \in `vcpkg_feature_flags`
* reserve `"core"` in addition to `"default"`, since that's already
reserved for features
* Add a small helper note about what identifiers must look like
* `<license-string>`: SPDX v3.8 -> v3.9
* `"feature"."description"` is allowed to be an array of strings as well
* `"version"` -> `"version-string"` for forward-compat with versions
RFC
* Add the `--feature-flags` option
* Add the ability to turn off feature flags via passing
`-<feature-flag>` to `VCPKG_FEATURE_FLAGS` or `--feature-flags`
* Add CMake toolchain support for manifests
* Requires either:
* a feature flag of `manifests` in either `Env{VCPKG_FEATURE_FLAGS}`
or `VCPKG_FEATURE_FLAGS`
* Passing the `VCPKG_ENABLE_MANIFESTS` option
* The toolchain will install your packages to
`${VCPKG_MANIFEST_DIR}/vcpkg_installed`.
* Add MSBuild `vcpkg integrate install` support for manifests
* Requires `VcpkgEnableManifest` to be true
* `vcpkg create` creates a port that has a `vcpkg.json` instead of a
`CONTROL`
* argparse, abseil, 3fd, and avisynthplus ports switched to manifest
from CONTROL
* Add support for `--x-manifest-root`, as well as code for finding it if
not passed
* Add support for parsing manifests!
* Add a filesystem lock!
==== Important Changes which are somewhat unrelated to manifests ====
* Rename `logicexpression.{h,cpp}` to `platform-expression.{h,cpp}`
* Add `PlatformExpression` type which takes the place of the old logic
expression
* Split the parsing of platform expressions from checking whether
they're true or not
* Eagerly parse PlatformExpressions as opposed to leaving them as
strings
* Add checking for feature flag consistency
* i.e., if `-binarycaching` is passed, you shouldn't be passing
`--binarysource`
* Add the `Json::Reader` type which, with the help of user-defined
visitors, converts JSON to your internal type
* VcpkgArgParser: place the switch names into a constant as opposed to
using magic constants
* In general update the parsing code so that this ^ works
* Add `Port-Version` fields to CONTROL files
* This replaces the existing practice of
`Version: <my-version>-<port-version>`
==== Smaller changes ====
* small drive-by cleanups to some CMake
* `${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}` ->
`${CURRENT_INSTALLED_DIR}`
* Remove `-analyze` when compiling with clang-cl, since that's not a
supported flag (vcpkg's build system)
* Add a message about which compiler is detected by vcpkg's build
system machinery
* Fix `Expected::then`
* Convert `""` to `{}` for `std::string` and `fs::path`, to avoid a
`strlen` (additionally, `.empty()` instead of `== ""`, and `.clear()`)
* Add `Strings::strto` which converts strings to numeric types
* Support built-in arrays and `StringView` for `Strings::join`
* Add `operator<` and friends to `StringView`
* Add `substr` to `StringView`
* SourceParagraphParser gets some new errors
2020-06-30 10:40:18 -07:00
|
|
|
ExpectedT(const T& t, ExpectedLeftTag = {}) : m_t(t) { }
|
2020-02-07 11:24:35 -08:00
|
|
|
template<class = std::enable_if<!std::is_reference_v<T>>>
|
|
|
|
ExpectedT(T&& t, ExpectedLeftTag = {}) : m_t(std::move(t))
|
|
|
|
{
|
|
|
|
}
|
2016-09-18 20:50:08 -07:00
|
|
|
|
2017-06-05 15:58:47 -07:00
|
|
|
ExpectedT(const ExpectedT&) = default;
|
|
|
|
ExpectedT(ExpectedT&&) = default;
|
|
|
|
ExpectedT& operator=(const ExpectedT&) = default;
|
|
|
|
ExpectedT& operator=(ExpectedT&&) = default;
|
2016-09-18 20:50:08 -07:00
|
|
|
|
2017-06-05 15:58:47 -07:00
|
|
|
explicit constexpr operator bool() const noexcept { return !m_s.has_error(); }
|
|
|
|
constexpr bool has_value() const noexcept { return !m_s.has_error(); }
|
2016-09-18 20:50:08 -07:00
|
|
|
|
2017-03-31 16:23:48 -07:00
|
|
|
T&& value_or_exit(const LineInfo& line_info) &&
|
2016-09-18 20:50:08 -07:00
|
|
|
{
|
2017-03-28 12:57:00 -07:00
|
|
|
exit_if_error(line_info);
|
2020-02-07 11:24:35 -08:00
|
|
|
return std::move(*this->m_t.get());
|
2016-09-18 20:50:08 -07:00
|
|
|
}
|
|
|
|
|
2017-10-13 18:37:41 -07:00
|
|
|
const T& value_or_exit(const LineInfo& line_info) const&
|
2016-09-18 20:50:08 -07:00
|
|
|
{
|
2017-03-28 12:57:00 -07:00
|
|
|
exit_if_error(line_info);
|
2020-02-07 11:24:35 -08:00
|
|
|
return *this->m_t.get();
|
2016-09-18 20:50:08 -07:00
|
|
|
}
|
|
|
|
|
2017-10-13 18:37:41 -07:00
|
|
|
const S& error() const& { return this->m_s.error(); }
|
2017-06-05 15:58:47 -07:00
|
|
|
|
|
|
|
S&& error() && { return std::move(this->m_s.error()); }
|
|
|
|
|
2020-02-07 11:24:35 -08:00
|
|
|
typename ExpectedHolder<T>::const_pointer get() const
|
2016-09-18 20:50:08 -07:00
|
|
|
{
|
2017-06-05 15:58:47 -07:00
|
|
|
if (!this->has_value())
|
2016-09-18 20:50:08 -07:00
|
|
|
{
|
|
|
|
return nullptr;
|
|
|
|
}
|
2020-02-07 11:24:35 -08:00
|
|
|
return this->m_t.get();
|
2016-09-18 20:50:08 -07:00
|
|
|
}
|
|
|
|
|
2020-02-07 11:24:35 -08:00
|
|
|
typename ExpectedHolder<T>::pointer get()
|
2016-09-18 20:50:08 -07:00
|
|
|
{
|
2017-06-05 15:58:47 -07:00
|
|
|
if (!this->has_value())
|
2016-09-18 20:50:08 -07:00
|
|
|
{
|
|
|
|
return nullptr;
|
|
|
|
}
|
2020-02-07 11:24:35 -08:00
|
|
|
return this->m_t.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
template<class F>
|
|
|
|
using map_t = decltype(std::declval<F&>()(*std::declval<typename ExpectedHolder<T>::const_pointer>()));
|
|
|
|
|
|
|
|
template<class F, class U = map_t<F>>
|
|
|
|
ExpectedT<U, S> map(F f) const&
|
|
|
|
{
|
|
|
|
if (has_value())
|
|
|
|
{
|
|
|
|
return {f(*m_t.get()), expected_left_tag};
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return {error(), expected_right_tag};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template<class F>
|
|
|
|
using move_map_t =
|
|
|
|
decltype(std::declval<F&>()(std::move(*std::declval<typename ExpectedHolder<T>::pointer>())));
|
|
|
|
|
|
|
|
template<class F, class U = move_map_t<F>>
|
|
|
|
ExpectedT<U, S> map(F f) &&
|
|
|
|
{
|
|
|
|
if (has_value())
|
|
|
|
{
|
|
|
|
return {f(std::move(*m_t.get())), expected_left_tag};
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-04-17 18:16:20 -07:00
|
|
|
return {std::move(*this).error(), expected_right_tag};
|
2020-02-07 11:24:35 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template<class F, class U = map_t<F>>
|
|
|
|
U then(F f) const&
|
|
|
|
{
|
|
|
|
if (has_value())
|
|
|
|
{
|
|
|
|
return f(*m_t.get());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return U{error(), expected_right_tag};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template<class F, class U = move_map_t<F>>
|
|
|
|
U then(F f) &&
|
|
|
|
{
|
|
|
|
if (has_value())
|
|
|
|
{
|
|
|
|
return f(std::move(*m_t.get()));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
[vcpkg manifest] Manifest Implementation (#11757)
==== Changes Related to manifests ====
* Add the `manifests` feature flag
* This only says whether we look for a `vcpkg.json` in the cwd, not
whether we support parsing manifests (for ports, for example)
* Changes to the manifests RFC
* `"authors"` -> `"maintainers"`
* `--x-classic-mode` -> `-manifests` \in `vcpkg_feature_flags`
* reserve `"core"` in addition to `"default"`, since that's already
reserved for features
* Add a small helper note about what identifiers must look like
* `<license-string>`: SPDX v3.8 -> v3.9
* `"feature"."description"` is allowed to be an array of strings as well
* `"version"` -> `"version-string"` for forward-compat with versions
RFC
* Add the `--feature-flags` option
* Add the ability to turn off feature flags via passing
`-<feature-flag>` to `VCPKG_FEATURE_FLAGS` or `--feature-flags`
* Add CMake toolchain support for manifests
* Requires either:
* a feature flag of `manifests` in either `Env{VCPKG_FEATURE_FLAGS}`
or `VCPKG_FEATURE_FLAGS`
* Passing the `VCPKG_ENABLE_MANIFESTS` option
* The toolchain will install your packages to
`${VCPKG_MANIFEST_DIR}/vcpkg_installed`.
* Add MSBuild `vcpkg integrate install` support for manifests
* Requires `VcpkgEnableManifest` to be true
* `vcpkg create` creates a port that has a `vcpkg.json` instead of a
`CONTROL`
* argparse, abseil, 3fd, and avisynthplus ports switched to manifest
from CONTROL
* Add support for `--x-manifest-root`, as well as code for finding it if
not passed
* Add support for parsing manifests!
* Add a filesystem lock!
==== Important Changes which are somewhat unrelated to manifests ====
* Rename `logicexpression.{h,cpp}` to `platform-expression.{h,cpp}`
* Add `PlatformExpression` type which takes the place of the old logic
expression
* Split the parsing of platform expressions from checking whether
they're true or not
* Eagerly parse PlatformExpressions as opposed to leaving them as
strings
* Add checking for feature flag consistency
* i.e., if `-binarycaching` is passed, you shouldn't be passing
`--binarysource`
* Add the `Json::Reader` type which, with the help of user-defined
visitors, converts JSON to your internal type
* VcpkgArgParser: place the switch names into a constant as opposed to
using magic constants
* In general update the parsing code so that this ^ works
* Add `Port-Version` fields to CONTROL files
* This replaces the existing practice of
`Version: <my-version>-<port-version>`
==== Smaller changes ====
* small drive-by cleanups to some CMake
* `${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}` ->
`${CURRENT_INSTALLED_DIR}`
* Remove `-analyze` when compiling with clang-cl, since that's not a
supported flag (vcpkg's build system)
* Add a message about which compiler is detected by vcpkg's build
system machinery
* Fix `Expected::then`
* Convert `""` to `{}` for `std::string` and `fs::path`, to avoid a
`strlen` (additionally, `.empty()` instead of `== ""`, and `.clear()`)
* Add `Strings::strto` which converts strings to numeric types
* Support built-in arrays and `StringView` for `Strings::join`
* Add `operator<` and friends to `StringView`
* Add `substr` to `StringView`
* SourceParagraphParser gets some new errors
2020-06-30 10:40:18 -07:00
|
|
|
return U{std::move(*this).error(), expected_right_tag};
|
2020-02-07 11:24:35 -08:00
|
|
|
}
|
2016-09-18 20:50:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2017-03-28 12:57:00 -07:00
|
|
|
void exit_if_error(const LineInfo& line_info) const
|
2016-09-18 20:50:08 -07:00
|
|
|
{
|
2018-02-20 16:56:51 -08:00
|
|
|
// This is used for quick value_or_exit() calls, so always put line_info in the error message.
|
|
|
|
Checks::check_exit(line_info,
|
|
|
|
!m_s.has_error(),
|
|
|
|
"Failed at [%s] with message:\n%s",
|
|
|
|
line_info.to_string(),
|
|
|
|
m_s.to_string());
|
2016-09-18 20:50:08 -07:00
|
|
|
}
|
|
|
|
|
2017-06-05 15:58:47 -07:00
|
|
|
ErrorHolder<S> m_s;
|
2020-02-07 11:24:35 -08:00
|
|
|
ExpectedHolder<T> m_t;
|
2016-09-18 20:50:08 -07:00
|
|
|
};
|
2017-06-05 15:58:47 -07:00
|
|
|
|
|
|
|
template<class T>
|
|
|
|
using Expected = ExpectedT<T, std::error_code>;
|
2020-02-07 11:24:35 -08:00
|
|
|
|
|
|
|
template<class T>
|
|
|
|
using ExpectedS = ExpectedT<T, std::string>;
|
2016-09-18 20:50:08 -07:00
|
|
|
}
|