Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Export Command] Enabling Manifest Mode #1136

Merged
merged 6 commits into from
Aug 10, 2023

Conversation

JavierMatosD
Copy link
Contributor

@JavierMatosD JavierMatosD commented Jul 21, 2023

This PR enables manifest mode for the vcpkg export command.

Summary of changes:

  • vcpkg export in manifest mode exports everything in the "vcpkg_installed" directory.
  • In manifest mode, the export command emmits an error and fails when port:triplet arguments are provided, as they are not allowed in manifest mode.
  • Added a guard to exit with an error message when the installed directory is empty. Previously, it just failed silently.
  • Made --output-dir mandatory in manifest mode.

Docs PR: microsoft/vcpkg-docs#116

@JavierMatosD JavierMatosD marked this pull request as draft July 21, 2023 22:32
src/vcpkg/commands.export.cpp Outdated Show resolved Hide resolved
include/vcpkg/base/message-data.inc.h Outdated Show resolved Hide resolved
src/vcpkg/commands.export.cpp Outdated Show resolved Hide resolved
src/vcpkg/commands.export.cpp Outdated Show resolved Hide resolved
include/vcpkg/base/message-data.inc.h Outdated Show resolved Hide resolved
src/vcpkg/commands.export.cpp Outdated Show resolved Hide resolved
Comment on lines +394 to +421
if (paths.manifest_mode_enabled())
{
auto output_dir_opt = Util::lookup_value(options.settings, OPTION_OUTPUT_DIR);

// --output-dir is required in manifest mode
if (auto d = output_dir_opt.get())
{
ret.output_dir = paths.original_cwd / *d;
}
else
{
msg::println_error(msgMissingOption, msg::option = "output-dir");
Checks::exit_fail(VCPKG_LINE_INFO);
}

// Force enable --all-installed in manifest mode
ret.all_installed = true;

// In manifest mode the entire installed directory is exported
if (!options.command_arguments.empty())
{
msg::println_error(msgUnexpectedArgument, msg::option = options.command_arguments[0]);
Checks::exit_fail(VCPKG_LINE_INFO);
}
}

ret.output_dir = ret.output_dir.empty() ? Util::lookup_value(options.settings, OPTION_OUTPUT_DIR)
.map([&](const Path& p) { return paths.original_cwd / p; })
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (paths.manifest_mode_enabled())
{
auto output_dir_opt = Util::lookup_value(options.settings, OPTION_OUTPUT_DIR);
// --output-dir is required in manifest mode
if (auto d = output_dir_opt.get())
{
ret.output_dir = paths.original_cwd / *d;
}
else
{
msg::println_error(msgMissingOption, msg::option = "output-dir");
Checks::exit_fail(VCPKG_LINE_INFO);
}
// Force enable --all-installed in manifest mode
ret.all_installed = true;
// In manifest mode the entire installed directory is exported
if (!options.command_arguments.empty())
{
msg::println_error(msgUnexpectedArgument, msg::option = options.command_arguments[0]);
Checks::exit_fail(VCPKG_LINE_INFO);
}
}
ret.output_dir = ret.output_dir.empty() ? Util::lookup_value(options.settings, OPTION_OUTPUT_DIR)
.map([&](const Path& p) { return paths.original_cwd / p; })
auto output_dir_arg = Util::lookup_value(options.settings, OPTION_OUTPUT_DIR);
if (paths.manifest_mode_enabled())
{
if (!output_dir_arg)
{
msg::println_error(msgMissingOption, msg::option = "output-dir");
Checks::exit_fail(VCPKG_LINE_INFO);
}
// Force enable --all-installed in manifest mode
ret.all_installed = true;
// In manifest mode the entire installed directory is exported
if (!options.command_arguments.empty())
{
msg::println_error(msgUnexpectedArgument, msg::option = options.command_arguments[0]);
Checks::exit_fail(VCPKG_LINE_INFO);
}
}
ret.output_dir = output_dir_arg.map([&](const Path& p) { return paths.original_cwd / p; }).value_or(paths.root);

Copy link
Member

@vicroms vicroms left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@vicroms vicroms merged commit c94e403 into microsoft:main Aug 10, 2023
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants