diff --git a/include/vcpkg/abi.h b/include/vcpkg/abi.h index 5fc781ca4c..d11ad0d3fa 100644 --- a/include/vcpkg/abi.h +++ b/include/vcpkg/abi.h @@ -13,7 +13,6 @@ #include #include - #include #include #include diff --git a/src/vcpkg-test/spdx.cpp b/src/vcpkg-test/spdx.cpp index f9cfdc9923..047a4fe9e1 100644 --- a/src/vcpkg-test/spdx.cpp +++ b/src/vcpkg-test/spdx.cpp @@ -26,18 +26,11 @@ TEST_CASE ("spdx maximum serialization", "[spdx]") auto& abi = *(ipa.abi_info = AbiInfo{}).get(); abi.package_abi = "ABIHASH"; - std::vector port_abi{ - {"vcpkg.json", "vcpkg.json-hash"}, - {"portfile.cmake", "portfile.cmake-hash"}, - {"patches/patch1.diff", "patch1.diff-hash"} - }; + std::vector port_abi{{"vcpkg.json", "vcpkg.json-hash"}, + {"portfile.cmake", "portfile.cmake-hash"}, + {"patches/patch1.diff", "patch1.diff-hash"}}; - const auto sbom = - create_spdx_sbom(ipa, - port_abi, - "now", - "https://test-document-namespace", - {}); + const auto sbom = create_spdx_sbom(ipa, port_abi, "now", "https://test-document-namespace", {}); auto expected = Json::parse(R"json( { @@ -184,16 +177,9 @@ TEST_CASE ("spdx minimum serialization", "[spdx]") InstallPlanAction ipa(spec, scfl, "test_packages_root", RequestType::USER_REQUESTED, Test::X86_WINDOWS, {}, {}, {}); auto& abi = *(ipa.abi_info = AbiInfo{}).get(); abi.package_abi = "deadbeef"; - std::vector port_abi{ - {"vcpkg.json", "hash-vcpkg.json"}, - {"portfile.cmake", "hash-portfile.cmake"} - }; + std::vector port_abi{{"vcpkg.json", "hash-vcpkg.json"}, {"portfile.cmake", "hash-portfile.cmake"}}; - const auto sbom = create_spdx_sbom(ipa, - port_abi, - "now+1", - "https://test-document-namespace-2", - {}); + const auto sbom = create_spdx_sbom(ipa, port_abi, "now+1", "https://test-document-namespace-2", {}); auto expected = Json::parse(R"json( { diff --git a/src/vcpkg/abi.cpp b/src/vcpkg/abi.cpp index a7cd34376d..4312d62ac9 100644 --- a/src/vcpkg/abi.cpp +++ b/src/vcpkg/abi.cpp @@ -38,8 +38,7 @@ namespace vcpkg std::vector port_files_abi; }; - static std::string grdk_hash(const Filesystem& fs, - const PreBuildInfo& pre_build_info) + static std::string grdk_hash(const Filesystem& fs, const PreBuildInfo& pre_build_info) { static const Cache> grdk_cache; if (auto game_dk_latest = pre_build_info.gamedk_latest_path.get()) @@ -98,7 +97,8 @@ namespace vcpkg auto& fs = paths.get_filesystem(); abi_entries.emplace_back("cmake", paths.get_tool_version(Tools::CMAKE, stdout_sink)); - abi_entries.emplace_back("ports.cmake", Hash::get_file_hash(fs, paths.ports_cmake, Hash::Algorithm::Sha256).value_or("")); + abi_entries.emplace_back("ports.cmake", + Hash::get_file_hash(fs, paths.ports_cmake, Hash::Algorithm::Sha256).value_or("")); abi_entries.emplace_back("post_build_checks", "2"); // This #ifdef is mirrored in tools.cpp's PowershellProvider @@ -116,7 +116,8 @@ namespace vcpkg std::vector helpers(files.size()); parallel_transform(files.begin(), files.size(), helpers.begin(), [&fs](auto&& file) { - return AbiEntry{file.stem().to_string(), Hash::get_file_hash(fs, file, Hash::Algorithm::Sha256).value_or("")}; + return AbiEntry{file.stem().to_string(), + Hash::get_file_hash(fs, file, Hash::Algorithm::Sha256).value_or("")}; }); return helpers; } @@ -260,15 +261,16 @@ namespace vcpkg { if (!dependency_abis.empty()) { - auto dep_no_hash_it = std::find_if( - dependency_abis.begin(), dependency_abis.end(), [](const auto& dep_abi) { return dep_abi.value.empty(); }); + auto dep_no_hash_it = std::find_if(dependency_abis.begin(), dependency_abis.end(), [](const auto& dep_abi) { + return dep_abi.value.empty(); + }); if (dep_no_hash_it != dependency_abis.end()) { Debug::print("Binary caching for package ", - spec, - " is disabled due to missing abi info for ", - dep_no_hash_it->key, - '\n'); + spec, + " is disabled due to missing abi info for ", + dep_no_hash_it->key, + '\n'); return false; } } @@ -277,10 +279,10 @@ namespace vcpkg // PRE: initialize_abi_tag() was called and returned true static PackageAbiResult make_abi_tag(const VcpkgPaths& paths, - InstallPlanAction& action, - View common_abi, - std::vector&& dependency_abis, - const AsyncLazy>& cmake_script_hashes) + InstallPlanAction& action, + View common_abi, + std::vector&& dependency_abis, + const AsyncLazy>& cmake_script_hashes) { auto& fs = paths.get_filesystem(); AbiInfo& abi_info = *action.abi_info.get(); @@ -291,13 +293,13 @@ namespace vcpkg // abi tags from prebuildinfo abi_entries_from_pre_build_info(fs, *abi_info.pre_build_info, abi_tag_entries); - + auto& scfl = action.source_control_file_and_location.value_or_exit(VCPKG_LINE_INFO); // portfile hashes/contents auto&& [port_files_abi, cmake_contents] = get_port_files(fs, scfl); abi_tag_entries.insert(abi_tag_entries.end(), port_files_abi.cbegin(), port_files_abi.cend()); - + // cmake helpers (access to cmake helper hashes in cache not in parallel) for (auto&& helper : cmake_script_hashes.get()) { @@ -332,7 +334,8 @@ namespace vcpkg std::string full_abi_info = Strings::join("", abi_tag_entries, [](const AbiEntry& p) { return p.key + " " + p.value + "\n"; }); abi_info.package_abi = Hash::get_string_sha256(full_abi_info); - abi_info.abi_tag_file.emplace(paths.build_dir(action.spec) / action.spec.triplet().canonical_name() + ".vcpkg_abi_info.txt"); + abi_info.abi_tag_file.emplace(paths.build_dir(action.spec) / action.spec.triplet().canonical_name() + + ".vcpkg_abi_info.txt"); return {action, std::move(full_abi_info), std::move(cmake_contents), std::move(port_files_abi)}; } @@ -382,7 +385,7 @@ namespace vcpkg } return dependency_abis; } - + void compute_all_abis(const VcpkgPaths& paths, ActionPlan& action_plan, const CMakeVars::CMakeVarProvider& var_provider, @@ -424,17 +427,23 @@ namespace vcpkg } } - abi_results.push_back(make_abi_tag(paths, action, common_abi, std::move(dependency_abis), cmake_script_hashes)); + abi_results.push_back( + make_abi_tag(paths, action, common_abi, std::move(dependency_abis), cmake_script_hashes)); } // populate abi tag for (auto&& abi_result : abi_results) { // write abi tag file - fs.write_contents_and_dirs(abi_result.action.abi_info.value_or_exit(VCPKG_LINE_INFO).abi_tag_file.value_or_exit(VCPKG_LINE_INFO), abi_result.abi_str, VCPKG_LINE_INFO); - + fs.write_contents_and_dirs( + abi_result.action.abi_info.value_or_exit(VCPKG_LINE_INFO).abi_tag_file.value_or_exit(VCPKG_LINE_INFO), + abi_result.abi_str, + VCPKG_LINE_INFO); + // make and write sbom file - auto& scf = abi_result.action.source_control_file_and_location.value_or_exit(VCPKG_LINE_INFO).source_control_file; - std::vector heuristic_resources{run_resource_heuristics(abi_result.cmake_content, scf->core_paragraph->raw_version)}; + auto& scf = + abi_result.action.source_control_file_and_location.value_or_exit(VCPKG_LINE_INFO).source_control_file; + std::vector heuristic_resources{ + run_resource_heuristics(abi_result.cmake_content, scf->core_paragraph->raw_version)}; write_sbom(paths, abi_result.action, std::move(heuristic_resources), abi_result.port_files_abi); } } diff --git a/src/vcpkg/commands.build.cpp b/src/vcpkg/commands.build.cpp index edecc1732f..269ee9f9a1 100644 --- a/src/vcpkg/commands.build.cpp +++ b/src/vcpkg/commands.build.cpp @@ -1036,7 +1036,6 @@ namespace vcpkg return result; } - ExtendedBuildResult build_package(const VcpkgCmdArguments& args, const VcpkgPaths& paths, const InstallPlanAction& action, diff --git a/src/vcpkg/spdx.cpp b/src/vcpkg/spdx.cpp index 59c0d47357..0f80474313 100644 --- a/src/vcpkg/spdx.cpp +++ b/src/vcpkg/spdx.cpp @@ -258,27 +258,25 @@ void vcpkg::write_sbom(const VcpkgPaths& paths, const InstallPlanAction& action, std::vector heuristic_resources, const std::vector& port_files_abi) - { - auto& fs = paths.get_filesystem(); - const auto& scfl = action.source_control_file_and_location.value_or_exit(VCPKG_LINE_INFO); - const auto& scf = *scfl.source_control_file; +{ + auto& fs = paths.get_filesystem(); + const auto& scfl = action.source_control_file_and_location.value_or_exit(VCPKG_LINE_INFO); + const auto& scf = *scfl.source_control_file; - auto doc_ns = Strings::concat("https://spdx.org/spdxdocs/", - scf.core_paragraph->name, - '-', - action.spec.triplet(), - '-', - scf.to_version(), - '-', - generate_random_UUID()); + auto doc_ns = Strings::concat("https://spdx.org/spdxdocs/", + scf.core_paragraph->name, + '-', + action.spec.triplet(), + '-', + scf.to_version(), + '-', + generate_random_UUID()); - const auto now = CTime::now_string(); + const auto now = CTime::now_string(); - const auto json_path = - action.package_dir.value_or_exit(VCPKG_LINE_INFO) / "share" / action.spec.name() / "vcpkg.spdx.json"; - fs.write_contents_and_dirs( - json_path, - create_spdx_sbom( - action, port_files_abi, now, doc_ns, std::move(heuristic_resources)), - VCPKG_LINE_INFO); - } + const auto json_path = + action.package_dir.value_or_exit(VCPKG_LINE_INFO) / "share" / action.spec.name() / "vcpkg.spdx.json"; + fs.write_contents_and_dirs(json_path, + create_spdx_sbom(action, port_files_abi, now, doc_ns, std::move(heuristic_resources)), + VCPKG_LINE_INFO); +}