Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions include/vcpkg/archives.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,4 @@ namespace vcpkg
Optional<Path> seven_zip;
#endif
};

std::vector<ExpectedL<Unit>> decompress_in_parallel(View<Command> jobs);
}
5 changes: 2 additions & 3 deletions include/vcpkg/base/files.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ namespace vcpkg

virtual std::vector<Path> get_files_recursive(const Path& dir, std::error_code& ec) const = 0;
std::vector<Path> get_files_recursive(const Path& dir, LineInfo li) const;
ExpectedL<std::vector<Path>> try_get_files_recursive(const Path& dir) const;
Optional<std::vector<Path>> try_get_files_recursive(DiagnosticContext& context, const Path& dir) const;

virtual std::vector<Path> get_files_recursive_lexically_proximate(const Path& dir,
std::error_code& ec) const = 0;
Expand Down Expand Up @@ -325,8 +325,7 @@ namespace vcpkg
virtual int64_t last_write_time(const Path& target, std::error_code& ec) const = 0;
int64_t last_write_time(const Path& target, LineInfo li) const noexcept;

virtual void last_write_time(const Path& target, int64_t new_time, std::error_code& ec) const = 0;
void last_write_time(const Path& target, int64_t new_time, LineInfo li) const noexcept;
virtual bool last_write_time(DiagnosticContext& context, const Path& target, int64_t new_time) const = 0;

using ReadOnlyFilesystem::current_path;
virtual void current_path(const Path& new_current_path, std::error_code&) const = 0;
Expand Down
4 changes: 3 additions & 1 deletion include/vcpkg/base/message-data.inc.h
Original file line number Diff line number Diff line change
Expand Up @@ -1268,6 +1268,7 @@ DECLARE_MESSAGE(ExportedZipArchive, (msg::path), "", "Zip archive exported at: {
DECLARE_MESSAGE(ExportingAlreadyBuiltPackages, (), "", "The following packages are already built and will be exported:")
DECLARE_MESSAGE(ExportingPackage, (msg::package_name), "", "Exporting {package_name}...")
DECLARE_MESSAGE(ExtendedDocumentationAtUrl, (msg::url), "", "Extended documentation available at '{url}'.")
DECLARE_MESSAGE(ExtractedInto, (msg::path), "", "extracted into {path}")
DECLARE_MESSAGE(ExtractHelp, (), "", "Extracts an archive.")
DECLARE_MESSAGE(ExtractingTool, (msg::tool_name), "", "Extracting {tool_name}...")
DECLARE_MESSAGE(FailedPostBuildChecks,
Expand Down Expand Up @@ -2849,7 +2850,6 @@ DECLARE_MESSAGE(TwoFeatureFlagsSpecified,
(msg::value),
"'{value}' is a feature flag.",
"Both '{value}' and -'{value}' were specified as feature flags.")
DECLARE_MESSAGE(UnableToClearPath, (msg::path), "", "unable to delete {path}")
DECLARE_MESSAGE(UnableToReadAppDatas, (), "", "both %LOCALAPPDATA% and %APPDATA% were unreadable")
DECLARE_MESSAGE(UnableToReadEnvironmentVariable, (msg::env_var), "", "unable to read {env_var}")
DECLARE_MESSAGE(UndeterminedToolChainForTriplet,
Expand Down Expand Up @@ -3348,11 +3348,13 @@ DECLARE_MESSAGE(WaitUntilPackagesUploaded,
"",
"Waiting for {count} remaining binary cache submissions...")
DECLARE_MESSAGE(WarningsTreatedAsErrors, (), "", "previous warnings being interpreted as errors")
DECLARE_MESSAGE(WhileClearingThis, (), "", "while clearing this directory")
DECLARE_MESSAGE(WhileCheckingOutBaseline, (msg::commit_sha), "", "while checking out baseline {commit_sha}")
DECLARE_MESSAGE(WhileCheckingOutPortTreeIsh,
(msg::package_name, msg::git_tree_sha),
"",
"while checking out port {package_name} with git tree {git_tree_sha}")
DECLARE_MESSAGE(WhileExtractingThisArchive, (), "", "while extracting this archive")
DECLARE_MESSAGE(WhileGettingLocalTreeIshObjectsForPorts, (), "", "while getting local treeish objects for ports")
DECLARE_MESSAGE(WhileLookingForSpec, (msg::spec), "", "while looking for {spec}:")
DECLARE_MESSAGE(WhileLoadingBaselineVersionForPort,
Expand Down
6 changes: 0 additions & 6 deletions include/vcpkg/base/parallel-algorithms.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,4 @@ namespace vcpkg
{
execute_in_parallel(c.size(), [&](size_t offset) { cb(c[offset]); });
}

template<class Container, class RanItTarget, class F>
void parallel_transform(const Container& c, RanItTarget out_begin, F cb) noexcept
{
execute_in_parallel(c.size(), [&](size_t offset) { out_begin[offset] = cb(c[offset]); });
}
}
4 changes: 0 additions & 4 deletions include/vcpkg/base/system.process.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,6 @@ namespace vcpkg
settings);
}

std::vector<ExpectedL<ExitCodeAndOutput>> cmd_execute_and_capture_output_parallel(View<Command> commands);
std::vector<ExpectedL<ExitCodeAndOutput>> cmd_execute_and_capture_output_parallel(
View<Command> commands, const RedirectedProcessLaunchSettings& settings);

Optional<ExitCodeIntegral> cmd_execute_and_stream_lines(DiagnosticContext& context,
const Command& cmd,
const std::function<void(StringView)>& per_line_cb);
Expand Down
6 changes: 4 additions & 2 deletions locales/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,8 @@
"ExtendedDocumentationAtUrl": "Extended documentation available at '{url}'.",
"_ExtendedDocumentationAtUrl.comment": "An example of {url} is https://github.com/microsoft/vcpkg.",
"ExtractHelp": "Extracts an archive.",
"ExtractedInto": "extracted into {path}",
"_ExtractedInto.comment": "An example of {path} is /foo/bar.",
"ExtractingTool": "Extracting {tool_name}...",
"_ExtractingTool.comment": "An example of {tool_name} is signtool.",
"FailedPostBuildChecks": "Found {count} post-build check problem(s). These are usually caused by bugs in portfile.cmake or the upstream build system. Please correct these before submitting this port to the curated registry.",
Expand Down Expand Up @@ -1499,8 +1501,6 @@
"TripletLabel": "Triplet:",
"TwoFeatureFlagsSpecified": "Both '{value}' and -'{value}' were specified as feature flags.",
"_TwoFeatureFlagsSpecified.comment": "'{value}' is a feature flag.",
"UnableToClearPath": "unable to delete {path}",
"_UnableToClearPath.comment": "An example of {path} is /foo/bar.",
"UnableToReadAppDatas": "both %LOCALAPPDATA% and %APPDATA% were unreadable",
"UnableToReadEnvironmentVariable": "unable to read {env_var}",
"_UnableToReadEnvironmentVariable.comment": "An example of {env_var} is VCPKG_DEFAULT_TRIPLET.",
Expand Down Expand Up @@ -1755,6 +1755,8 @@
"_WhileCheckingOutBaseline.comment": "An example of {commit_sha} is 7cfad47ae9f68b183983090afd6337cd60fd4949.",
"WhileCheckingOutPortTreeIsh": "while checking out port {package_name} with git tree {git_tree_sha}",
"_WhileCheckingOutPortTreeIsh.comment": "An example of {package_name} is zlib. An example of {git_tree_sha} is 7cfad47ae9f68b183983090afd6337cd60fd4949.",
"WhileClearingThis": "while clearing this directory",
"WhileExtractingThisArchive": "while extracting this archive",
"WhileGettingLocalTreeIshObjectsForPorts": "while getting local treeish objects for ports",
"WhileLoadingBaselineVersionForPort": "while loading baseline version for {package_name}",
"_WhileLoadingBaselineVersionForPort.comment": "An example of {package_name} is zlib.",
Expand Down
28 changes: 0 additions & 28 deletions src/vcpkg-test/system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,34 +134,6 @@ TEST_CASE ("cmdlinebuilder", "[system]")
#endif
}

TEST_CASE ("cmd_execute_and_capture_output_parallel", "[system]")
{
std::vector<Command> vec;
for (size_t i = 0; i < 50; ++i)
{
#if defined(_WIN32)
vec.push_back(Command("cmd.exe").string_arg("/d").string_arg("/c").string_arg(fmt::format("echo {}", i)));
#else
vec.push_back(Command("echo").string_arg(std::string(i, 'a')));
#endif
}

auto res = cmd_execute_and_capture_output_parallel(vec);

for (size_t i = 0; i != res.size(); ++i)
{
auto out = res[i].get();
REQUIRE(out != nullptr);
REQUIRE(out->exit_code == 0);

#if defined(_WIN32)
REQUIRE(out->output == (fmt::format("{}\r\n", i)));
#else
REQUIRE(out->output == (std::string(i, 'a') + "\n"));
#endif
}
}

TEST_CASE ("append_shell_escaped", "[system]")
{
Command cmd;
Expand Down
15 changes: 0 additions & 15 deletions src/vcpkg/archives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,19 +368,4 @@ namespace vcpkg
#endif
return cmd;
}

std::vector<ExpectedL<Unit>> decompress_in_parallel(View<Command> jobs)
{
RedirectedProcessLaunchSettings settings;
settings.environment = get_clean_environment();
auto results = cmd_execute_and_capture_output_parallel(jobs, settings);
std::vector<ExpectedL<Unit>> filtered_results;
filtered_results.reserve(jobs.size());
for (std::size_t idx = 0; idx < jobs.size(); ++idx)
{
filtered_results.push_back(flatten(results[idx], jobs[idx].command_line()));
}

return filtered_results;
}
}
56 changes: 40 additions & 16 deletions src/vcpkg/base/files.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1664,16 +1664,23 @@ namespace vcpkg

std::vector<Path> ReadOnlyFilesystem::get_files_recursive(const Path& dir, LineInfo li) const
{
return this->try_get_files_recursive(dir).value_or_exit(li);
return this->try_get_files_recursive(console_diagnostic_context, dir).value_or_exit(li);
}

ExpectedL<std::vector<Path>> ReadOnlyFilesystem::try_get_files_recursive(const Path& dir) const
Optional<std::vector<Path>> ReadOnlyFilesystem::try_get_files_recursive(DiagnosticContext& context,
const Path& dir) const
{
std::error_code ec;
auto maybe_files = this->get_files_recursive(dir, ec);
if (ec)
{
return format_filesystem_call_error(ec, __func__, {dir});
context.report(DiagnosticLine{DiagKind::Error,
dir,
msg::format(msgSystemApiErrorMessage,
msg::system_api = "get_files_recursive",
msg::exit_code = ec.value(),
msg::error_msg = ec.message())});
return nullopt;
}

return maybe_files;
Expand Down Expand Up @@ -2279,16 +2286,6 @@ namespace vcpkg
return result;
}

void Filesystem::last_write_time(const Path& target, int64_t new_time, vcpkg::LineInfo li) const noexcept
{
std::error_code ec;
this->last_write_time(target, new_time, ec);
if (ec)
{
exit_filesystem_call_error(li, ec, __func__, {target});
}
}

void Filesystem::write_lines(const Path& file_path, const std::vector<std::string>& lines, LineInfo li) const
{
std::error_code ec;
Expand Down Expand Up @@ -3926,29 +3923,56 @@ namespace vcpkg
#endif // ^^^ !_WIN32
}

void last_write_time(const Path& target, int64_t new_time, std::error_code& ec) const override
virtual bool last_write_time(DiagnosticContext& context, const Path& target, int64_t new_time) const override
{
std::error_code ec;
#if defined(_WIN32)
stdfs::last_write_time(to_stdfs_path(target),
stdfs::file_time_type::time_point{stdfs::file_time_type::time_point::duration {
new_time
}},
ec);
if (ec)
{
context.report(DiagnosticLine{DiagKind::Error,
target,
msg::format(msgSystemApiErrorMessage,
msg::system_api = "std::fs::last_write_time",
msg::exit_code = ec.value(),
msg::error_msg = ec.message())});
return false;
}

return true;
#else // ^^^ _WIN32 // !_WIN32 vvv
PosixFd fd(target.c_str(), O_WRONLY, ec);
if (ec)
{
return;
context.report(DiagnosticLine{DiagKind::Error,
target,
msg::format(msgSystemApiErrorMessage,
msg::system_api = "open",
msg::exit_code = ec.value(),
msg::error_msg = ec.message())});
return false;
}
timespec times[2]; // last access and modification time
times[0].tv_nsec = UTIME_OMIT;
times[1].tv_nsec = new_time % 1'000'000'000;
times[1].tv_sec = new_time / 1'000'000'000;
if (futimens(fd.get(), times))
{
ec.assign(errno, std::system_category());
auto local_errno = errno;
context.report(
DiagnosticLine{DiagKind::Error,
target,
msg::format(msgSystemApiErrorMessage,
msg::system_api = "futimens",
msg::exit_code = local_errno,
msg::error_msg = std::system_category().message(local_errno))});
}

return true;
#endif // ^^^ !_WIN32
}

Expand Down
18 changes: 0 additions & 18 deletions src/vcpkg/base/system.process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include <vcpkg/base/chrono.h>
#include <vcpkg/base/contractual-constants.h>
#include <vcpkg/base/files.h>
#include <vcpkg/base/parallel-algorithms.h>
#include <vcpkg/base/parse.h>
#include <vcpkg/base/strings.h>
#include <vcpkg/base/system.debug.h>
Expand Down Expand Up @@ -746,23 +745,6 @@ namespace vcpkg
static const Environment clean_env = get_modified_clean_environment({});
return clean_env;
}

std::vector<ExpectedL<ExitCodeAndOutput>> cmd_execute_and_capture_output_parallel(View<Command> commands)
{
RedirectedProcessLaunchSettings default_redirected_process_launch_settings;
return cmd_execute_and_capture_output_parallel(commands, default_redirected_process_launch_settings);
}

std::vector<ExpectedL<ExitCodeAndOutput>> cmd_execute_and_capture_output_parallel(
View<Command> commands, const RedirectedProcessLaunchSettings& settings)
{
std::vector<ExpectedL<ExitCodeAndOutput>> res(commands.size(), LocalizedString{});

parallel_transform(
commands, res.begin(), [&](const Command& cmd) { return cmd_execute_and_capture_output(cmd, settings); });

return res;
}
} // namespace vcpkg

namespace
Expand Down
Loading
Loading