[vcpkg manifest] add feature support (#12549)

This commit is contained in:
nicole mazzuca 2020-08-01 16:45:00 -07:00 committed by GitHub
parent 80d8bf5b72
commit d6565e146c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 53 additions and 8 deletions

View File

@ -308,13 +308,23 @@ if(VCPKG_MANIFEST_MODE AND VCPKG_MANIFEST_INSTALL AND NOT _CMAKE_IN_TRY_COMPILE)
message(STATUS "Running vcpkg install")
set(_VCPKG_MANIFEST_FEATURES)
foreach(feature ${VCPKG_MANIFEST_FEATURES})
list(APPEND _VCPKG_MANIFEST_FEATURES "--x-feature=${feature}")
endforeach()
if(VCPKG_MANIFEST_NO_DEFAULT_FEATURES)
set(_VCPKG_MANIFEST_NO_DEFAULT_FEATURES "--x-no-default-features")
endif()
execute_process(
COMMAND "${_VCPKG_EXECUTABLE}" install
--triplet ${VCPKG_TARGET_TRIPLET}
--vcpkg-root ${_VCPKG_ROOT_DIR}
--x-manifest-root=${_VCPKG_MANIFEST_DIR}
--x-install-root=${_VCPKG_INSTALLED_DIR}
--binarycaching
--triplet "${VCPKG_TARGET_TRIPLET}"
--vcpkg-root "${_VCPKG_ROOT_DIR}"
"--x-manifest-root=${_VCPKG_MANIFEST_DIR}"
"--x-install-root=${_VCPKG_INSTALLED_DIR}"
${_VCPKG_MANIFEST_FEATURES}
${_VCPKG_MANIFEST_NO_DEFAULT_FEATURES}
RESULT_VARIABLE _VCPKG_INSTALL_RESULT)
if (NOT _VCPKG_INSTALL_RESULT EQUAL 0)
@ -405,7 +415,7 @@ macro(${VCPKG_OVERRIDE_FIND_PACKAGE_NAME} name)
set(Boost_COMPILER "-vc120")
else()
set(Boost_COMPILER "-vc140")
endif()
endif()
_find_package(${ARGV})
elseif("${name}" STREQUAL "ICU" AND EXISTS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include/unicode/utf.h")
function(_vcpkg_find_in_list)

View File

@ -512,6 +512,8 @@ namespace vcpkg::Install
static constexpr StringLiteral OPTION_USE_ARIA2 = "x-use-aria2";
static constexpr StringLiteral OPTION_CLEAN_AFTER_BUILD = "clean-after-build";
static constexpr StringLiteral OPTION_WRITE_PACKAGES_CONFIG = "x-write-nuget-packages-config";
static constexpr StringLiteral OPTION_MANIFEST_NO_DEFAULT_FEATURES = "x-no-default-features";
static constexpr StringLiteral OPTION_MANIFEST_FEATURE = "x-feature";
static constexpr std::array<CommandSwitch, 9> INSTALL_SWITCHES = {{
{OPTION_DRY_RUN, "Do not actually build or install"},
@ -524,6 +526,19 @@ namespace vcpkg::Install
{OPTION_USE_ARIA2, "Use aria2 to perform download tasks"},
{OPTION_CLEAN_AFTER_BUILD, "Clean buildtrees, packages and downloads after building each package"},
}};
static constexpr std::array<CommandSwitch, 10> MANIFEST_INSTALL_SWITCHES = {{
{OPTION_DRY_RUN, "Do not actually build or install"},
{OPTION_USE_HEAD_VERSION, "Install the libraries on the command line using the latest upstream sources"},
{OPTION_NO_DOWNLOADS, "Do not download new sources"},
{OPTION_ONLY_DOWNLOADS, "Download sources but don't build packages"},
{OPTION_RECURSE, "Allow removal of packages as part of installation"},
{OPTION_KEEP_GOING, "Continue installing packages on failure"},
{OPTION_EDITABLE, "Disable source re-extraction and binary caching for libraries on the command line"},
{OPTION_USE_ARIA2, "Use aria2 to perform download tasks"},
{OPTION_CLEAN_AFTER_BUILD, "Clean buildtrees, packages and downloads after building each package"},
{OPTION_MANIFEST_NO_DEFAULT_FEATURES, "Don't install the default features from the manifest."},
}};
static constexpr std::array<CommandSetting, 2> INSTALL_SETTINGS = {{
{OPTION_XUNIT, "File to output results in XUnit format (Internal use)"},
{OPTION_WRITE_PACKAGES_CONFIG,
@ -531,6 +546,10 @@ namespace vcpkg::Install
"binarycaching` for more information."},
}};
static constexpr std::array<CommandMultiSetting, 1> MANIFEST_INSTALL_MULTISETTINGS = {{
{OPTION_MANIFEST_FEATURE, "A feature from the manifest to install."},
}};
std::vector<std::string> get_all_port_names(const VcpkgPaths& paths)
{
auto sources_and_errors = Paragraphs::try_load_all_ports(paths.get_filesystem(), paths.ports);
@ -551,7 +570,7 @@ namespace vcpkg::Install
create_example_string("install --triplet x64-windows"),
0,
0,
{INSTALL_SWITCHES, INSTALL_SETTINGS},
{MANIFEST_INSTALL_SWITCHES, INSTALL_SETTINGS, MANIFEST_INSTALL_MULTISETTINGS},
nullptr,
};
@ -750,8 +769,24 @@ namespace vcpkg::Install
pkgsconfig = fs::u8path(it_pkgsconfig->second);
}
std::vector<std::string> features;
if (Util::Sets::contains(options.switches, OPTION_MANIFEST_NO_DEFAULT_FEATURES))
{
features.emplace_back("core");
}
auto manifest_feature_it = options.multisettings.find(OPTION_MANIFEST_FEATURE);
if (manifest_feature_it != options.multisettings.end())
{
for (const auto& feature : manifest_feature_it->second)
{
features.push_back(feature);
}
}
std::vector<FullPackageSpec> specs;
specs.emplace_back(PackageSpec{PackageSpec::MANIFEST_NAME, default_triplet});
specs.emplace_back(PackageSpec{PackageSpec::MANIFEST_NAME, default_triplet}, std::move(features));
auto install_plan = Dependencies::create_feature_install_plan(provider, var_provider, specs, {});
for (InstallPlanAction& action : install_plan.install_actions)