diff --git a/toolsrc/include/vcpkg/install.h b/toolsrc/include/vcpkg/install.h index 1c42cc102c13aa..c54f1a9e51db86 100644 --- a/toolsrc/include/vcpkg/install.h +++ b/toolsrc/include/vcpkg/install.h @@ -71,6 +71,12 @@ namespace vcpkg::Install std::vector get_all_port_names(const VcpkgPaths& paths); void install_files_and_write_listfile(Files::Filesystem& fs, const fs::path& source_dir, const InstallDir& dirs); + + void install_files_and_write_listfile(Files::Filesystem& fs, + const fs::path& source_dir, + const std::vector& files, + const InstallDir& destination_dir); + InstallResult install_package(const VcpkgPaths& paths, const BinaryControlFile& binary_paragraph, StatusParagraphs* status_db); diff --git a/toolsrc/src/vcpkg/export.cpp b/toolsrc/src/vcpkg/export.cpp index b41d88dc176fd1..da39c03da03e28 100644 --- a/toolsrc/src/vcpkg/export.cpp +++ b/toolsrc/src/vcpkg/export.cpp @@ -3,9 +3,9 @@ #include #include #include -#include #include #include +#include #include #include #include @@ -306,9 +306,6 @@ namespace vcpkg::Export static constexpr StringLiteral OPTION_PREFAB_ENABLE_MAVEN = "--prefab-maven"; static constexpr StringLiteral OPTION_PREFAB_ENABLE_DEBUG = "--prefab-debug"; - - - static constexpr std::array EXPORT_SWITCHES = {{ {OPTION_DRY_RUN, "Do not actually export"}, {OPTION_RAW, "Export to an uncompressed directory"}, @@ -336,7 +333,7 @@ namespace vcpkg::Export "Specify the maintainer for the exported Chocolatey package (experimental feature)"}, {OPTION_CHOCOLATEY_VERSION_SUFFIX, "Specify the version suffix to add for the exported Chocolatey package (experimental feature)"}, - {OPTION_PREFAB_GROUP_ID, "GroupId uniquely identifies your project according maven specifications"}, + {OPTION_PREFAB_GROUP_ID, "GroupId uniquely identifies your project according maven specifications"}, {OPTION_PREFAB_ARTIFACT_ID, "Artifact Id is the name of the project according maven specifications"}, {OPTION_PREFAB_VERSION, "Version is the name of the project according maven specifications"}, {OPTION_PREFAB_SDK_MIN_VERSION, "Android minimum supported sdk version"}, @@ -389,10 +386,12 @@ namespace vcpkg::Export }); } - if (!ret.raw && !ret.nuget && !ret.ifw && !ret.zip && !ret.seven_zip && !ret.dry_run && !ret.chocolatey && !ret.prefab) + if (!ret.raw && !ret.nuget && !ret.ifw && !ret.zip && !ret.seven_zip && !ret.dry_run && !ret.chocolatey && + !ret.prefab) { - System::print2(System::Color::error, - "Must provide at least one export type: --raw --nuget --ifw --zip --7zip --chocolatey --prefab\n"); + System::print2( + System::Color::error, + "Must provide at least one export type: --raw --nuget --ifw --zip --7zip --chocolatey --prefab\n"); System::print2(COMMAND_STRUCTURE.example_text); Checks::exit_fail(VCPKG_LINE_INFO); } @@ -512,7 +511,15 @@ namespace vcpkg::Export action.spec.triplet().to_string(), raw_exported_dir_path / "installed" / "vcpkg" / "info" / (binary_paragraph.fullstem() + ".list")); - Install::install_files_and_write_listfile(paths.get_filesystem(), paths.package_dir(action.spec), dirs); + auto lines = fs.read_lines(paths.listfile_path(binary_paragraph)).value_or_exit(VCPKG_LINE_INFO); + std::vector files; + for (auto&& suffix : lines) + { + if (!suffix.empty() && suffix.back() == '\r') suffix.pop_back(); + files.push_back(paths.installed / suffix); + } + + Install::install_files_and_write_listfile(fs, paths.installed, files, dirs); } // Copy files needed for integration @@ -641,7 +648,8 @@ With a project open, go to Tools->NuGet Package Manager->Package Manager Console Chocolatey::do_export(export_plan, paths, opts.chocolatey_options); } - if(opts.prefab){ + if (opts.prefab) + { Prefab::do_export(export_plan, paths, opts.prefab_options, default_triplet); } diff --git a/toolsrc/src/vcpkg/install.cpp b/toolsrc/src/vcpkg/install.cpp index 1b9b7db34d6aa7..3934e5e0f145e8 100644 --- a/toolsrc/src/vcpkg/install.cpp +++ b/toolsrc/src/vcpkg/install.cpp @@ -45,17 +45,25 @@ namespace vcpkg::Install void install_files_and_write_listfile(Files::Filesystem& fs, const fs::path& source_dir, const InstallDir& destination_dir) + { + Checks::check_exit( + VCPKG_LINE_INFO, fs.exists(source_dir), "Source directory %s does not exist", source_dir.generic_string()); + auto files = fs.get_files_recursive(source_dir); + install_files_and_write_listfile(fs, source_dir, files, destination_dir); + } + void install_files_and_write_listfile(Files::Filesystem& fs, + const fs::path& source_dir, + const std::vector& files, + const InstallDir& destination_dir) { std::vector output; std::error_code ec; - const size_t prefix_length = source_dir.native().size(); + const size_t prefix_length = source_dir.generic_u8string().size(); const fs::path& destination = destination_dir.destination(); const std::string& destination_subdirectory = destination_dir.destination_subdirectory(); const fs::path& listfile = destination_dir.listfile(); - Checks::check_exit( - VCPKG_LINE_INFO, fs.exists(source_dir), "Source directory %s does not exist", source_dir.generic_string()); fs.create_directories(destination, ec); Checks::check_exit( VCPKG_LINE_INFO, !ec, "Could not create destination directory %s", destination.generic_string()); @@ -65,7 +73,6 @@ namespace vcpkg::Install VCPKG_LINE_INFO, !ec, "Could not create directory for listfile %s", listfile.generic_string()); output.push_back(Strings::format(R"(%s/)", destination_subdirectory)); - auto files = fs.get_files_recursive(source_dir); for (auto&& file : files) { const auto status = fs.symlink_status(file, ec); @@ -298,9 +305,9 @@ namespace vcpkg::Install using Build::ExtendedBuildResult; static ExtendedBuildResult perform_install_plan_action(const VcpkgPaths& paths, - InstallPlanAction& action, - StatusParagraphs& status_db, - IBinaryProvider* binaries_provider) + InstallPlanAction& action, + StatusParagraphs& status_db, + IBinaryProvider* binaries_provider) { const InstallPlanType& plan_type = action.plan_type; const std::string display_name = action.spec.to_string(); @@ -731,7 +738,7 @@ namespace vcpkg::Install { const auto vs_prompt_view = to_zstring_view(vs_prompt); System::print2(vcpkg::System::Color::warning, - "warning: vcpkg appears to be in a Visual Studio prompt targeting ", + "warning: vcpkg appears to be in a Visual Studio prompt targeting ", vs_prompt_view, " but is installing packages for ", common_triplet.to_string(),