diff options
| author | myd7349 <myd7349@gmail.com> | 2019-05-27 19:15:06 +0800 |
|---|---|---|
| committer | myd7349 <myd7349@gmail.com> | 2019-05-27 19:15:06 +0800 |
| commit | 8999734b401bb8bac9fa20ce831b2ad2a9a67add (patch) | |
| tree | 3f5cf1d5abbbc4295b556ea6e27882950bdd81f3 /toolsrc/src | |
| parent | a7ac12c90afed0a13e3b24d509927d2fca506115 (diff) | |
| parent | 9ffac4d56eed774419fbb628ea89417a6399db58 (diff) | |
| download | vcpkg-8999734b401bb8bac9fa20ce831b2ad2a9a67add.tar.gz vcpkg-8999734b401bb8bac9fa20ce831b2ad2a9a67add.zip | |
Merge branch 'master' into rdkafka-init
Diffstat (limited to 'toolsrc/src')
| -rw-r--r-- | toolsrc/src/vcpkg.cpp | 9 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg/base/files.cpp | 25 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg/build.cpp | 13 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg/commands.ci.cpp | 2 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg/commands.upgrade.cpp | 1 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg/export.cpp | 1 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg/globalstate.cpp | 2 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg/install.cpp | 46 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg/paragraphs.cpp | 16 |
9 files changed, 58 insertions, 57 deletions
diff --git a/toolsrc/src/vcpkg.cpp b/toolsrc/src/vcpkg.cpp index 2c0f562b6..9102205d8 100644 --- a/toolsrc/src/vcpkg.cpp +++ b/toolsrc/src/vcpkg.cpp @@ -294,11 +294,11 @@ int main(const int argc, const char* const* const argv) Checks::register_global_shutdown_handler([]() { const auto elapsed_us_inner = GlobalState::timer.lock()->microseconds(); - bool debugging = GlobalState::debugging; + bool debugging = Debug::g_debugging; auto metrics = Metrics::g_metrics.lock(); metrics->track_metric("elapsed_us", elapsed_us_inner); - GlobalState::debugging = false; + Debug::g_debugging = false; metrics->flush(); #if defined(_WIN32) @@ -337,14 +337,13 @@ int main(const int argc, const char* const* const argv) const VcpkgCmdArguments args = VcpkgCmdArguments::create_from_command_line(argc, argv); - if (const auto p = args.featurepackages.get()) GlobalState::feature_packages = *p; if (const auto p = args.binarycaching.get()) GlobalState::g_binary_caching = *p; if (const auto p = args.printmetrics.get()) Metrics::g_metrics.lock()->set_print_metrics(*p); if (const auto p = args.sendmetrics.get()) Metrics::g_metrics.lock()->set_send_metrics(*p); - if (const auto p = args.debug.get()) GlobalState::debugging = *p; + if (const auto p = args.debug.get()) Debug::g_debugging = *p; - if (GlobalState::debugging) + if (Debug::g_debugging) { inner(args); Checks::exit_fail(VCPKG_LINE_INFO); diff --git a/toolsrc/src/vcpkg/base/files.cpp b/toolsrc/src/vcpkg/base/files.cpp index 164394100..431491314 100644 --- a/toolsrc/src/vcpkg/base/files.cpp +++ b/toolsrc/src/vcpkg/base/files.cpp @@ -7,12 +7,17 @@ #include <vcpkg/base/system.process.h> #include <vcpkg/base/util.h> -#if defined(__linux__) +#if defined(__linux__) || defined(__APPLE__) #include <fcntl.h> -#include <sys/sendfile.h> #include <sys/stat.h> #include <sys/types.h> #include <unistd.h> +#include <string.h> +#endif +#if defined(__linux__) +#include <sys/sendfile.h> +#elif defined(__APPLE__) +#include <copyfile.h> #endif namespace vcpkg::Files @@ -166,7 +171,7 @@ namespace vcpkg::Files std::error_code& ec) override { this->rename(oldpath, newpath, ec); -#if defined(__linux__) +#if defined(__linux__) || defined(__APPLE__) if (ec) { auto dst = newpath; @@ -182,13 +187,25 @@ namespace vcpkg::Files return; } +#if defined(__linux__) off_t bytes = 0; struct stat info = {0}; fstat(i_fd, &info); auto written_bytes = sendfile(o_fd, i_fd, &bytes, info.st_size); +#elif defined(__APPLE__) + auto written_bytes = fcopyfile(i_fd, o_fd, 0, COPYFILE_ALL); +#endif + if (written_bytes == -1) + { + ec.assign(errno, std::generic_category()); + close(i_fd); + close(o_fd); + + return; + } + close(i_fd); close(o_fd); - if (written_bytes == -1) return; this->rename(dst, newpath, ec); if (ec) return; diff --git a/toolsrc/src/vcpkg/build.cpp b/toolsrc/src/vcpkg/build.cpp index 53b782edc..1f28e9f30 100644 --- a/toolsrc/src/vcpkg/build.cpp +++ b/toolsrc/src/vcpkg/build.cpp @@ -8,6 +8,7 @@ #include <vcpkg/base/stringliteral.h>
#include <vcpkg/base/system.print.h>
#include <vcpkg/base/system.process.h>
+#include <vcpkg/base/system.debug.h>
#include <vcpkg/build.h>
#include <vcpkg/commands.h>
@@ -69,6 +70,7 @@ namespace vcpkg::Build::Command Build::AllowDownloads::YES,
Build::CleanBuildtrees::NO,
Build::CleanPackages::NO,
+ Build::CleanDownloads::NO,
Build::DownloadTool::BUILT_IN,
GlobalState::g_binary_caching ? Build::BinaryCaching::YES : Build::BinaryCaching::NO,
Build::FailOnTombstone::NO,
@@ -129,11 +131,6 @@ namespace vcpkg::Build::Command const FullPackageSpec spec = Input::check_and_get_full_package_spec(
std::move(first_arg), default_triplet, COMMAND_STRUCTURE.example_text);
Input::check_triplet(spec.package_spec.triplet(), paths);
- if (!spec.features.empty() && !GlobalState::feature_packages)
- {
- Checks::exit_with_message(
- VCPKG_LINE_INFO, "Feature packages are experimentally available under the --featurepackages flag.");
- }
perform_and_exit_ex(spec, paths.port_dir(spec.package_spec), options, paths);
}
}
@@ -237,7 +234,7 @@ namespace vcpkg::Build if (!pre_build_info.cmake_system_name.empty() && pre_build_info.cmake_system_name != "WindowsStore") return "";
const char* tonull = " >nul";
- if (GlobalState::debugging)
+ if (Debug::g_debugging)
{
tonull = "";
}
@@ -511,7 +508,7 @@ namespace vcpkg::Build // which will give a stable ordering and better names in the key entry.
// this is not available in the filesystem TS so instead number the files for the key.
std::string key = Strings::format("file_%03d", counter++);
- if (GlobalState::debugging)
+ if (Debug::g_debugging)
{
System::print2("[DEBUG] mapping ", key, " from ", port_file.u8string(), "\n");
}
@@ -536,7 +533,7 @@ namespace vcpkg::Build const std::string full_abi_info =
Strings::join("", abi_tag_entries, [](const AbiEntry& p) { return p.key + " " + p.value + "\n"; });
- if (GlobalState::debugging)
+ if (Debug::g_debugging)
{
System::print2("[DEBUG] <abientries>\n");
for (auto&& entry : abi_tag_entries)
diff --git a/toolsrc/src/vcpkg/commands.ci.cpp b/toolsrc/src/vcpkg/commands.ci.cpp index 10cb7d9fe..4d31c4fbe 100644 --- a/toolsrc/src/vcpkg/commands.ci.cpp +++ b/toolsrc/src/vcpkg/commands.ci.cpp @@ -229,6 +229,7 @@ namespace vcpkg::Commands::CI Build::AllowDownloads::YES, Build::CleanBuildtrees::YES, Build::CleanPackages::YES, + Build::CleanDownloads::NO, Build::DownloadTool::BUILT_IN, GlobalState::g_binary_caching ? Build::BinaryCaching::YES : Build::BinaryCaching::NO, Build::FailOnTombstone::YES, @@ -372,6 +373,7 @@ namespace vcpkg::Commands::CI Build::AllowDownloads::YES, Build::CleanBuildtrees::YES, Build::CleanPackages::YES, + Build::CleanDownloads::NO, Build::DownloadTool::BUILT_IN, GlobalState::g_binary_caching ? Build::BinaryCaching::YES : Build::BinaryCaching::NO, Build::FailOnTombstone::YES, diff --git a/toolsrc/src/vcpkg/commands.upgrade.cpp b/toolsrc/src/vcpkg/commands.upgrade.cpp index 29627db3d..29815ca94 100644 --- a/toolsrc/src/vcpkg/commands.upgrade.cpp +++ b/toolsrc/src/vcpkg/commands.upgrade.cpp @@ -155,6 +155,7 @@ namespace vcpkg::Commands::Upgrade Build::AllowDownloads::YES, Build::CleanBuildtrees::NO, Build::CleanPackages::NO, + Build::CleanDownloads::NO, Build::DownloadTool::BUILT_IN, GlobalState::g_binary_caching ? Build::BinaryCaching::YES : Build::BinaryCaching::NO, Build::FailOnTombstone::NO, diff --git a/toolsrc/src/vcpkg/export.cpp b/toolsrc/src/vcpkg/export.cpp index 870d2c49e..f6a95b61f 100644 --- a/toolsrc/src/vcpkg/export.cpp +++ b/toolsrc/src/vcpkg/export.cpp @@ -75,6 +75,7 @@ namespace vcpkg::Export Build::AllowDownloads::YES, Build::CleanBuildtrees::NO, Build::CleanPackages::NO, + Build::CleanDownloads::NO, Build::DownloadTool::BUILT_IN, Build::BinaryCaching::NO, Build::FailOnTombstone::NO, diff --git a/toolsrc/src/vcpkg/globalstate.cpp b/toolsrc/src/vcpkg/globalstate.cpp index 1a2c08474..aac5148fa 100644 --- a/toolsrc/src/vcpkg/globalstate.cpp +++ b/toolsrc/src/vcpkg/globalstate.cpp @@ -7,8 +7,6 @@ namespace vcpkg Util::LockGuarded<Chrono::ElapsedTimer> GlobalState::timer; Util::LockGuarded<std::string> GlobalState::g_surveydate; - std::atomic<bool> GlobalState::debugging(false); - std::atomic<bool> GlobalState::feature_packages(true); std::atomic<bool> GlobalState::g_binary_caching(false); std::atomic<int> GlobalState::g_init_console_cp(0); diff --git a/toolsrc/src/vcpkg/install.cpp b/toolsrc/src/vcpkg/install.cpp index 14dfb6fa3..7fb304c17 100644 --- a/toolsrc/src/vcpkg/install.cpp +++ b/toolsrc/src/vcpkg/install.cpp @@ -302,8 +302,7 @@ namespace vcpkg::Install { const InstallPlanType& plan_type = action.plan_type; const std::string display_name = action.spec.to_string(); - const std::string display_name_with_features = - GlobalState::feature_packages ? action.displayname() : display_name; + const std::string display_name_with_features = action.displayname(); const bool is_user_requested = action.request_type == RequestType::USER_REQUESTED; const bool use_head_version = Util::Enum::to_bool(action.build_options.use_head_version); @@ -368,6 +367,16 @@ namespace vcpkg::Install fs.remove_all(package_dir, ec); } + if (action.build_options.clean_downloads == Build::CleanDownloads::YES) + { + auto& fs = paths.get_filesystem(); + const fs::path download_dir = paths.downloads; + std::error_code ec; + for(auto& p: fs.get_files_non_recursive(download_dir)) + if (!fs.is_directory(p)) + fs.remove(p); + } + return {code, std::move(bcf)}; } @@ -464,14 +473,16 @@ namespace vcpkg::Install static constexpr StringLiteral OPTION_KEEP_GOING = "--keep-going"; static constexpr StringLiteral OPTION_XUNIT = "--x-xunit"; static constexpr StringLiteral OPTION_USE_ARIA2 = "--x-use-aria2"; + static constexpr StringLiteral OPTION_CLEAN_AFTER_BUILD = "--clean-after-build"; - static constexpr std::array<CommandSwitch, 6> INSTALL_SWITCHES = {{ + static constexpr std::array<CommandSwitch, 7> 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_RECURSE, "Allow removal of packages as part of installation"}, {OPTION_KEEP_GOING, "Continue installing packages on failure"}, {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<CommandSetting, 1> INSTALL_SETTINGS = {{ {OPTION_XUNIT, "File to output results in XUnit format (Internal use)"}, @@ -532,7 +543,9 @@ namespace vcpkg::Install while (next != last) { auto match = *next; - library_targets[find_package_name].push_back(match[1]); + auto& targets = library_targets[find_package_name]; + if (std::find(targets.cbegin(), targets.cend(), match[1]) == targets.cend()) + targets.push_back(match[1]); ++next; } } @@ -615,11 +628,6 @@ namespace vcpkg::Install for (auto&& spec : specs) { Input::check_triplet(spec.package_spec.triplet(), paths); - if (!spec.features.empty() && !GlobalState::feature_packages) - { - Checks::exit_with_message( - VCPKG_LINE_INFO, "Feature packages are experimentally available under the --featurepackages flag."); - } } const bool dry_run = Util::Sets::contains(options.switches, OPTION_DRY_RUN); @@ -627,6 +635,7 @@ namespace vcpkg::Install const bool no_downloads = Util::Sets::contains(options.switches, (OPTION_NO_DOWNLOADS)); const bool is_recursive = Util::Sets::contains(options.switches, (OPTION_RECURSE)); const bool use_aria2 = Util::Sets::contains(options.switches, (OPTION_USE_ARIA2)); + const bool clean_after_build = Util::Sets::contains(options.switches, (OPTION_CLEAN_AFTER_BUILD)); const KeepGoing keep_going = to_keep_going(Util::Sets::contains(options.switches, OPTION_KEEP_GOING)); // create the plan @@ -638,8 +647,9 @@ namespace vcpkg::Install const Build::BuildPackageOptions install_plan_options = { Util::Enum::to_enum<Build::UseHeadVersion>(use_head_version), Util::Enum::to_enum<Build::AllowDownloads>(!no_downloads), - Build::CleanBuildtrees::NO, - Build::CleanPackages::NO, + clean_after_build ? Build::CleanBuildtrees::YES : Build::CleanBuildtrees::NO, + clean_after_build ? Build::CleanPackages::YES : Build::CleanPackages::NO, + clean_after_build ? Build::CleanDownloads::YES : Build::CleanDownloads::NO, download_tool, GlobalState::g_binary_caching ? Build::BinaryCaching::YES : Build::BinaryCaching::NO, Build::FailOnTombstone::NO, @@ -655,20 +665,6 @@ namespace vcpkg::Install std::vector<AnyAction> action_plan = create_feature_install_plan(provider, FullPackageSpec::to_feature_specs(specs), status_db); - if (!GlobalState::feature_packages) - { - for (auto&& action : action_plan) - { - if (action.remove_action.has_value()) - { - Checks::exit_with_message( - VCPKG_LINE_INFO, - "The installation plan requires feature packages support. Please re-run the " - "command with --featurepackages."); - } - } - } - for (auto&& action : action_plan) { if (auto p_install = action.install_action.get()) diff --git a/toolsrc/src/vcpkg/paragraphs.cpp b/toolsrc/src/vcpkg/paragraphs.cpp index 45f939afd..431fad5ca 100644 --- a/toolsrc/src/vcpkg/paragraphs.cpp +++ b/toolsrc/src/vcpkg/paragraphs.cpp @@ -3,7 +3,7 @@ #include <vcpkg/base/files.h> #include <vcpkg/base/system.print.h> #include <vcpkg/base/util.h> -#include <vcpkg/globalstate.h> +#include <vcpkg/base/system.debug.h> #include <vcpkg/paragraphparseresult.h> #include <vcpkg/paragraphs.h> @@ -211,17 +211,7 @@ namespace vcpkg::Paragraphs Expected<std::vector<std::unordered_map<std::string, std::string>>> pghs = get_paragraphs(fs, path / "CONTROL"); if (auto vector_pghs = pghs.get()) { - auto csf = SourceControlFile::parse_control_file(std::move(*vector_pghs)); - if (!GlobalState::feature_packages) - { - if (auto ptr = csf.get()) - { - Checks::check_exit(VCPKG_LINE_INFO, ptr->get() != nullptr); - ptr->get()->core_paragraph->default_features.clear(); - ptr->get()->feature_paragraphs.clear(); - } - } - return csf; + return SourceControlFile::parse_control_file(std::move(*vector_pghs)); } auto error_info = std::make_unique<ParseControlErrorInfo>(); error_info->name = path.filename().generic_u8string(); @@ -279,7 +269,7 @@ namespace vcpkg::Paragraphs auto results = try_load_all_ports(fs, ports_dir); if (!results.errors.empty()) { - if (GlobalState::debugging) + if (Debug::g_debugging) { print_error_message(results.errors); } |
