aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/include
diff options
context:
space:
mode:
authorras0219 <533828+ras0219@users.noreply.github.com>2020-10-21 14:46:48 -0700
committerGitHub <noreply@github.com>2020-10-21 14:46:48 -0700
commit291df751258928bc021a5251585c8733328edf25 (patch)
treee6ff3a8819d9d65ba5faa2bfb76108ade17926fb /toolsrc/include
parent998f86a82946591b1e80ade99a52699967dc66af (diff)
downloadvcpkg-291df751258928bc021a5251585c8733328edf25.tar.gz
vcpkg-291df751258928bc021a5251585c8733328edf25.zip
[vcpkg] Add `versions` feature flag and version field manifest parsing (#14079)
* [vcpkg] Add `versions` feature flag and version field manifest parsing * Introduce FeatureFlagSettings struct to more easily access feature flags throughout the program * To avoid users accidentally starting to write "version" instead of "version-string" in their manifests, vcpkg explicitly detects and prevents usage of ports with schemes other than "String" * Drive-by fix of copiable SourceControlFileLocation and an exposed use-after-move bug This code is largely extracted from PR #13777 Co-authored-by: Victor Romero <romerosanchezv@gmail.com> * [vcpkg] Address CR Comments. Fix test crash on Linux. Co-authored-by: Robert Schumacher <roschuma@microsoft.com> Co-authored-by: Victor Romero <romerosanchezv@gmail.com>
Diffstat (limited to 'toolsrc/include')
-rw-r--r--toolsrc/include/vcpkg/fwd/vcpkgcmdarguments.h1
-rw-r--r--toolsrc/include/vcpkg/sourceparagraph.h24
-rw-r--r--toolsrc/include/vcpkg/vcpkgcmdarguments.h21
-rw-r--r--toolsrc/include/vcpkg/vcpkgpaths.h1
-rw-r--r--toolsrc/include/vcpkg/versions.h14
5 files changed, 50 insertions, 11 deletions
diff --git a/toolsrc/include/vcpkg/fwd/vcpkgcmdarguments.h b/toolsrc/include/vcpkg/fwd/vcpkgcmdarguments.h
index 87d6f9eaa..152627128 100644
--- a/toolsrc/include/vcpkg/fwd/vcpkgcmdarguments.h
+++ b/toolsrc/include/vcpkg/fwd/vcpkgcmdarguments.h
@@ -10,4 +10,5 @@ namespace vcpkg
struct CommandStructure;
struct HelpTableFormatter;
struct VcpkgCmdArguments;
+ struct FeatureFlagSettings;
}
diff --git a/toolsrc/include/vcpkg/sourceparagraph.h b/toolsrc/include/vcpkg/sourceparagraph.h
index d5069adde..21e5a4ef9 100644
--- a/toolsrc/include/vcpkg/sourceparagraph.h
+++ b/toolsrc/include/vcpkg/sourceparagraph.h
@@ -10,6 +10,7 @@
#include <vcpkg/packagespec.h>
#include <vcpkg/paragraphparser.h>
#include <vcpkg/platform-expression.h>
+#include <vcpkg/versions.h>
namespace vcpkg
{
@@ -54,6 +55,7 @@ namespace vcpkg
struct SourceParagraph
{
std::string name;
+ Versions::Scheme version_scheme = Versions::Scheme::String;
std::string version;
int port_version = 0;
std::vector<std::string> description;
@@ -78,14 +80,15 @@ namespace vcpkg
/// </summary>
struct SourceControlFile
{
- SourceControlFile() = default;
- SourceControlFile(const SourceControlFile& scf)
- : core_paragraph(std::make_unique<SourceParagraph>(*scf.core_paragraph))
+ SourceControlFile clone() const
{
- for (const auto& feat_ptr : scf.feature_paragraphs)
+ SourceControlFile ret;
+ ret.core_paragraph = std::make_unique<SourceParagraph>(*core_paragraph);
+ for (const auto& feat_ptr : feature_paragraphs)
{
- feature_paragraphs.push_back(std::make_unique<FeatureParagraph>(*feat_ptr));
+ ret.feature_paragraphs.push_back(std::make_unique<FeatureParagraph>(*feat_ptr));
}
+ return ret;
}
static Parse::ParseExpected<SourceControlFile> parse_manifest_file(const fs::path& path_to_manifest,
@@ -114,12 +117,6 @@ namespace vcpkg
/// </summary>
struct SourceControlFileLocation
{
- SourceControlFileLocation(const SourceControlFileLocation& scfl)
- : source_control_file(std::make_unique<SourceControlFile>(*scfl.source_control_file))
- , source_location(scfl.source_location)
- {
- }
-
SourceControlFileLocation(std::unique_ptr<SourceControlFile>&& scf, fs::path&& source)
: source_control_file(std::move(scf)), source_location(std::move(source))
{
@@ -130,6 +127,11 @@ namespace vcpkg
{
}
+ SourceControlFileLocation clone() const
+ {
+ return {std::make_unique<SourceControlFile>(source_control_file->clone()), source_location};
+ }
+
std::unique_ptr<SourceControlFile> source_control_file;
fs::path source_location;
};
diff --git a/toolsrc/include/vcpkg/vcpkgcmdarguments.h b/toolsrc/include/vcpkg/vcpkgcmdarguments.h
index eaf5cc3eb..6759e63cf 100644
--- a/toolsrc/include/vcpkg/vcpkgcmdarguments.h
+++ b/toolsrc/include/vcpkg/vcpkgcmdarguments.h
@@ -98,6 +98,14 @@ namespace vcpkg
std::string m_str;
};
+ struct FeatureFlagSettings
+ {
+ bool registries;
+ bool compiler_tracking;
+ bool binary_caching;
+ bool versions;
+ };
+
struct VcpkgCmdArguments
{
static VcpkgCmdArguments create_from_command_line(const Files::Filesystem& fs,
@@ -173,12 +181,25 @@ namespace vcpkg
Optional<bool> manifest_mode = nullopt;
constexpr static StringLiteral REGISTRIES_FEATURE = "registries";
Optional<bool> registries_feature = nullopt;
+ constexpr static StringLiteral VERSIONS_FEATURE = "versions";
+ Optional<bool> versions_feature = nullopt;
constexpr static StringLiteral RECURSIVE_DATA_ENV = "VCPKG_X_RECURSIVE_DATA";
bool binary_caching_enabled() const { return binary_caching.value_or(true); }
bool compiler_tracking_enabled() const { return compiler_tracking.value_or(true); }
bool registries_enabled() const { return registries_feature.value_or(false); }
+ bool versions_enabled() const { return versions_feature.value_or(false); }
+ FeatureFlagSettings feature_flag_settings() const
+ {
+ FeatureFlagSettings f;
+ f.binary_caching = binary_caching_enabled();
+ f.compiler_tracking = compiler_tracking_enabled();
+ f.registries = registries_enabled();
+ f.versions = versions_enabled();
+ return f;
+ }
+
bool output_json() const { return json.value_or(false); }
bool is_recursive_invocation() const { return m_is_recursive_invocation; }
diff --git a/toolsrc/include/vcpkg/vcpkgpaths.h b/toolsrc/include/vcpkg/vcpkgpaths.h
index da0e2ec14..aa1ba92d7 100644
--- a/toolsrc/include/vcpkg/vcpkgpaths.h
+++ b/toolsrc/include/vcpkg/vcpkgpaths.h
@@ -125,6 +125,7 @@ namespace vcpkg
const Build::CompilerInfo& get_compiler_info(const Build::AbiInfo& abi_info) const;
bool manifest_mode_enabled() const { return get_manifest().has_value(); }
+ const FeatureFlagSettings& get_feature_flags() const;
void track_feature_flag_metrics() const;
private:
diff --git a/toolsrc/include/vcpkg/versions.h b/toolsrc/include/vcpkg/versions.h
new file mode 100644
index 000000000..f0304c788
--- /dev/null
+++ b/toolsrc/include/vcpkg/versions.h
@@ -0,0 +1,14 @@
+#pragma once
+
+#include <vcpkg/fwd/vcpkgpaths.h>
+
+namespace vcpkg::Versions
+{
+ enum class Scheme
+ {
+ String,
+ Relaxed,
+ Semver,
+ Date
+ };
+}