Skip to content

Commit ce99f4c

Browse files
authored
Move merging original_cwd into overlay directories into VcpkgPaths. (#1522)
This work is part of resolving microsoft/vcpkg#30942 / https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1979597 When overlay directories from the config were added in #743 this added a condition where VcpkgPaths took responsibility to tack on the relative path, transforming those paths that come from the config into absolute paths. I did not realize at the time that this block was repeating machinery already present in IOverlayProvider family. The difference is that, there, it always assumed the prefix would be original_cwd. As part of adding overlay-port-dirs, I needed to add the same kind of prefix handling as overlay-ports get, thus pointing this out to me. It doesn't make sense to keep two independent ways to do this, leaving two options: * Move the prefix stapling into VcpkgPaths (as done in this PR) * Move the prefix stapling related to configs down into OverlayPortProviderImpl I chose to move into VcpkgPaths for several reasons: * Plumbing the information about how to handle config paths correctly into OverlayPortProviderImpl would have added many many function parameters to large parts of the product that are only passing paths information around. * The decision to chdir in VcpkgPaths is a consideration *it* makes, and OverlayPortProviderImpl would be just as happy if the relative paths were left alone. (And in fact I think the right behavior in the future would be to remove this harmful chdir but that is not proposed right now) * Despite making VcpkgPaths do "more work" here, I actually argue that it makes the "VcpkgPaths big ball of mud" problem better, by removing parts of the code that need to consider original_cwd.
1 parent cfbdd3a commit ce99f4c

19 files changed

+80
-96
lines changed

include/vcpkg/commands.find.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#pragma once
22

3+
#include <vcpkg/base/fwd/files.h>
34
#include <vcpkg/base/fwd/optional.h>
45
#include <vcpkg/base/fwd/stringview.h>
56

@@ -14,7 +15,7 @@ namespace vcpkg
1415
bool full_description,
1516
bool enable_json,
1617
Optional<StringView> filter,
17-
View<std::string> overlay_ports);
18+
View<Path> overlay_ports);
1819
extern const CommandMetadata CommandFindMetadata;
1920
void command_find_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths);
2021
}

include/vcpkg/portfileprovider.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,9 @@ namespace vcpkg
7676

7777
std::unique_ptr<IBaselineProvider> make_baseline_provider(const RegistrySet& registry_set);
7878
std::unique_ptr<IFullVersionedPortfileProvider> make_versioned_portfile_provider(const RegistrySet& registry_set);
79-
std::unique_ptr<IFullOverlayProvider> make_overlay_provider(const ReadOnlyFilesystem& fs,
80-
const Path& original_cwd,
81-
View<std::string> overlay_ports);
79+
std::unique_ptr<IFullOverlayProvider> make_overlay_provider(const ReadOnlyFilesystem& fs, View<Path> overlay_ports);
8280
std::unique_ptr<IOverlayProvider> make_manifest_provider(const ReadOnlyFilesystem& fs,
83-
const Path& original_cwd,
84-
View<std::string> overlay_ports,
81+
View<Path> overlay_ports,
8582
const Path& manifest_path,
8683
std::unique_ptr<SourceControlFile>&& manifest_scf);
8784
}

include/vcpkg/vcpkgpaths.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,10 @@ namespace vcpkg
9898
private:
9999
const Path triplets;
100100
const Path community_triplets;
101-
std::vector<std::string> overlay_triplets;
101+
std::vector<Path> overlay_triplets;
102102

103103
public:
104-
std::vector<std::string> overlay_ports;
104+
std::vector<Path> overlay_ports;
105105

106106
std::string get_toolver_diagnostics() const;
107107

src/vcpkg/commands.build-external.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ namespace vcpkg
4747

4848
auto& fs = paths.get_filesystem();
4949
auto registry_set = paths.make_registry_set();
50-
PathsPortFileProvider provider(*registry_set, make_overlay_provider(fs, paths.original_cwd, overlays));
50+
PathsPortFileProvider provider(*registry_set, make_overlay_provider(fs, overlays));
5151
command_build_and_exit_ex(args, paths, host_triplet, build_options, spec, provider, null_build_logs_recorder());
5252
}
5353
}

src/vcpkg/commands.build.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,7 @@ namespace vcpkg
106106

107107
auto& fs = paths.get_filesystem();
108108
auto registry_set = paths.make_registry_set();
109-
PathsPortFileProvider provider(*registry_set,
110-
make_overlay_provider(fs, paths.original_cwd, paths.overlay_ports));
109+
PathsPortFileProvider provider(*registry_set, make_overlay_provider(fs, paths.overlay_ports));
111110
Checks::exit_with_code(VCPKG_LINE_INFO,
112111
command_build_ex(args,
113112
paths,

src/vcpkg/commands.check-support.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,7 @@ namespace vcpkg
128128

129129
auto& fs = paths.get_filesystem();
130130
auto registry_set = paths.make_registry_set();
131-
PathsPortFileProvider provider(*registry_set,
132-
make_overlay_provider(fs, paths.original_cwd, paths.overlay_ports));
131+
PathsPortFileProvider provider(*registry_set, make_overlay_provider(fs, paths.overlay_ports));
133132
auto cmake_vars = CMakeVars::make_triplet_cmake_var_provider(paths);
134133

135134
// for each spec in the user-requested specs, check all dependencies

src/vcpkg/commands.ci.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,8 +375,7 @@ namespace vcpkg
375375
build_logs_recorder_storage ? *(build_logs_recorder_storage.get()) : null_build_logs_recorder();
376376

377377
auto registry_set = paths.make_registry_set();
378-
PathsPortFileProvider provider(*registry_set,
379-
make_overlay_provider(filesystem, paths.original_cwd, paths.overlay_ports));
378+
PathsPortFileProvider provider(*registry_set, make_overlay_provider(filesystem, paths.overlay_ports));
380379
auto var_provider_storage = CMakeVars::make_triplet_cmake_var_provider(paths);
381380
auto& var_provider = *var_provider_storage;
382381

src/vcpkg/commands.depend-info.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -409,8 +409,7 @@ namespace vcpkg
409409

410410
auto& fs = paths.get_filesystem();
411411
auto registry_set = paths.make_registry_set();
412-
PathsPortFileProvider provider(*registry_set,
413-
make_overlay_provider(fs, paths.original_cwd, paths.overlay_ports));
412+
PathsPortFileProvider provider(*registry_set, make_overlay_provider(fs, paths.overlay_ports));
414413
auto var_provider_storage = CMakeVars::make_triplet_cmake_var_provider(paths);
415414
auto& var_provider = *var_provider_storage;
416415

src/vcpkg/commands.env.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@ namespace vcpkg
8080
const ParsedArguments options = args.parse_arguments(CommandEnvMetadata);
8181

8282
auto registry_set = paths.make_registry_set();
83-
PathsPortFileProvider provider(*registry_set,
84-
make_overlay_provider(fs, paths.original_cwd, paths.overlay_ports));
83+
PathsPortFileProvider provider(*registry_set, make_overlay_provider(fs, paths.overlay_ports));
8584
auto var_provider_storage = CMakeVars::make_triplet_cmake_var_provider(paths);
8685
auto& var_provider = *var_provider_storage;
8786

src/vcpkg/commands.export.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -602,8 +602,7 @@ namespace vcpkg
602602
// Load ports from ports dirs
603603
auto& fs = paths.get_filesystem();
604604
auto registry_set = paths.make_registry_set();
605-
PathsPortFileProvider provider(*registry_set,
606-
make_overlay_provider(fs, paths.original_cwd, paths.overlay_ports));
605+
PathsPortFileProvider provider(*registry_set, make_overlay_provider(fs, paths.overlay_ports));
607606

608607
// create the plan
609608
std::vector<ExportPlanAction> export_plan = create_export_plan(opts.specs, status_db);

0 commit comments

Comments
 (0)