diff options
| author | ras0219 <533828+ras0219@users.noreply.github.com> | 2020-08-10 10:22:51 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-08-10 10:22:51 -0700 |
| commit | 481738beaeb77bca19ff7fa01b4c02be7fc9deb2 (patch) | |
| tree | 00c985177f75b190abfc58f12600f293d10b5d25 /toolsrc/src | |
| parent | ed474ea9344a39d917e2b0719192502650cbd536 (diff) | |
| download | vcpkg-481738beaeb77bca19ff7fa01b4c02be7fc9deb2.tar.gz vcpkg-481738beaeb77bca19ff7fa01b4c02be7fc9deb2.zip | |
[vcpkg] Add `vcpkg export` to E2E tests. Enable E2E tests on all platforms. (#12198)
* [vcpkg] Add `vcpkg export` to E2E tests. Enable E2E tests on MacOS.
* [vcpkg] Fix export --raw --output-dir=/path/ by changing directory to new export root
Co-authored-by: Robert Schumacher <roschuma@microsoft.com>
Co-authored-by: Billy Robert O'Neal III <bion@microsoft.com>
Diffstat (limited to 'toolsrc/src')
| -rw-r--r-- | toolsrc/src/vcpkg/base/files.cpp | 2 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg/export.cpp | 70 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg/tools.cpp | 8 |
3 files changed, 57 insertions, 23 deletions
diff --git a/toolsrc/src/vcpkg/base/files.cpp b/toolsrc/src/vcpkg/base/files.cpp index f2684633c..59931603b 100644 --- a/toolsrc/src/vcpkg/base/files.cpp +++ b/toolsrc/src/vcpkg/base/files.cpp @@ -1041,7 +1041,7 @@ namespace vcpkg::Files return res; } - System::printf("Waiting to take filesystem lock on %s...\n", path.u8string()); + Debug::print("Waiting to take filesystem lock on ", path.u8string(), "...\n"); auto wait = std::chrono::milliseconds(100); // waits, at most, a second and a half. while (wait < std::chrono::milliseconds(1000)) diff --git a/toolsrc/src/vcpkg/export.cpp b/toolsrc/src/vcpkg/export.cpp index 10d79195f..a124345a7 100644 --- a/toolsrc/src/vcpkg/export.cpp +++ b/toolsrc/src/vcpkg/export.cpp @@ -150,13 +150,19 @@ namespace vcpkg::Export fs.write_contents(nuspec_file_path, nuspec_file_content, VCPKG_LINE_INFO); // -NoDefaultExcludes is needed for ".vcpkg-root" - const auto cmd_line = Strings::format(R"("%s" pack -OutputDirectory "%s" "%s" -NoDefaultExcludes)", - nuget_exe.u8string(), - output_dir.u8string(), - nuspec_file_path.u8string()); + System::CmdLineBuilder cmd; +#ifndef _WIN32 + cmd.path_arg(paths.get_tool_exe(Tools::MONO)); +#endif + cmd.path_arg(nuget_exe) + .string_arg("pack") + .path_arg(nuspec_file_path) + .string_arg("-OutputDirectory") + .path_arg(output_dir) + .string_arg("-NoDefaultExcludes"); const int exit_code = - System::cmd_execute_and_capture_output(cmd_line, System::get_clean_environment()).exit_code; + System::cmd_execute_and_capture_output(cmd.extract(), System::get_clean_environment()).exit_code; Checks::check_exit(VCPKG_LINE_INFO, exit_code == 0, "Error: NuGet package creation failed"); const fs::path output_path = output_dir / (nuget_id + "." + nuget_version + ".nupkg"); @@ -206,14 +212,26 @@ namespace vcpkg::Export Strings::format("%s.%s", exported_dir_filename, format.extension()); const fs::path exported_archive_path = (output_dir / exported_archive_filename); - // -NoDefaultExcludes is needed for ".vcpkg-root" - const auto cmd_line = Strings::format(R"("%s" -E tar "cf" "%s" --format=%s -- "%s")", - cmake_exe.u8string(), - exported_archive_path.u8string(), - format.cmake_option(), - raw_exported_dir.u8string()); + System::CmdLineBuilder cmd; + cmd.string_arg("cd").path_arg(raw_exported_dir.parent_path()); + cmd.ampersand(); + cmd.path_arg(cmake_exe) + .string_arg("-E") + .string_arg("tar") + .string_arg("cf") + .path_arg(exported_archive_path) + .string_arg(Strings::concat("--format=", format.cmake_option())) + .string_arg("--") + .path_arg(raw_exported_dir); + + auto cmdline = cmd.extract(); +#ifdef WIN32 + // Invoke through `cmd` to support `&&` + cmdline.insert(0, "cmd /c \""); + cmdline.push_back('"'); +#endif - const int exit_code = System::cmd_execute_clean(cmd_line); + const int exit_code = System::cmd_execute_clean(cmdline); Checks::check_exit( VCPKG_LINE_INFO, exit_code == 0, "Error: %s creation failed", exported_archive_path.generic_string()); return exported_archive_path; @@ -262,6 +280,7 @@ namespace vcpkg::Export bool all_installed = false; Optional<std::string> maybe_output; + fs::path output_dir; Optional<std::string> maybe_nuget_id; Optional<std::string> maybe_nuget_version; @@ -273,6 +292,7 @@ namespace vcpkg::Export }; static constexpr StringLiteral OPTION_OUTPUT = "output"; + static constexpr StringLiteral OPTION_OUTPUT_DIR = "output-dir"; static constexpr StringLiteral OPTION_DRY_RUN = "dry-run"; static constexpr StringLiteral OPTION_RAW = "raw"; static constexpr StringLiteral OPTION_NUGET = "nuget"; @@ -314,8 +334,9 @@ namespace vcpkg::Export {OPTION_ALL_INSTALLED, "Export all installed packages"}, }}; - static constexpr std::array<CommandSetting, 15> EXPORT_SETTINGS = {{ + static constexpr std::array<CommandSetting, 16> EXPORT_SETTINGS = {{ {OPTION_OUTPUT, "Specify the output name (used to construct filename)"}, + {OPTION_OUTPUT_DIR, "Specify the output directory for produced artifacts"}, {OPTION_NUGET_ID, "Specify the id for the exported NuGet package (overrides --output)"}, {OPTION_NUGET_VERSION, "Specify the version for the exported NuGet package"}, {OPTION_IFW_REPOSITORY_URL, "Specify the remote repository URL for the online installer"}, @@ -342,7 +363,8 @@ namespace vcpkg::Export nullptr, }; - static ExportArguments handle_export_command_arguments(const VcpkgCmdArguments& args, + static ExportArguments handle_export_command_arguments(const VcpkgPaths& paths, + const VcpkgCmdArguments& args, Triplet default_triplet, const StatusParagraphs& status_db) { @@ -361,6 +383,15 @@ namespace vcpkg::Export ret.prefab_options.enable_maven = options.switches.find(OPTION_PREFAB_ENABLE_MAVEN) != options.switches.cend(); ret.prefab_options.enable_debug = options.switches.find(OPTION_PREFAB_ENABLE_DEBUG) != options.switches.cend(); ret.maybe_output = maybe_lookup(options.settings, OPTION_OUTPUT); + auto maybe_output_dir = maybe_lookup(options.settings, OPTION_OUTPUT_DIR); + if (auto output_dir = maybe_output_dir.get()) + { + ret.output_dir = Files::combine(paths.original_cwd, fs::u8path(*output_dir)); + } + else + { + ret.output_dir = paths.root; + } ret.all_installed = options.switches.find(OPTION_ALL_INSTALLED) != options.switches.end(); if (ret.all_installed) @@ -479,8 +510,7 @@ namespace vcpkg::Export const VcpkgPaths& paths) { Files::Filesystem& fs = paths.get_filesystem(); - const fs::path export_to_path = paths.root; - const fs::path raw_exported_dir_path = export_to_path / export_id; + const fs::path raw_exported_dir_path = opts.output_dir / export_id; fs.remove_all(raw_exported_dir_path, VCPKG_LINE_INFO); // TODO: error handling @@ -538,7 +568,7 @@ namespace vcpkg::Export const std::string nuget_id = opts.maybe_nuget_id.value_or(raw_exported_dir_path.filename().string()); const std::string nuget_version = opts.maybe_nuget_version.value_or("1.0.0"); const fs::path output_path = - do_nuget_export(paths, nuget_id, nuget_version, raw_exported_dir_path, export_to_path); + do_nuget_export(paths, nuget_id, nuget_version, raw_exported_dir_path, opts.output_dir); System::print2(System::Color::success, "NuGet package exported at: ", output_path.u8string(), "\n"); System::printf(R"( @@ -554,7 +584,7 @@ With a project open, go to Tools->NuGet Package Manager->Package Manager Console { System::print2("Creating zip archive...\n"); const fs::path output_path = - do_archive_export(paths, raw_exported_dir_path, export_to_path, ArchiveFormatC::ZIP); + do_archive_export(paths, raw_exported_dir_path, opts.output_dir, ArchiveFormatC::ZIP); System::print2(System::Color::success, "Zip archive exported at: ", output_path.u8string(), "\n"); print_next_step_info("[...]"); } @@ -563,7 +593,7 @@ With a project open, go to Tools->NuGet Package Manager->Package Manager Console { System::print2("Creating 7zip archive...\n"); const fs::path output_path = - do_archive_export(paths, raw_exported_dir_path, export_to_path, ArchiveFormatC::SEVEN_ZIP); + do_archive_export(paths, raw_exported_dir_path, opts.output_dir, ArchiveFormatC::SEVEN_ZIP); System::print2(System::Color::success, "7zip archive exported at: ", output_path.u8string(), "\n"); print_next_step_info("[...]"); } @@ -584,7 +614,7 @@ With a project open, go to Tools->NuGet Package Manager->Package Manager Console "may use export in classic mode by running vcpkg outside of a manifest-based project."); } const StatusParagraphs status_db = database_load_check(paths); - const auto opts = handle_export_command_arguments(args, default_triplet, status_db); + const auto opts = handle_export_command_arguments(paths, args, default_triplet, status_db); for (auto&& spec : opts.specs) Input::check_triplet(spec.triplet(), paths); diff --git a/toolsrc/src/vcpkg/tools.cpp b/toolsrc/src/vcpkg/tools.cpp index 9098cb135..0d3f61757 100644 --- a/toolsrc/src/vcpkg/tools.cpp +++ b/toolsrc/src/vcpkg/tools.cpp @@ -83,8 +83,12 @@ namespace vcpkg const bool has_tool_entry = std::regex_search(XML.cbegin(), XML.cend(), match_tool_entry, tool_regex); if (!has_tool_entry) { - return Strings::format( - "Could not find entry for tool %s in %s for os=%s", tool, XML_PATH.u8string(), OS_STRING); + return Strings::format("Could not automatically acquire %s because there is no entry in %s for os=%s. You " + "may be able to install %s via your system package manager.", + tool, + XML_PATH.u8string(), + OS_STRING, + tool); } const std::string tool_data = |
