mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-11-28 21:09:01 +08:00
[build.cpp] Clang tidy fixes
This commit is contained in:
parent
30e516cd61
commit
4e4afa29bf
@ -64,7 +64,8 @@ namespace vcpkg::Build::Command
|
||||
const Build::BuildPackageOptions build_package_options{Build::UseHeadVersion::NO,
|
||||
Build::AllowDownloads::YES,
|
||||
Build::CleanBuildtrees::NO,
|
||||
Build::CleanPackages::NO};
|
||||
Build::CleanPackages::NO,
|
||||
Build::DownloadTool::BUILT_IN};
|
||||
|
||||
std::set<std::string> features_as_set(full_spec.features.begin(), full_spec.features.end());
|
||||
features_as_set.emplace("core");
|
||||
@ -210,7 +211,7 @@ namespace vcpkg::Build
|
||||
|
||||
for (auto&& host : host_architectures)
|
||||
{
|
||||
auto it = Util::find_if(toolset.supported_architectures, [&](const ToolsetArchOption& opt) {
|
||||
const auto it = Util::find_if(toolset.supported_architectures, [&](const ToolsetArchOption& opt) {
|
||||
return host == opt.host_arch && target_arch == opt.target_arch;
|
||||
});
|
||||
if (it != toolset.supported_architectures.end()) return it->name;
|
||||
@ -279,7 +280,7 @@ namespace vcpkg::Build
|
||||
{
|
||||
const Triplet& triplet = config.triplet;
|
||||
|
||||
auto dep_strings =
|
||||
const std::vector<std::string> dep_strings =
|
||||
Util::fmap_flatten(config.feature_list, [&](std::string const& feature) -> std::vector<std::string> {
|
||||
if (feature == "core")
|
||||
{
|
||||
@ -302,7 +303,7 @@ namespace vcpkg::Build
|
||||
if (fspec.feature().empty())
|
||||
{
|
||||
// reference to default features
|
||||
auto it = status_db.find_installed(fspec.spec());
|
||||
const auto it = status_db.find_installed(fspec.spec());
|
||||
if (it == status_db.end())
|
||||
{
|
||||
// not currently installed, so just leave the default reference so it will fail later
|
||||
@ -310,9 +311,9 @@ namespace vcpkg::Build
|
||||
}
|
||||
else
|
||||
{
|
||||
ret.push_back(FeatureSpec{fspec.spec(), "core"});
|
||||
ret.emplace_back(fspec.spec(), "core");
|
||||
for (auto&& default_feature : it->get()->package.default_features)
|
||||
ret.push_back(FeatureSpec{fspec.spec(), default_feature});
|
||||
ret.emplace_back(fspec.spec(), default_feature);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -463,7 +464,7 @@ namespace vcpkg::Build
|
||||
|
||||
abi_tag_entries.emplace_back(AbiEntry{"triplet", pre_build_info.triplet_abi_tag});
|
||||
|
||||
std::string features = Strings::join(";", config.feature_list);
|
||||
const std::string features = Strings::join(";", config.feature_list);
|
||||
abi_tag_entries.emplace_back(AbiEntry{"features", features});
|
||||
|
||||
if (config.build_package_options.use_head_version == UseHeadVersion::YES)
|
||||
@ -471,7 +472,7 @@ namespace vcpkg::Build
|
||||
|
||||
Util::sort(abi_tag_entries);
|
||||
|
||||
std::string full_abi_info =
|
||||
const std::string full_abi_info =
|
||||
Strings::join("", abi_tag_entries, [](const AbiEntry& p) { return p.key + " " + p.value + "\n"; });
|
||||
|
||||
if (GlobalState::debugging)
|
||||
@ -491,19 +492,17 @@ namespace vcpkg::Build
|
||||
{
|
||||
std::error_code ec;
|
||||
fs.create_directories(paths.buildtrees / name, ec);
|
||||
auto abi_file_path = paths.buildtrees / name / (triplet.canonical_name() + ".vcpkg_abi_info.txt");
|
||||
const auto abi_file_path = paths.buildtrees / name / (triplet.canonical_name() + ".vcpkg_abi_info.txt");
|
||||
fs.write_contents(abi_file_path, full_abi_info);
|
||||
|
||||
return AbiTagAndFile{Commands::Hash::get_file_hash(paths, abi_file_path, "SHA1"), abi_file_path};
|
||||
}
|
||||
else
|
||||
{
|
||||
System::println(
|
||||
"Warning: binary caching disabled because abi keys are missing values:\n%s",
|
||||
Strings::join("", abi_tag_entries_missing, [](const AbiEntry& e) { return " " + e.key + "\n"; }));
|
||||
|
||||
return nullopt;
|
||||
}
|
||||
System::println(
|
||||
"Warning: binary caching disabled because abi keys are missing values:\n%s",
|
||||
Strings::join("", abi_tag_entries_missing, [](const AbiEntry& e) { return " " + e.key + "\n"; }));
|
||||
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
static void decompress_archive(const VcpkgPaths& paths, const PackageSpec& spec, const fs::path& archive_path)
|
||||
@ -518,10 +517,10 @@ namespace vcpkg::Build
|
||||
Checks::check_exit(VCPKG_LINE_INFO, files.empty(), "unable to clear path: %s", pkg_path.u8string());
|
||||
|
||||
#if defined(_WIN32)
|
||||
auto&& _7za = paths.get_tool_exe(Tools::SEVEN_ZIP);
|
||||
auto&& seven_zip_exe = paths.get_tool_exe(Tools::SEVEN_ZIP);
|
||||
|
||||
System::cmd_execute_clean(Strings::format(
|
||||
R"("%s" x "%s" -o"%s" -y >nul)", _7za.u8string(), archive_path.u8string(), pkg_path.u8string()));
|
||||
R"("%s" x "%s" -o"%s" -y >nul)", seven_zip_exe.u8string(), archive_path.u8string(), pkg_path.u8string()));
|
||||
#else
|
||||
System::cmd_execute_clean(Strings::format(
|
||||
R"(unzip -qq "%s" "-d%s")", archive_path.u8string(), pkg_path.u8string()));
|
||||
@ -538,11 +537,11 @@ namespace vcpkg::Build
|
||||
Checks::check_exit(
|
||||
VCPKG_LINE_INFO, !fs.exists(tmp_archive_path), "Could not remove file: %s", tmp_archive_path.u8string());
|
||||
#if defined(_WIN32)
|
||||
auto&& _7za = paths.get_tool_exe(Tools::SEVEN_ZIP);
|
||||
auto&& seven_zip_exe = paths.get_tool_exe(Tools::SEVEN_ZIP);
|
||||
|
||||
System::cmd_execute_clean(Strings::format(
|
||||
R"("%s" a "%s" "%s\*" >nul)",
|
||||
_7za.u8string(),
|
||||
seven_zip_exe.u8string(),
|
||||
tmp_archive_path.u8string(),
|
||||
paths.package_dir(spec).u8string()));
|
||||
#else
|
||||
@ -584,7 +583,7 @@ namespace vcpkg::Build
|
||||
for (auto&& pspec : dep_pspecs)
|
||||
{
|
||||
if (pspec == spec) continue;
|
||||
auto status_it = status_db.find_installed(pspec);
|
||||
const auto status_it = status_db.find_installed(pspec);
|
||||
Checks::check_exit(VCPKG_LINE_INFO, status_it != status_db.end());
|
||||
dependency_abis.emplace_back(
|
||||
AbiEntry{status_it->get()->package.spec.name(), status_it->get()->package.abi});
|
||||
@ -594,17 +593,15 @@ namespace vcpkg::Build
|
||||
|
||||
auto maybe_abi_tag_and_file = compute_abi_tag(paths, config, pre_build_info, dependency_abis);
|
||||
|
||||
std::unique_ptr<BinaryControlFile> bcf;
|
||||
|
||||
auto abi_tag_and_file = maybe_abi_tag_and_file.get();
|
||||
const auto abi_tag_and_file = maybe_abi_tag_and_file.get();
|
||||
|
||||
if (GlobalState::g_binary_caching && abi_tag_and_file)
|
||||
{
|
||||
auto archives_root_dir = paths.root / "archives";
|
||||
auto archive_name = abi_tag_and_file->tag + ".zip";
|
||||
auto archive_subpath = fs::u8path(abi_tag_and_file->tag.substr(0, 2)) / archive_name;
|
||||
auto archive_path = archives_root_dir / archive_subpath;
|
||||
auto archive_tombstone_path = archives_root_dir / "fail" / archive_subpath;
|
||||
const fs::path archives_root_dir = paths.root / "archives";
|
||||
const std::string archive_name = abi_tag_and_file->tag + ".zip";
|
||||
const fs::path archive_subpath = fs::u8path(abi_tag_and_file->tag.substr(0, 2)) / archive_name;
|
||||
const fs::path archive_path = archives_root_dir / archive_subpath;
|
||||
const fs::path archive_tombstone_path = archives_root_dir / "fail" / archive_subpath;
|
||||
|
||||
if (fs.exists(archive_path))
|
||||
{
|
||||
@ -613,10 +610,12 @@ namespace vcpkg::Build
|
||||
decompress_archive(paths, spec, archive_path);
|
||||
|
||||
auto maybe_bcf = Paragraphs::try_load_cached_package(paths, spec);
|
||||
bcf = std::make_unique<BinaryControlFile>(std::move(maybe_bcf).value_or_exit(VCPKG_LINE_INFO));
|
||||
std::unique_ptr<BinaryControlFile> bcf =
|
||||
std::make_unique<BinaryControlFile>(std::move(maybe_bcf).value_or_exit(VCPKG_LINE_INFO));
|
||||
return {BuildResult::SUCCEEDED, std::move(bcf)};
|
||||
}
|
||||
else if (fs.exists(archive_tombstone_path))
|
||||
|
||||
if (fs.exists(archive_tombstone_path))
|
||||
{
|
||||
System::println("Found failure tombstone: %s", archive_tombstone_path.u8string());
|
||||
return BuildResult::BUILD_FAILED;
|
||||
@ -635,7 +634,7 @@ namespace vcpkg::Build
|
||||
|
||||
if (result.code == BuildResult::SUCCEEDED)
|
||||
{
|
||||
auto tmp_archive_path = paths.buildtrees / spec.name() / (spec.triplet().to_string() + ".zip");
|
||||
const auto tmp_archive_path = paths.buildtrees / spec.name() / (spec.triplet().to_string() + ".zip");
|
||||
|
||||
compress_archive(paths, spec, tmp_archive_path);
|
||||
|
||||
@ -656,11 +655,9 @@ namespace vcpkg::Build
|
||||
|
||||
return result;
|
||||
}
|
||||
else
|
||||
{
|
||||
return do_build_package_and_clean_buildtrees(
|
||||
paths, pre_build_info, spec, maybe_abi_tag_and_file.value_or(AbiTagAndFile{}).tag, config, status_db);
|
||||
}
|
||||
|
||||
return do_build_package_and_clean_buildtrees(
|
||||
paths, pre_build_info, spec, maybe_abi_tag_and_file.value_or(AbiTagAndFile{}).tag, config, status_db);
|
||||
}
|
||||
|
||||
const std::string& to_string(const BuildResult build_result)
|
||||
@ -774,7 +771,7 @@ namespace vcpkg::Build
|
||||
const fs::path ports_cmake_script_path = paths.scripts / "get_triplet_environment.cmake";
|
||||
const fs::path triplet_file_path = paths.triplets / (triplet.canonical_name() + ".cmake");
|
||||
|
||||
auto triplet_abi_tag = [&]() {
|
||||
const std::string triplet_abi_tag = [&]() {
|
||||
static std::map<fs::path, std::string> s_hash_cache;
|
||||
|
||||
if (GlobalState::g_binary_caching)
|
||||
|
Loading…
Reference in New Issue
Block a user