Skip to content

Commit

Permalink
Delete unused VcpkgPaths m_manifest_path and m_config_dir. (#1585)
Browse files Browse the repository at this point in the history
  • Loading branch information
BillyONeal authored Jan 27, 2025
1 parent fffdeb2 commit 987ba13
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 17 deletions.
13 changes: 7 additions & 6 deletions src/vcpkg/commands.install.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1033,8 +1033,9 @@ namespace vcpkg
Triplet default_triplet,
Triplet host_triplet)
{
const ParsedArguments options = args.parse_arguments(
paths.manifest_mode_enabled() ? CommandInstallMetadataManifest : CommandInstallMetadataClassic);
auto manifest = paths.get_manifest().get();
const ParsedArguments options =
args.parse_arguments(manifest ? CommandInstallMetadataManifest : CommandInstallMetadataClassic);

const bool dry_run = Util::Sets::contains(options.switches, SwitchDryRun);
const bool use_head_version = Util::Sets::contains(options.switches, (SwitchHead));
Expand All @@ -1061,9 +1062,9 @@ namespace vcpkg
: UnsupportedPortAction::Error;
const bool print_cmake_usage = !Util::Sets::contains(options.switches, SwitchNoPrintUsage);

get_global_metrics_collector().track_bool(BoolMetric::InstallManifestMode, paths.manifest_mode_enabled());
get_global_metrics_collector().track_bool(BoolMetric::InstallManifestMode, manifest);

if (auto p = paths.get_manifest().get())
if (manifest)
{
bool failure = false;
if (!options.command_arguments.empty())
Expand All @@ -1084,7 +1085,7 @@ namespace vcpkg
}
if (failure)
{
msg::println(msgUsingManifestAt, msg::path = p->path);
msg::println(msgUsingManifestAt, msg::path = manifest->path);
msg::print(usage_for_command(CommandInstallMetadataManifest));
Checks::exit_fail(VCPKG_LINE_INFO);
}
Expand Down Expand Up @@ -1141,7 +1142,7 @@ namespace vcpkg
auto var_provider_storage = CMakeVars::make_triplet_cmake_var_provider(paths);
auto& var_provider = *var_provider_storage;

if (auto manifest = paths.get_manifest().get())
if (manifest)
{
Optional<Path> pkgsconfig;
auto it_pkgsconfig = options.settings.find(SwitchXWriteNuGetPackagesConfig);
Expand Down
16 changes: 5 additions & 11 deletions src/vcpkg/vcpkgpaths.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -563,8 +563,6 @@ namespace vcpkg
, m_global_config(bundle.read_only ? get_user_configuration_home().value_or_exit(VCPKG_LINE_INFO) /
"vcpkg-configuration.json"
: root / "vcpkg-configuration.json")
, m_config_dir(m_manifest_dir.empty() ? root : m_manifest_dir)
, m_manifest_path(m_manifest_dir.empty() ? Path{} : m_manifest_dir / "vcpkg.json")
, m_registries_work_tree_dir(m_registries_cache / "git")
, m_registries_dot_git_dir(m_registries_cache / "git" / ".git")
, m_registries_git_trees(m_registries_cache / "git-trees")
Expand Down Expand Up @@ -645,8 +643,6 @@ namespace vcpkg
}

const Path m_global_config;
const Path m_config_dir;
const Path m_manifest_path;
const Path m_registries_work_tree_dir;
const Path m_registries_dot_git_dir;
const Path m_registries_git_trees;
Expand Down Expand Up @@ -688,18 +684,16 @@ namespace vcpkg
Debug::print("Using builtin-registry: ", builtin_registry_versions, '\n');
Debug::print("Using downloads-root: ", downloads, '\n');

const auto config_path = m_pimpl->m_config_dir / "vcpkg-configuration.json";
auto config_dir = m_pimpl->m_manifest_dir.empty() ? root : m_pimpl->m_manifest_dir;
const auto config_path = config_dir / "vcpkg-configuration.json";
auto maybe_manifest_config = config_from_manifest(m_pimpl->m_manifest_doc);
auto maybe_json_config =
filesystem.exists(config_path, IgnoreErrors{})
? parse_configuration(filesystem.read_contents(config_path, IgnoreErrors{}), config_path, out_sink)
: nullopt;

m_pimpl->m_config = merge_validate_configs(std::move(maybe_manifest_config),
m_pimpl->m_manifest_dir,
std::move(maybe_json_config),
m_pimpl->m_config_dir,
*this);
m_pimpl->m_config = merge_validate_configs(
std::move(maybe_manifest_config), m_pimpl->m_manifest_dir, std::move(maybe_json_config), config_dir, *this);
overlay_ports.overlay_ports = merge_overlays(m_pimpl->m_fs,
args.cli_overlay_ports,
args.env_overlay_ports,
Expand Down Expand Up @@ -1275,7 +1269,7 @@ namespace vcpkg
return nullopt;
}

bool VcpkgPaths::manifest_mode_enabled() const { return !m_pimpl->m_manifest_dir.empty(); }
bool VcpkgPaths::manifest_mode_enabled() const { return m_pimpl->m_manifest_doc.has_value(); }

const ConfigurationAndSource& VcpkgPaths::get_configuration() const { return m_pimpl->m_config; }

Expand Down

0 comments on commit 987ba13

Please # to comment.