aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/src
diff options
context:
space:
mode:
authornicole mazzuca <mazzucan@outlook.com>2020-08-01 13:46:26 -0700
committerGitHub <noreply@github.com>2020-08-01 13:46:26 -0700
commitf225ba822b55a2ba9d3cc2a3c4e0646c8f47f035 (patch)
treed8454e9c65d547838773b2d1e39c074bd8ec48ab /toolsrc/src
parent54ec974afefae1864b423335ba8bcb64291d2317 (diff)
downloadvcpkg-f225ba822b55a2ba9d3cc2a3c4e0646c8f47f035.tar.gz
vcpkg-f225ba822b55a2ba9d3cc2a3c4e0646c8f47f035.zip
[vcpkg manifest] look at `platform` directives (#12548)
Fixes #12538
Diffstat (limited to 'toolsrc/src')
-rw-r--r--toolsrc/src/vcpkg/commands.setinstalled.cpp27
-rw-r--r--toolsrc/src/vcpkg/dependencies.cpp14
-rw-r--r--toolsrc/src/vcpkg/install.cpp42
-rw-r--r--toolsrc/src/vcpkg/portfileprovider.cpp56
4 files changed, 93 insertions, 46 deletions
diff --git a/toolsrc/src/vcpkg/commands.setinstalled.cpp b/toolsrc/src/vcpkg/commands.setinstalled.cpp
index 742a7a536..a99c3af4a 100644
--- a/toolsrc/src/vcpkg/commands.setinstalled.cpp
+++ b/toolsrc/src/vcpkg/commands.setinstalled.cpp
@@ -39,21 +39,10 @@ namespace vcpkg::Commands::SetInstalled
const PortFileProvider::PathsPortFileProvider& provider,
IBinaryProvider& binary_provider,
const CMakeVars::CMakeVarProvider& cmake_vars,
- const std::vector<FullPackageSpec>& specs,
- const Build::BuildPackageOptions& install_plan_options,
+ Dependencies::ActionPlan action_plan,
DryRun dry_run,
const Optional<fs::path>& maybe_pkgsconfig)
{
- // We have a set of user-requested specs.
- // We need to know all the specs which are required to fulfill dependencies for those specs.
- // Therefore, we see what we would install into an empty installed tree, so we can use the existing code.
- auto action_plan = Dependencies::create_feature_install_plan(provider, cmake_vars, specs, {});
-
- for (auto&& action : action_plan.install_actions)
- {
- action.build_options = install_plan_options;
- }
-
cmake_vars.load_tag_vars(action_plan, provider);
Build::compute_all_abis(paths, action_plan, cmake_vars, {});
@@ -155,13 +144,23 @@ namespace vcpkg::Commands::SetInstalled
{
pkgsconfig = it_pkgsconfig->second;
}
+
+ // We have a set of user-requested specs.
+ // We need to know all the specs which are required to fulfill dependencies for those specs.
+ // Therefore, we see what we would install into an empty installed tree, so we can use the existing code.
+ auto action_plan = Dependencies::create_feature_install_plan(provider, *cmake_vars, specs, {});
+
+ for (auto&& action : action_plan.install_actions)
+ {
+ action.build_options = Build::default_build_package_options;
+ }
+
perform_and_exit_ex(args,
paths,
provider,
*binary_provider,
*cmake_vars,
- specs,
- vcpkg::Build::default_build_package_options,
+ std::move(action_plan),
dry_run ? DryRun::Yes : DryRun::No,
pkgsconfig);
}
diff --git a/toolsrc/src/vcpkg/dependencies.cpp b/toolsrc/src/vcpkg/dependencies.cpp
index e9af12929..d4757cfcc 100644
--- a/toolsrc/src/vcpkg/dependencies.cpp
+++ b/toolsrc/src/vcpkg/dependencies.cpp
@@ -627,7 +627,19 @@ namespace vcpkg::Dependencies
}
pgraph.install(feature_specs);
- return pgraph.serialize(options);
+ auto res = pgraph.serialize(options);
+
+ const auto is_manifest_spec = [](const auto& action) {
+ return action.spec.name() == PackageSpec::MANIFEST_NAME;
+ };
+
+ Util::erase_remove_if(res.install_actions, is_manifest_spec);
+
+ Checks::check_exit(VCPKG_LINE_INFO,
+ !std::any_of(res.remove_actions.begin(), res.remove_actions.end(), is_manifest_spec),
+ "\"default\" should never be installed");
+
+ return res;
}
void PackageGraph::mark_for_reinstall(const PackageSpec& first_remove_spec,
diff --git a/toolsrc/src/vcpkg/install.cpp b/toolsrc/src/vcpkg/install.cpp
index 053acb2ec..ec8eba8dd 100644
--- a/toolsrc/src/vcpkg/install.cpp
+++ b/toolsrc/src/vcpkg/install.cpp
@@ -743,48 +743,30 @@ namespace vcpkg::Install
if (paths.manifest_mode_enabled())
{
- std::error_code ec;
- const auto path_to_manifest = paths.manifest_root_dir / "vcpkg.json";
- auto res = Paragraphs::try_load_manifest(paths.get_filesystem(), "user manifest", path_to_manifest, ec);
-
- if (ec)
+ Optional<fs::path> pkgsconfig;
+ auto it_pkgsconfig = options.settings.find(OPTION_WRITE_PACKAGES_CONFIG);
+ if (it_pkgsconfig != options.settings.end())
{
- Checks::exit_with_message(VCPKG_LINE_INFO,
- "Failed to load manifest file (%s): %s\n",
- path_to_manifest.u8string(),
- ec.message());
+ pkgsconfig = fs::u8path(it_pkgsconfig->second);
}
std::vector<FullPackageSpec> specs;
- if (auto val = res.get())
- {
- for (auto& dep : (*val)->core_paragraph->dependencies)
- {
- specs.push_back(FullPackageSpec{
- {std::move(dep.name), default_triplet},
- std::move(dep.features),
- });
- }
- }
- else
- {
- print_error_message(res.error());
- Checks::exit_fail(VCPKG_LINE_INFO);
- }
+ specs.emplace_back(PackageSpec{PackageSpec::MANIFEST_NAME, default_triplet});
+ auto install_plan = Dependencies::create_feature_install_plan(provider, var_provider, specs, {});
- Optional<fs::path> pkgsconfig;
- auto it_pkgsconfig = options.settings.find(OPTION_WRITE_PACKAGES_CONFIG);
- if (it_pkgsconfig != options.settings.end())
+ for (InstallPlanAction& action : install_plan.install_actions)
{
- pkgsconfig = fs::u8path(it_pkgsconfig->second);
+ action.build_options = install_plan_options;
+ action.build_options.use_head_version = Build::UseHeadVersion::NO;
+ action.build_options.editable = Build::Editable::NO;
}
+
Commands::SetInstalled::perform_and_exit_ex(args,
paths,
provider,
*binaryprovider,
var_provider,
- specs,
- install_plan_options,
+ std::move(install_plan),
dry_run ? Commands::DryRun::Yes : Commands::DryRun::No,
pkgsconfig);
}
diff --git a/toolsrc/src/vcpkg/portfileprovider.cpp b/toolsrc/src/vcpkg/portfileprovider.cpp
index 707b763a4..c0538fdb8 100644
--- a/toolsrc/src/vcpkg/portfileprovider.cpp
+++ b/toolsrc/src/vcpkg/portfileprovider.cpp
@@ -29,6 +29,10 @@ namespace vcpkg::PortFileProvider
const std::vector<std::string>& ports_dirs_paths)
: filesystem(paths.get_filesystem())
{
+ if (paths.manifest_mode_enabled())
+ {
+ manifest = paths.manifest_root_dir / fs::u8path("vcpkg.json");
+ }
auto& fs = paths.get_filesystem();
for (auto&& overlay_path : ports_dirs_paths)
{
@@ -60,6 +64,38 @@ namespace vcpkg::PortFileProvider
ports_dirs.emplace_back(paths.ports);
}
+ const SourceControlFileLocation* PathsPortFileProvider::load_manifest_file() const
+ {
+ if (!manifest.empty())
+ {
+ std::error_code ec;
+ auto maybe_scf = Paragraphs::try_load_manifest(filesystem, "manifest", manifest, ec);
+ if (ec)
+ {
+ Checks::exit_with_message(
+ VCPKG_LINE_INFO, "Failed to read manifest file %s: %s", manifest.u8string(), ec.message());
+ }
+
+ if (auto scf = maybe_scf.get())
+ {
+ auto it = cache.emplace(std::piecewise_construct,
+ std::forward_as_tuple(PackageSpec::MANIFEST_NAME),
+ std::forward_as_tuple(std::move(*scf), manifest.parent_path()));
+ return &it.first->second;
+ }
+ else
+ {
+ vcpkg::print_error_message(maybe_scf.error());
+ Checks::exit_with_message(
+ VCPKG_LINE_INFO, "Error: Failed to load manifest file %s.", manifest.u8string());
+ }
+ }
+ else
+ {
+ return nullptr;
+ }
+ }
+
ExpectedS<const SourceControlFileLocation&> PathsPortFileProvider::get_control_file(const std::string& spec) const
{
auto cache_it = cache.find(spec);
@@ -68,6 +104,18 @@ namespace vcpkg::PortFileProvider
return cache_it->second;
}
+ if (spec == PackageSpec::MANIFEST_NAME)
+ {
+ if (auto p = load_manifest_file())
+ {
+ return *p;
+ }
+ else
+ {
+ Checks::unreachable(VCPKG_LINE_INFO);
+ }
+ }
+
for (auto&& ports_dir : ports_dirs)
{
// Try loading individual port
@@ -88,7 +136,7 @@ namespace vcpkg::PortFileProvider
{
vcpkg::print_error_message(maybe_scf.error());
Checks::exit_with_message(
- VCPKG_LINE_INFO, "Error: Failed to load port from %s", spec, ports_dir.u8string());
+ VCPKG_LINE_INFO, "Error: Failed to load port %s from %s", spec, ports_dir.u8string());
}
continue;
@@ -130,6 +178,12 @@ namespace vcpkg::PortFileProvider
// Reload cache with ports contained in all ports_dirs
cache.clear();
std::vector<const SourceControlFileLocation*> ret;
+
+ if (auto p = load_manifest_file())
+ {
+ ret.push_back(p);
+ }
+
for (auto&& ports_dir : ports_dirs)
{
// Try loading individual port