Skip to content

Commit 4f37559

Browse files
authored
Remove embedded configuration warning. (#1766)
1 parent 4580816 commit 4f37559

File tree

14 files changed

+257
-78
lines changed

14 files changed

+257
-78
lines changed

azure-pipelines/e2e-projects/e2e-registry-templates/removed.json.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"vcpkg-configuration": {
2+
"configuration": {
33
"default-registry": {
44
"kind": "git",
55
"baseline": "$E2ERegistryBaseline",

docs/vcpkg.schema.json

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@
9090
"supports": {
9191
"$ref": "vcpkg-schema-definitions.schema.json#/definitions/platform-expression"
9292
},
93+
"configuration": {
94+
"description": "Embedded vcpkg.configuration.json file.",
95+
"$ref": "vcpkg-configuration.schema.json"
96+
},
9397
"vcpkg-configuration": {
9498
"description": "Embedded vcpkg.configuration.json file.",
9599
"$ref": "vcpkg-configuration.schema.json"
@@ -102,6 +106,21 @@
102106
},
103107
{
104108
"$ref": "vcpkg-schema-definitions.schema.json#/definitions/has-zero-or-one-version"
109+
},
110+
{
111+
"description": "Only one of configuration or vcpkg-configuration may be used. (They are aliases of the same field)",
112+
"if": {
113+
"required": [
114+
"configuration"
115+
]
116+
},
117+
"then": {
118+
"not": {
119+
"required": [
120+
"vcpkg-configuration"
121+
]
122+
}
123+
}
105124
}
106125
]
107-
}
126+
}

include/vcpkg/base/contractual-constants.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ namespace vcpkg
3030
inline constexpr StringLiteral JsonIdCacheCapitalSize = "cacheSize";
3131
inline constexpr StringLiteral JsonIdChecksums = "checksums";
3232
inline constexpr StringLiteral JsonIdComment = "comment";
33+
inline constexpr StringLiteral JsonIdConfiguration = "configuration";
3334
inline constexpr StringLiteral JsonIdContacts = "contacts";
3435
inline constexpr StringLiteral JsonIdCorrelator = "correlator";
3536
inline constexpr StringLiteral JsonIdCreated = "created";

include/vcpkg/base/message-data.inc.h

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,11 @@ DECLARE_MESSAGE(AlreadyInstalled, (msg::spec), "", "{spec} is already installed"
136136
DECLARE_MESSAGE(AManifest, (), "", "a manifest")
137137
DECLARE_MESSAGE(AMaximumOfOneAssetReadUrlCanBeSpecified, (), "", "a maximum of one asset read url can be specified.")
138138
DECLARE_MESSAGE(AMaximumOfOneAssetWriteUrlCanBeSpecified, (), "", "a maximum of one asset write url can be specified.")
139-
DECLARE_MESSAGE(AmbiguousConfigDeleteConfigFile,
140-
(msg::path),
139+
DECLARE_MESSAGE(AmbiguousConfig,
140+
(msg::json_field),
141141
"",
142-
"Ambiguous vcpkg configuration provided by both manifest and configuration file.\n-- Delete "
143-
"configuration file {path}")
142+
"Ambiguous vcpkg configuration provided by both manifest and configuration file. Choose one by "
143+
"deleting this file or deleting \"{json_field}\" from the manifest file.")
144144
DECLARE_MESSAGE(AnArtifactsGitRegistryUrl, (), "", "an artifacts git registry URL")
145145
DECLARE_MESSAGE(AnArtifactsRegistry, (), "", "an artifacts registry")
146146
DECLARE_MESSAGE(AnArrayOfDefaultFeatures, (), "", "an array of default features")
@@ -920,6 +920,10 @@ DECLARE_MESSAGE(ConfigurationNestedDemands,
920920
(msg::json_field),
921921
"",
922922
"[\"{json_field}\"] contains a nested `demands` object (nested `demands` have no effect)")
923+
DECLARE_MESSAGE(ConflictingEmbeddedConfiguration,
924+
(),
925+
"",
926+
"only one of {{\"configuration\", \"vcpkg-configuration\"}} may be used")
923927
DECLARE_MESSAGE(ConflictingFiles,
924928
(msg::path, msg::spec),
925929
"",
@@ -1013,10 +1017,6 @@ DECLARE_MESSAGE(
10131017
DECLARE_MESSAGE(DefaultFeatureIdentifier, (), "", "the names of default features must be identifiers")
10141018
DECLARE_MESSAGE(DefaultFlag, (msg::option), "", "Defaulting to --{option} being on.")
10151019
DECLARE_MESSAGE(DefaultRegistryIsArtifact, (), "", "The default registry cannot be an artifact registry.")
1016-
DECLARE_MESSAGE(DeleteVcpkgConfigFromManifest,
1017-
(msg::path),
1018-
"",
1019-
"-- Or remove \"vcpkg-configuration\" from the manifest file {path}.")
10201020
DECLARE_MESSAGE(
10211021
DependencyFeatureCore,
10221022
(),
@@ -1133,10 +1133,6 @@ DECLARE_MESSAGE(DuplicatePackagePatternRegistry, (msg::url), "", "registry: {url
11331133
DECLARE_MESSAGE(ElapsedForPackage, (msg::spec, msg::elapsed), "", "Elapsed time to handle {spec}: {elapsed}")
11341134
DECLARE_MESSAGE(ElapsedTimeForChecks, (msg::elapsed), "", "Time to determine pass/fail: {elapsed}")
11351135
DECLARE_MESSAGE(EmailVcpkgTeam, (msg::url), "", "Send an email to {url} with any feedback.")
1136-
DECLARE_MESSAGE(EmbeddingVcpkgConfigInManifest,
1137-
(),
1138-
"",
1139-
"Embedding `vcpkg-configuration` in a manifest file is an EXPERIMENTAL feature.")
11401136
DECLARE_MESSAGE(EmptyLicenseExpression, (), "", "SPDX license expression was empty.")
11411137
DECLARE_MESSAGE(EndOfStringInCodeUnit, (), "", "found end of string in middle of code point")
11421138
DECLARE_MESSAGE(EnvInvalidMaxConcurrency,
@@ -2125,6 +2121,7 @@ DECLARE_MESSAGE(LoadingDependencyInformation,
21252121
"",
21262122
"Loading dependency information for {count} packages...")
21272123
DECLARE_MESSAGE(LocalPortfileVersion, (), "", "Using local port versions. To update the local ports, use `git pull`.")
2124+
DECLARE_MESSAGE(ManifestHere, (), "", "the manifest file is here")
21282125
DECLARE_MESSAGE(ManifestConflict2, (), "", "Found both a manifest and CONTROL files; please rename one or the other")
21292126
DECLARE_MESSAGE(ManifestFormatCompleted, (), "", "Succeeded in formatting the manifest files.")
21302127
DECLARE_MESSAGE(MismatchedBinParagraphs,

include/vcpkg/configuration.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,8 @@ namespace vcpkg
6464
static View<StringView> known_fields();
6565
};
6666

67-
enum class ConfigurationSource
68-
{
69-
None,
70-
VcpkgConfigurationFile,
71-
ManifestFile,
72-
};
67+
StringLiteral configuration_source_file_name(ConfigurationSource source);
68+
StringLiteral configuration_source_field(ConfigurationSource source);
7369

7470
struct ConfigurationAndSource
7571
{
@@ -87,6 +83,7 @@ namespace vcpkg
8783
{
8884
Optional<std::string> builtin_baseline;
8985
Optional<Configuration> config;
86+
ConfigurationSource config_source = ConfigurationSource::None;
9087
};
9188

9289
extern const Json::IDeserializer<Configuration>& configuration_deserializer;

include/vcpkg/fwd/configuration.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,12 @@ namespace vcpkg
66
struct ConfigurationAndSource;
77
struct RegistryConfig;
88
struct ManifestConfiguration;
9+
10+
enum class ConfigurationSource
11+
{
12+
None,
13+
VcpkgConfigurationFile,
14+
ManifestFileVcpkgConfiguration,
15+
ManifestFileConfiguration
16+
};
917
}

include/vcpkg/sourceparagraph.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,9 @@ namespace vcpkg
188188
ParsedSpdxLicenseDeclaration license;
189189

190190
Optional<std::string> builtin_baseline;
191-
Optional<Json::Object> vcpkg_configuration;
191+
192+
Optional<Json::Object> configuration;
193+
ConfigurationSource configuration_source = ConfigurationSource::None;
192194
// Currently contacts is only a Json::Object but it will eventually be unified with maintainers
193195
Json::Object contacts;
194196

locales/messages.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@
119119
"_AllShasValid.comment": "sha = sha512 of url",
120120
"AlreadyInstalled": "{spec} is already installed",
121121
"_AlreadyInstalled.comment": "An example of {spec} is zlib:x64-windows.",
122-
"AmbiguousConfigDeleteConfigFile": "Ambiguous vcpkg configuration provided by both manifest and configuration file.\n-- Delete configuration file {path}",
123-
"_AmbiguousConfigDeleteConfigFile.comment": "An example of {path} is /foo/bar.",
122+
"AmbiguousConfig": "Ambiguous vcpkg configuration provided by both manifest and configuration file. Choose one by deleting this file or deleting \"{json_field}\" from the manifest file.",
123+
"_AmbiguousConfig.comment": "An example of {json_field} is identifer.",
124124
"AnArrayOfDefaultFeatures": "an array of default features",
125125
"AnArrayOfDependencies": "an array of dependencies",
126126
"AnArrayOfDependencyOverrides": "an array of dependency overrides",
@@ -536,6 +536,7 @@
536536
"_ConfigurationErrorRegistriesWithoutBaseline.comment": "An example of {path} is /foo/bar. An example of {url} is https://github.com/microsoft/vcpkg.",
537537
"ConfigurationNestedDemands": "[\"{json_field}\"] contains a nested `demands` object (nested `demands` have no effect)",
538538
"_ConfigurationNestedDemands.comment": "An example of {json_field} is identifer.",
539+
"ConflictingEmbeddedConfiguration": "only one of {{\"configuration\", \"vcpkg-configuration\"}} may be used",
539540
"ConflictingFiles": "The following files are already installed in {path} and are in conflict with {spec}",
540541
"_ConflictingFiles.comment": "An example of {path} is /foo/bar. An example of {spec} is zlib:x64-windows.",
541542
"ConsideredVersions": "The following executables were considered but discarded because of the version requirement of {version}:",
@@ -589,8 +590,6 @@
589590
"DefaultFlag": "Defaulting to --{option} being on.",
590591
"_DefaultFlag.comment": "An example of {option} is editable.",
591592
"DefaultRegistryIsArtifact": "The default registry cannot be an artifact registry.",
592-
"DeleteVcpkgConfigFromManifest": "-- Or remove \"vcpkg-configuration\" from the manifest file {path}.",
593-
"_DeleteVcpkgConfigFromManifest.comment": "An example of {path} is /foo/bar.",
594593
"DependencyFeatureCore": "the feature \"core\" cannot be in a dependency's feature list. To turn off default features, add \"default-features\": false instead.",
595594
"_DependencyFeatureCore.comment": "The word \"core\" is an on-disk name that must not be localized. The \"default-features\" part is JSON syntax that must be copied verbatim into the user's file.",
596595
"DependencyFeatureDefault": "the feature \"default\" cannot be in a dependency's feature list. To turn on default features, add \"default-features\": true instead.",
@@ -673,7 +672,6 @@
673672
"_ElapsedTimeForChecks.comment": "An example of {elapsed} is 3.532 min.",
674673
"EmailVcpkgTeam": "Send an email to {url} with any feedback.",
675674
"_EmailVcpkgTeam.comment": "An example of {url} is https://github.com/microsoft/vcpkg.",
676-
"EmbeddingVcpkgConfigInManifest": "Embedding `vcpkg-configuration` in a manifest file is an EXPERIMENTAL feature.",
677675
"EmptyLicenseExpression": "SPDX license expression was empty.",
678676
"EndOfStringInCodeUnit": "found end of string in middle of code point",
679677
"EnvInvalidMaxConcurrency": "{env_var} is {value}, must be > 0",
@@ -1172,6 +1170,7 @@
11721170
"LocalPortfileVersion": "Using local port versions. To update the local ports, use `git pull`.",
11731171
"ManifestConflict2": "Found both a manifest and CONTROL files; please rename one or the other",
11741172
"ManifestFormatCompleted": "Succeeded in formatting the manifest files.",
1173+
"ManifestHere": "the manifest file is here",
11751174
"MismatchedBinParagraphs": "The serialized binary paragraph was different from the original binary paragraph. Please open an issue at https://github.com/microsoft/vcpkg with the following output:",
11761175
"MismatchedFiles": "file to store does not match hash",
11771176
"MismatchedManifestAfterReserialize": "The serialized manifest was different from the original manifest. Please open an issue at https://github.com/microsoft/vcpkg, with the following output:",

src/vcpkg-test/manifests.cpp

Lines changed: 92 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ TEST_CASE ("manifest construct minimum", "[manifests]")
103103
REQUIRE(pgh.core_paragraph->description.empty());
104104
REQUIRE(pgh.core_paragraph->dependencies.empty());
105105
REQUIRE(!pgh.core_paragraph->builtin_baseline.has_value());
106-
REQUIRE(!pgh.core_paragraph->vcpkg_configuration.has_value());
106+
REQUIRE(!pgh.core_paragraph->configuration.has_value());
107107

108108
REQUIRE(pgh.check_against_feature_flags({}, feature_flags_without_versioning));
109109

@@ -136,7 +136,7 @@ TEST_CASE ("project manifest construct minimum", "[manifests]")
136136
REQUIRE(pgh.core_paragraph->description.empty());
137137
REQUIRE(pgh.core_paragraph->dependencies.empty());
138138
REQUIRE(!pgh.core_paragraph->builtin_baseline.has_value());
139-
REQUIRE(!pgh.core_paragraph->vcpkg_configuration.has_value());
139+
REQUIRE(!pgh.core_paragraph->configuration.has_value());
140140

141141
// name might not be present:
142142
REQUIRE(project_manifest_is_parsable(R"json({
@@ -873,6 +873,93 @@ TEST_CASE ("manifest embed configuration", "[manifests]")
873873
]
874874
})json";
875875

876+
std::string raw = Strings::concat(R"json({
877+
"configuration": )json",
878+
raw_config,
879+
R"json(,
880+
"name": "zlib",
881+
"version": "1.0.0",
882+
"builtin-baseline": "089fa4de7dca22c67dcab631f618d5cd0697c8d4",
883+
"dependencies": [
884+
"a",
885+
{
886+
"$extra": null,
887+
"name": "b"
888+
},
889+
{
890+
"name": "c",
891+
"version>=": "2018-09-01"
892+
}
893+
]
894+
})json");
895+
auto m_pgh = test_parse_port_manifest(raw);
896+
897+
REQUIRE(m_pgh.has_value());
898+
auto& pgh = **m_pgh.get();
899+
REQUIRE(!pgh.check_against_feature_flags({}, feature_flags_without_versioning));
900+
REQUIRE(pgh.check_against_feature_flags({}, feature_flags_with_versioning));
901+
902+
auto maybe_as_json = Json::parse(raw, "test");
903+
REQUIRE(maybe_as_json.has_value());
904+
auto as_json = *maybe_as_json.get();
905+
check_json_eq(Json::Value::object(serialize_manifest(pgh)), as_json.value);
906+
907+
REQUIRE(pgh.core_paragraph->builtin_baseline == "089fa4de7dca22c67dcab631f618d5cd0697c8d4");
908+
REQUIRE(pgh.core_paragraph->dependencies.size() == 3);
909+
REQUIRE(pgh.core_paragraph->dependencies[0].name == "a");
910+
REQUIRE(pgh.core_paragraph->dependencies[0].constraint == DependencyConstraint{});
911+
REQUIRE(pgh.core_paragraph->dependencies[1].name == "b");
912+
REQUIRE(pgh.core_paragraph->dependencies[1].constraint == DependencyConstraint{});
913+
REQUIRE(pgh.core_paragraph->dependencies[2].name == "c");
914+
REQUIRE(pgh.core_paragraph->dependencies[2].constraint ==
915+
DependencyConstraint{VersionConstraintKind::Minimum, Version{"2018-09-01", 0}});
916+
917+
auto config = Json::parse(raw_config, "<test config>").value(VCPKG_LINE_INFO).value;
918+
REQUIRE(config.is_object());
919+
auto config_obj = config.object(VCPKG_LINE_INFO);
920+
REQUIRE(pgh.core_paragraph->configuration.has_value());
921+
auto parsed_config_obj = *pgh.core_paragraph->configuration.get();
922+
REQUIRE(Json::stringify(parsed_config_obj) == Json::stringify(config_obj));
923+
REQUIRE(pgh.core_paragraph->configuration_source == ConfigurationSource::ManifestFileConfiguration);
924+
}
925+
926+
TEST_CASE ("manifest embed vcpkg_configuration", "[manifests]")
927+
{
928+
std::string raw_config = R"json({
929+
"$extra-info": null,
930+
"default-registry": {
931+
"kind": "builtin",
932+
"baseline": "089fa4de7dca22c67dcab631f618d5cd0697c8d4"
933+
},
934+
"registries": [
935+
{
936+
"kind": "filesystem",
937+
"path": "a/b/c",
938+
"baseline": "default",
939+
"packages": [
940+
"a",
941+
"b",
942+
"c"
943+
]
944+
},
945+
{
946+
"kind": "git",
947+
"repository": "https://github.com/microsoft/vcpkg-ports",
948+
"baseline": "089fa4de7dca22c67dcab631f618d5cd0697c8d4",
949+
"packages": [
950+
"zlib",
951+
"rapidjson",
952+
"fmt"
953+
]
954+
},
955+
{
956+
"kind": "artifact",
957+
"name": "vcpkg-artifacts",
958+
"location": "https://github.com/microsoft/vcpkg-artifacts"
959+
}
960+
]
961+
})json";
962+
876963
std::string raw = Strings::concat(R"json({
877964
"vcpkg-configuration": )json",
878965
raw_config,
@@ -917,9 +1004,10 @@ TEST_CASE ("manifest embed configuration", "[manifests]")
9171004
auto config = Json::parse(raw_config, "<test config>").value(VCPKG_LINE_INFO).value;
9181005
REQUIRE(config.is_object());
9191006
auto config_obj = config.object(VCPKG_LINE_INFO);
920-
REQUIRE(pgh.core_paragraph->vcpkg_configuration.has_value());
921-
auto parsed_config_obj = *pgh.core_paragraph->vcpkg_configuration.get();
1007+
REQUIRE(pgh.core_paragraph->configuration.has_value());
1008+
auto parsed_config_obj = *pgh.core_paragraph->configuration.get();
9221009
REQUIRE(Json::stringify(parsed_config_obj) == Json::stringify(config_obj));
1010+
REQUIRE(pgh.core_paragraph->configuration_source == ConfigurationSource::ManifestFileVcpkgConfiguration);
9231011
}
9241012

9251013
TEST_CASE ("manifest construct maximum", "[manifests]")

src/vcpkg/commands.new.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,8 @@ namespace vcpkg
171171
// no existing configuration, so create one with out-of-the-box registries
172172
break;
173173
case ConfigurationSource::VcpkgConfigurationFile:
174-
case ConfigurationSource::ManifestFile:
174+
case ConfigurationSource::ManifestFileVcpkgConfiguration:
175+
case ConfigurationSource::ManifestFileConfiguration:
175176
// reuse existing configuration
176177
configuration = current_configuration.config;
177178
break;

0 commit comments

Comments
 (0)