Skip to content

[Export Command] Enabling Manifest Mode#1136

Merged
vicroms merged 6 commits intomicrosoft:mainfrom
JavierMatosD:export_enable_manifest
Aug 10, 2023
Merged

[Export Command] Enabling Manifest Mode#1136
vicroms merged 6 commits intomicrosoft:mainfrom
JavierMatosD:export_enable_manifest

Conversation

@JavierMatosD
Copy link
Copy Markdown
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: MicrosoftDocs/vcpkg-docs#116

@JavierMatosD JavierMatosD marked this pull request as draft July 21, 2023 22:32
Comment thread src/vcpkg/commands.export.cpp Outdated
Comment thread include/vcpkg/base/message-data.inc.h Outdated
Comment thread src/vcpkg/commands.export.cpp Outdated
Comment thread src/vcpkg/commands.export.cpp Outdated
Comment thread include/vcpkg/base/message-data.inc.h Outdated
Comment thread src/vcpkg/commands.export.cpp Outdated
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
Copy Markdown
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
Copy Markdown
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
@JavierMatosD JavierMatosD deleted the export_enable_manifest branch July 20, 2024 19:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants