diff options
Diffstat (limited to 'toolsrc/src')
| -rw-r--r-- | toolsrc/src/vcpkg/base/files.cpp | 25 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg/binarycaching.cpp | 92 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg/build.cpp | 65 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg/commands.buildexternal.cpp | 1 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg/commands.ci.cpp | 132 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg/commands.edit.cpp | 5 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg/commands.setinstalled.cpp | 14 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg/commands.upgrade.cpp | 14 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg/export.cpp | 14 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg/install.cpp | 105 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg/postbuildlint.cpp | 11 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg/vcpkgpaths.cpp | 11 |
12 files changed, 230 insertions, 259 deletions
diff --git a/toolsrc/src/vcpkg/base/files.cpp b/toolsrc/src/vcpkg/base/files.cpp index 2e39073ce..32a382154 100644 --- a/toolsrc/src/vcpkg/base/files.cpp +++ b/toolsrc/src/vcpkg/base/files.cpp @@ -204,11 +204,36 @@ namespace vcpkg::Files return this->create_directory(path, ec); } + bool Filesystem::create_directory(const fs::path& path, LineInfo li) + { + std::error_code ec; + bool result = this->create_directory(path, ec); + if (ec) + { + vcpkg::Checks::exit_with_message(li, "error creating directory %s", path.u8string(), ec.message()); + } + + return result; + } + bool Filesystem::create_directories(const fs::path& path, ignore_errors_t) { std::error_code ec; return this->create_directories(path, ec); } + + bool Filesystem::create_directories(const fs::path& path, LineInfo li) + { + std::error_code ec; + bool result = this->create_directories(path, ec); + if (ec) + { + vcpkg::Checks::exit_with_message(li, "error creating directories %s", path.u8string(), ec.message()); + } + + return result; + } + void Filesystem::copy_file(const fs::path& oldpath, const fs::path& newpath, fs::copy_options opts, LineInfo li) { std::error_code ec; diff --git a/toolsrc/src/vcpkg/binarycaching.cpp b/toolsrc/src/vcpkg/binarycaching.cpp index 1c337aea5..21ef7094a 100644 --- a/toolsrc/src/vcpkg/binarycaching.cpp +++ b/toolsrc/src/vcpkg/binarycaching.cpp @@ -104,33 +104,10 @@ namespace }
}
}
+
+ System::printf("Could not locate cached archive: %s\n", archive_path.u8string());
}
- for (auto&& archives_root_dir : m_read_dirs)
- {
- const std::string archive_name = abi_tag + ".zip";
- const fs::path archive_subpath = fs::u8path(abi_tag.substr(0, 2)) / fs::u8path(archive_name);
- const fs::path archive_tombstone_path = archives_root_dir / fs::u8path("fail") / archive_subpath;
- if (fs.exists(archive_tombstone_path))
- {
- if (action.build_options.fail_on_tombstone == Build::FailOnTombstone::YES)
- {
- System::print2("Found failure tombstone: ", archive_tombstone_path.u8string(), "\n");
- return RestoreResult::build_failed;
- }
- else
- {
- System::print2(System::Color::warning,
- "Found failure tombstone: ",
- archive_tombstone_path.u8string(),
- "\n");
- }
- }
- else
- {
- const fs::path archive_path = archives_root_dir / archive_subpath;
- System::printf("Could not locate cached archive: %s\n", archive_path.u8string());
- }
- }
+
return RestoreResult::missing;
}
void push_success(const VcpkgPaths& paths, const Dependencies::InstallPlanAction& action) override
@@ -167,46 +144,6 @@ namespace }
if (m_write_dirs.size() > 1) fs.remove(tmp_archive_path, ignore_errors);
}
- void push_failure(const VcpkgPaths& paths, const std::string& abi_tag, const PackageSpec& spec) override
- {
- if (m_write_dirs.empty()) return;
- auto& fs = paths.get_filesystem();
- std::error_code ec;
- for (auto&& m_directory : m_write_dirs)
- {
- const fs::path& archives_root_dir = m_directory;
- const std::string archive_name = abi_tag + ".zip";
- const fs::path archive_subpath = fs::u8path(abi_tag.substr(0, 2)) / fs::u8path(archive_name);
- const fs::path archive_tombstone_path = archives_root_dir / fs::u8path("fail") / archive_subpath;
- if (!fs.exists(archive_tombstone_path))
- {
- // Build failed, store all failure logs in the tombstone.
- const auto spec_name_path = fs::u8path(spec.name());
- const auto tmp_log_path = paths.buildtrees / spec_name_path / fs::u8path("tmp_failure_logs");
- const auto tmp_log_path_destination = tmp_log_path / spec_name_path;
- const auto tmp_failure_zip = paths.buildtrees / spec_name_path / fs::u8path("failure_logs.zip");
- fs.create_directories(tmp_log_path_destination, ignore_errors);
-
- for (auto& log_file : fs::stdfs::directory_iterator(paths.buildtrees / spec.name()))
- {
- if (log_file.path().extension() == ".log")
- {
- fs.copy_file(log_file.path(),
- tmp_log_path_destination / log_file.path().filename(),
- fs::copy_options::none,
- ec);
- }
- }
-
- compress_directory(paths, tmp_log_path, tmp_failure_zip);
- fs.create_directories(archive_tombstone_path.parent_path(), ignore_errors);
- fs.rename_or_copy(tmp_failure_zip, archive_tombstone_path, ".tmp", ec);
-
- // clean up temporary directory
- fs.remove_all(tmp_log_path, VCPKG_LINE_INFO);
- }
- }
- }
RestoreResult precheck(const VcpkgPaths& paths, const Dependencies::InstallPlanAction& action) override
{
const auto& abi_tag = action.abi_info.value_or_exit(VCPKG_LINE_INFO).package_abi;
@@ -223,20 +160,6 @@ namespace return RestoreResult::success;
}
}
- for (auto&& archives_root_dir : m_read_dirs)
- {
- const std::string archive_name = abi_tag + ".zip";
- const fs::path archive_subpath = fs::u8path(abi_tag.substr(0, 2)) / fs::u8path(archive_name);
- const fs::path archive_tombstone_path = archives_root_dir / fs::u8path("fail") / archive_subpath;
-
- if (fs.exists(archive_tombstone_path))
- {
- if (action.build_options.fail_on_tombstone == Build::FailOnTombstone::YES)
- {
- return RestoreResult::build_failed;
- }
- }
- }
return RestoreResult::missing;
}
@@ -525,7 +448,6 @@ namespace paths.get_filesystem().remove(nupkg_path, ignore_errors);
}
}
- void push_failure(const VcpkgPaths&, const std::string&, const PackageSpec&) override {}
RestoreResult precheck(const VcpkgPaths&, const Dependencies::InstallPlanAction&) override
{
return RestoreResult::missing;
@@ -578,13 +500,6 @@ namespace provider->push_success(paths, action);
}
}
- void push_failure(const VcpkgPaths& paths, const std::string& abi_tag, const PackageSpec& spec) override
- {
- for (auto&& provider : m_providers)
- {
- provider->push_failure(paths, abi_tag, spec);
- }
- }
RestoreResult precheck(const VcpkgPaths& paths, const Dependencies::InstallPlanAction& action) override
{
for (auto&& provider : m_providers)
@@ -613,7 +528,6 @@ namespace return RestoreResult::missing;
}
void push_success(const VcpkgPaths&, const Dependencies::InstallPlanAction&) override {}
- void push_failure(const VcpkgPaths&, const std::string&, const PackageSpec&) override {}
RestoreResult precheck(const VcpkgPaths&, const Dependencies::InstallPlanAction&) override
{
return RestoreResult::missing;
diff --git a/toolsrc/src/vcpkg/build.cpp b/toolsrc/src/vcpkg/build.cpp index 7d2976165..d89bb5b74 100644 --- a/toolsrc/src/vcpkg/build.cpp +++ b/toolsrc/src/vcpkg/build.cpp @@ -32,6 +32,24 @@ using vcpkg::Parse::ParseControlErrorInfo; using vcpkg::Parse::ParseExpected;
using vcpkg::PortFileProvider::PathsPortFileProvider;
+namespace
+{
+ using vcpkg::PackageSpec;
+ using vcpkg::VcpkgPaths;
+ using vcpkg::Build::IBuildLogsRecorder;
+ struct NullBuildLogsRecorder final : IBuildLogsRecorder
+ {
+ void record_build_result(const VcpkgPaths& paths, const PackageSpec& spec, BuildResult result) const override
+ {
+ (void)paths;
+ (void)spec;
+ (void)result;
+ }
+ };
+
+ static const NullBuildLogsRecorder null_build_logs_recorder_instance;
+}
+
namespace vcpkg::Build
{
using Dependencies::InstallPlanAction;
@@ -41,9 +59,11 @@ namespace vcpkg::Build const SourceControlFileLocation& scfl,
const PathsPortFileProvider& provider,
IBinaryProvider& binaryprovider,
+ const IBuildLogsRecorder& build_logs_recorder,
const VcpkgPaths& paths)
{
- Checks::exit_with_code(VCPKG_LINE_INFO, perform_ex(full_spec, scfl, provider, binaryprovider, paths));
+ Checks::exit_with_code(VCPKG_LINE_INFO,
+ perform_ex(full_spec, scfl, provider, binaryprovider, build_logs_recorder, paths));
}
const CommandStructure COMMAND_STRUCTURE = {
@@ -63,6 +83,7 @@ namespace vcpkg::Build const SourceControlFileLocation& scfl,
const PathsPortFileProvider& provider,
IBinaryProvider& binaryprovider,
+ const IBuildLogsRecorder& build_logs_recorder,
const VcpkgPaths& paths)
{
auto var_provider_storage = CMakeVars::make_triplet_cmake_var_provider(paths);
@@ -86,17 +107,6 @@ namespace vcpkg::Build compute_all_abis(paths, action_plan, var_provider, status_db);
- const Build::BuildPackageOptions build_package_options{
- Build::UseHeadVersion::NO,
- Build::AllowDownloads::YES,
- Build::OnlyDownloads::NO,
- Build::CleanBuildtrees::NO,
- Build::CleanPackages::NO,
- Build::CleanDownloads::NO,
- Build::DownloadTool::BUILT_IN,
- Build::FailOnTombstone::NO,
- };
-
InstallPlanAction* action = nullptr;
for (auto& install_action : action_plan.already_installed)
{
@@ -115,10 +125,10 @@ namespace vcpkg::Build Checks::check_exit(VCPKG_LINE_INFO, action != nullptr);
ASSUME(action != nullptr);
- action->build_options = build_package_options;
+ action->build_options = default_build_package_options;
const auto build_timer = Chrono::ElapsedTimer::create_started();
- const auto result = Build::build_package(paths, *action, binaryprovider, status_db);
+ const auto result = Build::build_package(paths, *action, binaryprovider, build_logs_recorder, status_db);
System::print2("Elapsed time for package ", spec, ": ", build_timer, '\n');
if (result.code == BuildResult::CASCADED_DUE_TO_MISSING_DEPENDENCIES)
@@ -167,8 +177,12 @@ namespace vcpkg::Build Checks::check_exit(VCPKG_LINE_INFO, scfl != nullptr, "Error: Couldn't find port '%s'", port_name);
ASSUME(scfl != nullptr);
- return perform_ex(
- spec, *scfl, provider, args.binary_caching_enabled() ? *binaryprovider : null_binary_provider(), paths);
+ return perform_ex(spec,
+ *scfl,
+ provider,
+ args.binary_caching_enabled() ? *binaryprovider : null_binary_provider(),
+ Build::null_build_logs_recorder(),
+ paths);
}
}
@@ -728,8 +742,7 @@ namespace vcpkg::Build if (action.build_options.clean_buildtrees == CleanBuildtrees::YES)
{
auto& fs = paths.get_filesystem();
- const fs::path buildtrees_dir = paths.buildtrees / action.spec.name();
- auto buildtree_files = fs.get_files_non_recursive(buildtrees_dir);
+ auto buildtree_files = fs.get_files_non_recursive(paths.build_dir(action.spec));
for (auto&& file : buildtree_files)
{
if (fs.is_directory(file)) // Will only keep the logs
@@ -771,7 +784,6 @@ namespace vcpkg::Build {
auto& fs = paths.get_filesystem();
Triplet triplet = action.spec.triplet();
- const std::string& name = action.spec.name();
std::vector<AbiEntry> abi_tag_entries(dependency_abis.begin(), dependency_abis.end());
@@ -841,9 +853,9 @@ namespace vcpkg::Build if (abi_tag_entries_missing.empty())
{
- std::error_code ec;
- fs.create_directories(paths.buildtrees / name, ec);
- const auto abi_file_path = paths.buildtrees / name / (triplet.canonical_name() + ".vcpkg_abi_info.txt");
+ auto current_build_tree = paths.build_dir(action.spec);
+ fs.create_directory(current_build_tree, VCPKG_LINE_INFO);
+ const auto abi_file_path = current_build_tree / (triplet.canonical_name() + ".vcpkg_abi_info.txt");
fs.write_contents(abi_file_path, full_abi_info, VCPKG_LINE_INFO);
return AbiTagAndFile{Hash::get_file_hash(VCPKG_LINE_INFO, fs, abi_file_path, Hash::Algorithm::Sha1),
@@ -919,6 +931,7 @@ namespace vcpkg::Build ExtendedBuildResult build_package(const VcpkgPaths& paths,
const Dependencies::InstallPlanAction& action,
IBinaryProvider& binaries_provider,
+ const IBuildLogsRecorder& build_logs_recorder,
const StatusParagraphs& status_db)
{
auto& fs = paths.get_filesystem();
@@ -991,10 +1004,8 @@ namespace vcpkg::Build {
binaries_provider.push_success(paths, action);
}
- else if ((result.code == BuildResult::BUILD_FAILED || result.code == BuildResult::POST_BUILD_CHECKS_FAILED))
- {
- binaries_provider.push_failure(paths, abi_info.package_abi, spec);
- }
+
+ build_logs_recorder.record_build_result(paths, spec, result.code);
return result;
}
@@ -1217,4 +1228,6 @@ namespace vcpkg::Build : code(code), unmet_dependencies(std::move(unmet_deps))
{
}
+
+ const IBuildLogsRecorder& null_build_logs_recorder() noexcept { return null_build_logs_recorder_instance; }
}
diff --git a/toolsrc/src/vcpkg/commands.buildexternal.cpp b/toolsrc/src/vcpkg/commands.buildexternal.cpp index 5609e28f8..5fc26b8ea 100644 --- a/toolsrc/src/vcpkg/commands.buildexternal.cpp +++ b/toolsrc/src/vcpkg/commands.buildexternal.cpp @@ -41,6 +41,7 @@ namespace vcpkg::Commands::BuildExternal maybe_scfl.value_or_exit(VCPKG_LINE_INFO), provider, args.binary_caching_enabled() ? *binaryprovider : null_binary_provider(), + Build::null_build_logs_recorder(), paths); } } diff --git a/toolsrc/src/vcpkg/commands.ci.cpp b/toolsrc/src/vcpkg/commands.ci.cpp index df69d2e12..8453d7af6 100644 --- a/toolsrc/src/vcpkg/commands.ci.cpp +++ b/toolsrc/src/vcpkg/commands.ci.cpp @@ -20,6 +20,55 @@ using namespace vcpkg; +namespace +{ + using namespace vcpkg::Build; + + const fs::path dot_log = fs::u8path(".log"); + const fs::path readme_dot_log = fs::u8path("readme.log"); + + class CiBuildLogsRecorder final : public IBuildLogsRecorder + { + fs::path base_path; + + public: + CiBuildLogsRecorder(const fs::path& base_path_) : base_path(base_path_) {} + + virtual void record_build_result(const VcpkgPaths& paths, + const PackageSpec& spec, + BuildResult result) const override + { + if (result == BuildResult::SUCCEEDED) + { + return; + } + + auto& filesystem = paths.get_filesystem(); + const auto source_path = paths.build_dir(spec); + auto children = filesystem.get_files_non_recursive(source_path); + Util::erase_remove_if(children, [](const fs::path& p) { return p.extension() != dot_log; }); + const auto target_path = base_path / fs::u8path(spec.name()); + (void)filesystem.create_directory(target_path, VCPKG_LINE_INFO); + if (children.empty()) + { + std::string message = + "There are no build logs for " + spec.to_string() + + " build.\n" + "This is usually because the build failed early and outside of a task that is logged.\n" + "See the console output logs from vcpkg for more information on the failure.\n"; + filesystem.write_contents(target_path / readme_dot_log, message, VCPKG_LINE_INFO); + } + else + { + for (const fs::path& p : children) + { + filesystem.copy_file(p, target_path / p.filename(), fs::copy_options::none, VCPKG_LINE_INFO); + } + } + } + }; +} + namespace vcpkg::Commands::CI { using Build::BuildResult; @@ -34,13 +83,14 @@ namespace vcpkg::Commands::CI static constexpr StringLiteral OPTION_DRY_RUN = "--dry-run"; static constexpr StringLiteral OPTION_EXCLUDE = "--exclude"; + static constexpr StringLiteral OPTION_FAILURE_LOGS = "--failure-logs"; static constexpr StringLiteral OPTION_XUNIT = "--x-xunit"; static constexpr StringLiteral OPTION_RANDOMIZE = "--x-randomize"; - static constexpr std::array<CommandSetting, 2> CI_SETTINGS = {{ - {OPTION_EXCLUDE, "Comma separated list of ports to skip"}, - {OPTION_XUNIT, "File to output results in XUnit format (internal)"}, - }}; + static constexpr std::array<CommandSetting, 3> CI_SETTINGS = { + {{OPTION_EXCLUDE, "Comma separated list of ports to skip"}, + {OPTION_XUNIT, "File to output results in XUnit format (internal)"}, + {OPTION_FAILURE_LOGS, "Directory to which failure logs will be copied"}}}; static constexpr std::array<CommandSwitch, 2> CI_SWITCHES = {{ {OPTION_DRY_RUN, "Print out plan without execution"}, @@ -245,17 +295,6 @@ namespace vcpkg::Commands::CI std::set<PackageSpec> will_fail; - const Build::BuildPackageOptions build_options = { - Build::UseHeadVersion::NO, - Build::AllowDownloads::YES, - Build::OnlyDownloads::NO, - Build::CleanBuildtrees::YES, - Build::CleanPackages::YES, - Build::CleanDownloads::NO, - Build::DownloadTool::BUILT_IN, - Build::FailOnTombstone::YES, - }; - std::vector<PackageSpec> packages_with_qualified_deps; auto has_qualifier = [](Dependency const& dep) { return !dep.platform.is_empty(); }; for (auto&& spec : specs) @@ -300,7 +339,7 @@ namespace vcpkg::Commands::CI auto emp = ret->default_feature_provider.emplace(p->spec.name(), *scfl); emp.first->second.source_control_file->core_paragraph->default_features = p->feature_list; - p->build_options = build_options; + p->build_options = vcpkg::Build::default_build_package_options; } auto precheck_result = binaryprovider.precheck(paths, action); @@ -361,11 +400,6 @@ namespace vcpkg::Commands::CI void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths, Triplet default_triplet) { - if (!args.binary_caching_enabled()) - { - System::print2(System::Color::warning, "Warning: Running ci without binary caching!\n"); - } - std::unique_ptr<IBinaryProvider> binaryproviderStorage; if (args.binary_caching_enabled()) { @@ -376,10 +410,11 @@ namespace vcpkg::Commands::CI IBinaryProvider& binaryprovider = binaryproviderStorage ? *binaryproviderStorage : null_binary_provider(); const ParsedArguments options = args.parse_arguments(COMMAND_STRUCTURE); + auto& settings = options.settings; std::set<std::string> exclusions_set; - auto it_exclusions = options.settings.find(OPTION_EXCLUDE); - if (it_exclusions != options.settings.end()) + auto it_exclusions = settings.find(OPTION_EXCLUDE); + if (it_exclusions != settings.end()) { auto exclusions = Strings::split(it_exclusions->second, ','); exclusions_set.insert(exclusions.begin(), exclusions.end()); @@ -395,24 +430,28 @@ namespace vcpkg::Commands::CI triplets.push_back(default_triplet); } + auto& filesystem = paths.get_filesystem(); + Optional<CiBuildLogsRecorder> build_logs_recorder_storage; + { + auto it_failure_logs = settings.find(OPTION_FAILURE_LOGS); + if (it_failure_logs != settings.end()) + { + auto raw_path = fs::u8path(it_failure_logs->second); + System::printf("Creating failure logs output directory %s\n", it_failure_logs->second); + filesystem.create_directories(raw_path, VCPKG_LINE_INFO); + build_logs_recorder_storage = filesystem.canonical(VCPKG_LINE_INFO, raw_path); + } + } + + const IBuildLogsRecorder& build_logs_recorder = + build_logs_recorder_storage ? *(build_logs_recorder_storage.get()) : null_build_logs_recorder(); + StatusParagraphs status_db = database_load_check(paths); PortFileProvider::PathsPortFileProvider provider(paths, args.overlay_ports); auto var_provider_storage = CMakeVars::make_triplet_cmake_var_provider(paths); auto& var_provider = *var_provider_storage; - const Build::BuildPackageOptions install_plan_options = { - Build::UseHeadVersion::NO, - Build::AllowDownloads::YES, - Build::OnlyDownloads::NO, - Build::CleanBuildtrees::YES, - Build::CleanPackages::YES, - Build::CleanDownloads::NO, - Build::DownloadTool::BUILT_IN, - Build::FailOnTombstone::YES, - Build::PurgeDecompressFailure::YES, - }; - std::vector<std::map<PackageSpec, BuildResult>> all_known_results; XunitTestResults xunitTestResults; @@ -438,12 +477,8 @@ namespace vcpkg::Commands::CI return FullPackageSpec{spec, std::move(default_features)}; }); - auto split_specs = find_unknown_ports_for_ci(paths, - exclusions_set, - provider, - var_provider, - all_default_full_specs, - binaryprovider); + auto split_specs = find_unknown_ports_for_ci( + paths, exclusions_set, provider, var_provider, all_default_full_specs, binaryprovider); PortFileProvider::MapPortFileProvider new_default_provider(split_specs->default_feature_provider); Dependencies::CreateInstallPlanOptions serialize_options; @@ -476,7 +511,7 @@ namespace vcpkg::Commands::CI } else { - action.build_options = install_plan_options; + action.build_options = vcpkg::Build::default_build_package_options; } } @@ -487,8 +522,13 @@ namespace vcpkg::Commands::CI else { auto collection_timer = Chrono::ElapsedTimer::create_started(); - auto summary = Install::perform( - action_plan, Install::KeepGoing::YES, paths, status_db, binaryprovider, var_provider); + auto summary = Install::perform(action_plan, + Install::KeepGoing::YES, + paths, + status_db, + binaryprovider, + build_logs_recorder, + var_provider); auto collection_time_elapsed = collection_timer.elapsed(); // Adding results for ports that were built or pulled from an archive @@ -530,12 +570,10 @@ namespace vcpkg::Commands::CI result.summary.print(); } - auto& settings = options.settings; auto it_xunit = settings.find(OPTION_XUNIT); if (it_xunit != settings.end()) { - paths.get_filesystem().write_contents( - fs::u8path(it_xunit->second), xunitTestResults.build_xml(), VCPKG_LINE_INFO); + filesystem.write_contents(fs::u8path(it_xunit->second), xunitTestResults.build_xml(), VCPKG_LINE_INFO); } Checks::exit_success(VCPKG_LINE_INFO); diff --git a/toolsrc/src/vcpkg/commands.edit.cpp b/toolsrc/src/vcpkg/commands.edit.cpp index e3c74d360..1f00a929e 100644 --- a/toolsrc/src/vcpkg/commands.edit.cpp +++ b/toolsrc/src/vcpkg/commands.edit.cpp @@ -115,7 +115,7 @@ namespace vcpkg::Commands::Edit return Util::fmap(ports, [&](const std::string& port_name) -> std::string { const auto portpath = paths.ports / port_name; const auto portfile = portpath / "portfile.cmake"; - const auto buildtrees_current_dir = paths.buildtrees / port_name; + const auto buildtrees_current_dir = paths.build_dir(port_name); const auto pattern = port_name + "_"; std::string package_paths; @@ -138,8 +138,7 @@ namespace vcpkg::Commands::Edit if (Util::Sets::contains(options.switches, OPTION_BUILDTREES)) { return Util::fmap(ports, [&](const std::string& port_name) -> std::string { - const auto buildtrees_current_dir = paths.buildtrees / port_name; - return Strings::format(R"###("%s")###", buildtrees_current_dir.u8string()); + return Strings::format(R"###("%s")###", paths.build_dir(port_name).u8string()); }); } diff --git a/toolsrc/src/vcpkg/commands.setinstalled.cpp b/toolsrc/src/vcpkg/commands.setinstalled.cpp index df191ee3e..d248a4b09 100644 --- a/toolsrc/src/vcpkg/commands.setinstalled.cpp +++ b/toolsrc/src/vcpkg/commands.setinstalled.cpp @@ -118,6 +118,7 @@ namespace vcpkg::Commands::SetInstalled paths, status_db, args.binary_caching_enabled() ? binary_provider : null_binary_provider(), + Build::null_build_logs_recorder(), cmake_vars); System::print2("\nTotal elapsed time: ", summary.total_elapsed_time, "\n\n"); @@ -145,17 +146,6 @@ namespace vcpkg::Commands::SetInstalled const bool dry_run = Util::Sets::contains(options.switches, OPTION_DRY_RUN); - const Build::BuildPackageOptions install_plan_options = { - Build::UseHeadVersion::NO, - Build::AllowDownloads::YES, - Build::OnlyDownloads::NO, - Build::CleanBuildtrees::YES, - Build::CleanPackages::YES, - Build::CleanDownloads::YES, - Build::DownloadTool::BUILT_IN, - Build::FailOnTombstone::NO, - }; - PortFileProvider::PathsPortFileProvider provider(paths, args.overlay_ports); auto cmake_vars = CMakeVars::make_triplet_cmake_var_provider(paths); @@ -171,7 +161,7 @@ namespace vcpkg::Commands::SetInstalled *binary_provider, *cmake_vars, specs, - install_plan_options, + vcpkg::Build::default_build_package_options, dry_run ? DryRun::Yes : DryRun::No, pkgsconfig); } diff --git a/toolsrc/src/vcpkg/commands.upgrade.cpp b/toolsrc/src/vcpkg/commands.upgrade.cpp index 89466ab60..32071259b 100644 --- a/toolsrc/src/vcpkg/commands.upgrade.cpp +++ b/toolsrc/src/vcpkg/commands.upgrade.cpp @@ -157,21 +157,10 @@ namespace vcpkg::Commands::Upgrade Checks::check_exit(VCPKG_LINE_INFO, !action_plan.empty()); - const Build::BuildPackageOptions install_plan_options = { - Build::UseHeadVersion::NO, - Build::AllowDownloads::YES, - Build::OnlyDownloads::NO, - Build::CleanBuildtrees::NO, - Build::CleanPackages::NO, - Build::CleanDownloads::NO, - Build::DownloadTool::BUILT_IN, - Build::FailOnTombstone::NO, - }; - // Set build settings for all install actions for (auto&& action : action_plan.install_actions) { - action.build_options = install_plan_options; + action.build_options = vcpkg::Build::default_build_package_options; } Dependencies::print_plan(action_plan, true, paths.ports); @@ -192,6 +181,7 @@ namespace vcpkg::Commands::Upgrade paths, status_db, args.binary_caching_enabled() ? *binaryprovider : null_binary_provider(), + Build::null_build_logs_recorder(), var_provider); System::print2("\nTotal elapsed time: ", summary.total_elapsed_time, "\n\n"); diff --git a/toolsrc/src/vcpkg/export.cpp b/toolsrc/src/vcpkg/export.cpp index 48e9747b3..3819584f9 100644 --- a/toolsrc/src/vcpkg/export.cpp +++ b/toolsrc/src/vcpkg/export.cpp @@ -76,17 +76,6 @@ namespace vcpkg::Export { static constexpr std::array<ExportPlanType, 2> ORDER = {ExportPlanType::ALREADY_BUILT, ExportPlanType::NOT_BUILT}; - static constexpr Build::BuildPackageOptions BUILD_OPTIONS = { - Build::UseHeadVersion::NO, - Build::AllowDownloads::YES, - Build::OnlyDownloads::NO, - Build::CleanBuildtrees::NO, - Build::CleanPackages::NO, - Build::CleanDownloads::NO, - Build::DownloadTool::BUILT_IN, - Build::FailOnTombstone::NO, - }; - for (const ExportPlanType plan_type : ORDER) { const auto it = group_by_plan_type.find(plan_type); @@ -98,7 +87,8 @@ namespace vcpkg::Export std::vector<const ExportPlanAction*> cont = it->second; std::sort(cont.begin(), cont.end(), &ExportPlanAction::compare_by_name); const std::string as_string = Strings::join("\n", cont, [](const ExportPlanAction* p) { - return Dependencies::to_output_string(p->request_type, p->spec.to_string(), BUILD_OPTIONS); + return Dependencies::to_output_string( + p->request_type, p->spec.to_string(), vcpkg::Build::default_build_package_options); }); switch (plan_type) diff --git a/toolsrc/src/vcpkg/install.cpp b/toolsrc/src/vcpkg/install.cpp index aa79bb1f2..842a7a7fa 100644 --- a/toolsrc/src/vcpkg/install.cpp +++ b/toolsrc/src/vcpkg/install.cpp @@ -308,7 +308,8 @@ namespace vcpkg::Install static ExtendedBuildResult perform_install_plan_action(const VcpkgPaths& paths, InstallPlanAction& action, StatusParagraphs& status_db, - IBinaryProvider& binaries_provider) + IBinaryProvider& binaries_provider, + const Build::IBuildLogsRecorder& build_logs_recorder) { const InstallPlanType& plan_type = action.plan_type; const std::string display_name = action.spec.to_string(); @@ -328,19 +329,6 @@ namespace vcpkg::Install return BuildResult::SUCCEEDED; } - auto aux_install = [&](const std::string& name, const BinaryControlFile& bcf) -> BuildResult { - System::printf("Installing package %s...\n", name); - const auto install_result = install_package(paths, bcf, &status_db); - switch (install_result) - { - case InstallResult::SUCCESS: - System::printf(System::Color::success, "Installing package %s... done\n", name); - return BuildResult::SUCCEEDED; - case InstallResult::FILE_CONFLICTS: return BuildResult::FILE_CONFLICTS; - default: Checks::unreachable(VCPKG_LINE_INFO); - } - }; - if (plan_type == InstallPlanType::BUILD_AND_INSTALL) { if (use_head_version) @@ -348,7 +336,7 @@ namespace vcpkg::Install else System::printf("Building package %s...\n", display_name_with_features); - auto result = Build::build_package(paths, action, binaries_provider, status_db); + auto result = Build::build_package(paths, action, binaries_provider, build_logs_recorder, status_db); if (BuildResult::DOWNLOADED == result.code) { @@ -367,7 +355,19 @@ namespace vcpkg::Install auto bcf = std::make_unique<BinaryControlFile>( Paragraphs::try_load_cached_package(paths, action.spec).value_or_exit(VCPKG_LINE_INFO)); - auto code = aux_install(display_name_with_features, *bcf); + System::printf("Installing package %s...\n", display_name_with_features); + const auto install_result = install_package(paths, *bcf, &status_db); + BuildResult code; + switch (install_result) + { + case InstallResult::SUCCESS: + System::printf( + System::Color::success, "Installing package %s... done\n", display_name_with_features); + code = BuildResult::SUCCEEDED; + break; + case InstallResult::FILE_CONFLICTS: code = BuildResult::FILE_CONFLICTS; break; + default: Checks::unreachable(VCPKG_LINE_INFO); + } if (action.build_options.clean_packages == Build::CleanPackages::YES) { @@ -429,44 +429,52 @@ namespace vcpkg::Install } } + struct TrackedPackageInstallGuard + { + SpecSummary* current_summary = nullptr; + Chrono::ElapsedTimer build_timer = Chrono::ElapsedTimer::create_started(); + + TrackedPackageInstallGuard(const size_t package_count, std::vector<SpecSummary>& results, const PackageSpec& spec) + { + results.emplace_back(spec, nullptr); + current_summary = &results.back(); + System::printf("Starting package %zd/%zd: %s\n", results.size(), package_count, spec.to_string()); + } + + ~TrackedPackageInstallGuard() + { + current_summary->timing = build_timer.elapsed(); + System::printf( + "Elapsed time for package %s: %s\n", current_summary->spec.to_string(), current_summary->timing); + } + + TrackedPackageInstallGuard(const TrackedPackageInstallGuard&) = delete; + TrackedPackageInstallGuard& operator=(const TrackedPackageInstallGuard&) = delete; + }; + InstallSummary perform(ActionPlan& action_plan, const KeepGoing keep_going, const VcpkgPaths& paths, StatusParagraphs& status_db, IBinaryProvider& binaryprovider, + const Build::IBuildLogsRecorder& build_logs_recorder, const CMakeVars::CMakeVarProvider& var_provider) { std::vector<SpecSummary> results; - - const auto timer = Chrono::ElapsedTimer::create_started(); - size_t counter = 0; const size_t package_count = action_plan.remove_actions.size() + action_plan.install_actions.size(); - auto with_tracking = [&](const PackageSpec& spec, auto f) { - const auto build_timer = Chrono::ElapsedTimer::create_started(); - counter++; - - const std::string display_name = spec.to_string(); - System::printf("Starting package %zd/%zd: %s\n", counter, package_count, display_name); - - results.emplace_back(spec, nullptr); - - f(); - - results.back().timing = build_timer.elapsed(); - System::printf("Elapsed time for package %s: %s\n", display_name, results.back().timing); - }; - + const auto timer = Chrono::ElapsedTimer::create_started(); for (auto&& action : action_plan.remove_actions) { - with_tracking(action.spec, - [&]() { Remove::perform_remove_plan_action(paths, action, Remove::Purge::YES, &status_db); }); + TrackedPackageInstallGuard this_install(package_count, results, action.spec); + Remove::perform_remove_plan_action(paths, action, Remove::Purge::YES, &status_db); } for (auto&& action : action_plan.already_installed) { results.emplace_back(action.spec, &action); - results.back().build_result = perform_install_plan_action(paths, action, status_db, binaryprovider); + results.back().build_result = + perform_install_plan_action(paths, action, status_db, binaryprovider, build_logs_recorder); } Build::compute_all_abis(paths, action_plan, var_provider, status_db); @@ -475,19 +483,18 @@ namespace vcpkg::Install for (auto&& action : action_plan.install_actions) { - with_tracking(action.spec, [&]() { - auto result = perform_install_plan_action(paths, action, status_db, binaryprovider); - - if (result.code != BuildResult::SUCCEEDED && keep_going == KeepGoing::NO) - { - System::print2(Build::create_user_troubleshooting_message(action.spec), '\n'); - Checks::exit_fail(VCPKG_LINE_INFO); - } + TrackedPackageInstallGuard this_install(package_count, results, action.spec); + auto result = perform_install_plan_action(paths, action, status_db, binaryprovider, build_logs_recorder); + if (result.code != BuildResult::SUCCEEDED && keep_going == KeepGoing::NO) + { + System::print2(Build::create_user_troubleshooting_message(action.spec), '\n'); + Checks::exit_fail(VCPKG_LINE_INFO); + } - results.back().action = &action; - results.back().build_result = std::move(result); - }); + this_install.current_summary->action = &action; + this_install.current_summary->build_result = std::move(result); } + return InstallSummary{std::move(results), timer.to_string()}; } @@ -687,7 +694,6 @@ namespace vcpkg::Install clean_after_build ? Build::CleanPackages::YES : Build::CleanPackages::NO, clean_after_build ? Build::CleanDownloads::YES : Build::CleanDownloads::NO, download_tool, - Build::FailOnTombstone::NO, }; PortFileProvider::PathsPortFileProvider provider(paths, args.overlay_ports); @@ -842,6 +848,7 @@ namespace vcpkg::Install paths, status_db, args.binary_caching_enabled() && !only_downloads ? *binaryprovider : null_binary_provider(), + Build::null_build_logs_recorder(), var_provider); System::print2("\nTotal elapsed time: ", summary.total_elapsed_time, "\n\n"); diff --git a/toolsrc/src/vcpkg/postbuildlint.cpp b/toolsrc/src/vcpkg/postbuildlint.cpp index c6d5f04be..a50736e9b 100644 --- a/toolsrc/src/vcpkg/postbuildlint.cpp +++ b/toolsrc/src/vcpkg/postbuildlint.cpp @@ -318,7 +318,7 @@ namespace vcpkg::PostBuildLint { return LintStatus::SUCCESS; } - const fs::path current_buildtrees_dir = paths.buildtrees / spec.name(); + const fs::path current_buildtrees_dir = paths.build_dir(spec); const fs::path current_buildtrees_dir_src = current_buildtrees_dir / "src"; std::vector<fs::path> potential_copyright_files; @@ -342,12 +342,13 @@ namespace vcpkg::PostBuildLint System::printf(System::Color::warning, "The software license must be available at ${CURRENT_PACKAGES_DIR}/share/%s/copyright\n", spec.name()); - if (potential_copyright_files.size() == - 1) // if there is only one candidate, provide the cmake lines needed to place it in the proper location + if (potential_copyright_files.size() == 1) { + // if there is only one candidate, provide the cmake lines needed to place it in the proper location const fs::path found_file = potential_copyright_files[0]; - const fs::path relative_path = found_file.string().erase( - 0, current_buildtrees_dir.string().size() + 1); // The +1 is needed to remove the "/" + auto found_relative_native = found_file.native(); + found_relative_native.erase(current_buildtrees_dir.native().size() + 1); // The +1 is needed to remove the "/" + const fs::path relative_path = found_relative_native; System::printf( "\n configure_file(\"${CURRENT_BUILDTREES_DIR}/%s/%s\" \"${CURRENT_PACKAGES_DIR}/share/%s/copyright\" COPYONLY)\n", relative_path.generic_string(), diff --git a/toolsrc/src/vcpkg/vcpkgpaths.cpp b/toolsrc/src/vcpkg/vcpkgpaths.cpp index 3d5a3bd6f..30f7367bf 100644 --- a/toolsrc/src/vcpkg/vcpkgpaths.cpp +++ b/toolsrc/src/vcpkg/vcpkgpaths.cpp @@ -229,7 +229,12 @@ If you wish to silence this error and use classic mode, you can: m_pimpl->triplets_dirs.emplace_back(community_triplets); } - fs::path VcpkgPaths::package_dir(const PackageSpec& spec) const { return this->packages / spec.dir(); } + fs::path VcpkgPaths::package_dir(const PackageSpec& spec) const { return this->packages / fs::u8path(spec.dir()); } + fs::path VcpkgPaths::build_dir(const PackageSpec& spec) const { return this->buildtrees / fs::u8path(spec.name()); } + fs::path VcpkgPaths::build_dir(const std::string& package_name) const + { + return this->buildtrees / fs::u8path(package_name); + } fs::path VcpkgPaths::build_info_file_path(const PackageSpec& spec) const { @@ -389,9 +394,7 @@ If you wish to silence this error and use classic mode, you can: { StringView flag; bool enabled; - } flags[] = { - {VcpkgCmdArguments::MANIFEST_MODE_FEATURE, manifest_mode_enabled()} - }; + } flags[] = {{VcpkgCmdArguments::MANIFEST_MODE_FEATURE, manifest_mode_enabled()}}; for (const auto& flag : flags) { |
