Add support for response files with vcpkg
Response files are a convenient way of specifying bulk parameters,
typically supported by compilers and linkers. For vcpkg response files
provide a convenient way of installing sets of packages from simple
newline separate list files.
MODIFY
src/vcpkg/help.cpp
src/vcpkg/help.cpp
@@ -116,6 +116,8 @@ namespace vcpkg::Help
" --vcpkg-root <path> Specify the vcpkg root directory\n"
" (default: " ENVVAR(VCPKG_ROOT) ")\n"
"\n"
+ " @response_file Specify a response file to provide additional parameters\n"
+ "\n"
"For more help (including examples) see the accompanying README.md.",
Commands::Integrate::INTEGRATE_COMMAND_HELPSTRING);
}

MODIFY
src/vcpkg/vcpkgcmdarguments.cpp
src/vcpkg/vcpkgcmdarguments.cpp
@@ -51,11 +51,29 @@ namespace vcpkg
std::vector<std::string> v;
for (int i = 1; i < argc; ++i)
{
+ std::string arg;
#if defined(_WIN32)
- v.push_back(Strings::to_utf8(argv[i]));
+ arg = Strings::to_utf8(argv[i]);
#else
- v.push_back(argv[i]);
+ arg = argv[i];
#endif
+ // Response file?
+ if (arg.size() > 0 && arg[0] == '@')
+ {
+ arg.erase(arg.begin());
+ const auto& fs = Files::get_real_filesystem();
+ auto lines = fs.read_lines(fs::u8path(arg));
+ if (!lines.has_value())
+ {
+ System::println(System::Color::error, "Error: Could not open response file %s", arg);
+ Checks::exit_fail(VCPKG_LINE_INFO);
+ }
+ std::copy(lines.get()->begin(), lines.get()->end(), std::back_inserter(v));
+ }
+ else
+ {
+ v.emplace_back(std::move(arg));
+ }
}
return VcpkgCmdArguments::create_from_arg_sequence(v.data(), v.data() + v.size());

Add support for response files with vcpkg (#4507)

Response files are a convenient way of specifying bulk parameters,
typically supported by compilers and linkers. For vcpkg response files
provide a convenient way of installing sets of packages from simple
newline separate list files.