diff --git a/azure-pipelines/e2e-ports/hash-additional/vcpkg-test-hash-additional/portfile.cmake b/azure-pipelines/e2e-ports/hash-additional/vcpkg-test-hash-additional/portfile.cmake index a93d39acf1..d0eee7beeb 100644 --- a/azure-pipelines/e2e-ports/hash-additional/vcpkg-test-hash-additional/portfile.cmake +++ b/azure-pipelines/e2e-ports/hash-additional/vcpkg-test-hash-additional/portfile.cmake @@ -1,13 +1,12 @@ -set(ABI_FILE "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}.vcpkg_abi_info.txt") -file(STRINGS "${ABI_FILE}" lines) -list(GET lines 0 first_line) - -set(expected "additional_file_0 61ba0c7fc1f696e28c1b7aa9460980a571025ff8c97bb90a57e990463aa25660") - -if(first_line STREQUAL "${expected}") - message(STATUS "Test successful!") -else() - message(FATAL_ERROR "First line in abi info ( ${ABI_FILE} ) is not the additional file to be hashed but:\n first_line: '${first_line}'\n expected: '${expected}' ") -endif() - -set(VCPKG_POLICY_EMPTY_PACKAGE enabled) +set(ABI_FILE "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}.vcpkg_abi_info.txt") +file(STRINGS "${ABI_FILE}" lines) +list(FILTER lines INCLUDE REGEX "additional_file_.+") + +if(lines STREQUAL "additional_file_0 61ba0c7fc1f696e28c1b7aa9460980a571025ff8c97bb90a57e990463aa25660") + message(STATUS "Test successful!") +else() + list(JOIN lines "\n " lines) + message(FATAL_ERROR "Expected exactly one expected additional file in ${ABI_FILE} but got:\n ${lines}") +endif() + +set(VCPKG_POLICY_EMPTY_PACKAGE enabled) diff --git a/include/vcpkg/commands.build.h b/include/vcpkg/commands.build.h index 4d86057468..1538b2cc4b 100644 --- a/include/vcpkg/commands.build.h +++ b/include/vcpkg/commands.build.h @@ -268,7 +268,7 @@ namespace vcpkg // The parts of AbiInfo which depend only on the port directory and thus can be reused across multiple feature // builds - struct PortDirAbiInfoCacheEntry + struct SpecAbiInfoCacheEntry { std::vector abi_entries; std::vector files; @@ -276,7 +276,7 @@ namespace vcpkg Json::Object heuristic_resources; }; - using PortDirAbiInfoCache = Cache; + using SpecAbiInfoCache = Cache; struct CompilerInfo { @@ -313,7 +313,7 @@ namespace vcpkg ActionPlan& action_plan, const CMakeVars::CMakeVarProvider& var_provider, const StatusParagraphs& status_db, - PortDirAbiInfoCache& port_dir_cache); + SpecAbiInfoCache& port_dir_cache); struct EnvCache { diff --git a/src/vcpkg/commands.build.cpp b/src/vcpkg/commands.build.cpp index 62e4b925cf..f5d241a1b7 100644 --- a/src/vcpkg/commands.build.cpp +++ b/src/vcpkg/commands.build.cpp @@ -1353,7 +1353,7 @@ namespace vcpkg InstallPlanAction& action, std::unique_ptr&& proto_pre_build_info, Span dependency_abis, - PortDirAbiInfoCache& port_dir_cache, + SpecAbiInfoCache& spec_abi_cache, Cache>& grdk_cache) { Checks::check_exit(VCPKG_LINE_INFO, static_cast(proto_pre_build_info)); @@ -1399,8 +1399,8 @@ namespace vcpkg abi_entries_from_pre_build_info(fs, grdk_cache, pre_build_info, abi_tag_entries); auto&& port_dir = action.source_control_file_and_location.value_or_exit(VCPKG_LINE_INFO).port_directory(); - const auto& port_dir_cache_entry = port_dir_cache.get_lazy(port_dir, [&]() { - PortDirAbiInfoCacheEntry port_dir_cache_entry; + const auto& port_dir_cache_entry = spec_abi_cache.get_lazy(action.spec, [&]() { + SpecAbiInfoCacheEntry port_dir_cache_entry; std::string portfile_cmake_contents; { @@ -1419,8 +1419,6 @@ namespace vcpkg port_dir_cache_entry.files = std::move(rel_port_files); } const auto& rel_port_files = port_dir_cache_entry.files; - // Technically the pre_build_info is not part of the port_dir cache key, but a given port_dir is only going - // to be associated with 1 port for (size_t i = 0; i < abi_info.pre_build_info->hash_additional_files.size(); ++i) { const auto& file = abi_info.pre_build_info->hash_additional_files[i]; @@ -1471,22 +1469,6 @@ namespace vcpkg Util::Vectors::append(abi_tag_entries, port_dir_cache_entry.abi_entries); - { - size_t i = 0; - for (auto& filestr : abi_info.pre_build_info->hash_additional_files) - { - Path file(filestr); - if (file.is_relative() || !fs.is_regular_file(file)) - { - Checks::msg_exit_with_message( - VCPKG_LINE_INFO, msgInvalidValueHashAdditionalFiles, msg::path = file); - } - const auto hash = - vcpkg::Hash::get_file_hash(fs, file, Hash::Algorithm::Sha256).value_or_exit(VCPKG_LINE_INFO); - abi_tag_entries.emplace_back(fmt::format("additional_file_{}", i++), hash); - } - } - for (size_t i = 0; i < abi_info.pre_build_info->post_portfile_includes.size(); ++i) { auto& file = abi_info.pre_build_info->post_portfile_includes[i]; @@ -1567,15 +1549,15 @@ namespace vcpkg const CMakeVars::CMakeVarProvider& var_provider, const StatusParagraphs& status_db) { - PortDirAbiInfoCache port_dir_cache; - compute_all_abis(paths, action_plan, var_provider, status_db, port_dir_cache); + SpecAbiInfoCache spec_abi_cache; + compute_all_abis(paths, action_plan, var_provider, status_db, spec_abi_cache); } void compute_all_abis(const VcpkgPaths& paths, ActionPlan& action_plan, const CMakeVars::CMakeVarProvider& var_provider, const StatusParagraphs& status_db, - PortDirAbiInfoCache& port_dir_cache) + SpecAbiInfoCache& spec_abi_cache) { Cache> grdk_cache; for (auto it = action_plan.install_actions.begin(); it != action_plan.install_actions.end(); ++it) @@ -1622,7 +1604,7 @@ namespace vcpkg action.spec.triplet(), var_provider.get_tag_vars(action.spec).value_or_exit(VCPKG_LINE_INFO)), dependency_abis, - port_dir_cache, + spec_abi_cache, grdk_cache); } } diff --git a/src/vcpkg/commands.test-features.cpp b/src/vcpkg/commands.test-features.cpp index 63244284b4..0799327417 100644 --- a/src/vcpkg/commands.test-features.cpp +++ b/src/vcpkg/commands.test-features.cpp @@ -563,7 +563,7 @@ namespace vcpkg KeepGoing::Yes, }; StatusParagraphs status_db = database_load_collapse(fs, paths.installed()); - PortDirAbiInfoCache port_dir_abi_info_cache; + SpecAbiInfoCache spec_abi_info_cache; // check what should be tested std::vector specs_to_test; @@ -708,7 +708,7 @@ namespace vcpkg { if (test_spec.plan.unsupported_features.empty()) { - compute_all_abis(paths, test_spec.plan, var_provider, empty_status_db, port_dir_abi_info_cache); + compute_all_abis(paths, test_spec.plan, var_provider, empty_status_db, spec_abi_info_cache); } }