From 299c7c730ca759ef3dee365a2ecd7c3dd39db8a6 Mon Sep 17 00:00:00 2001 From: martin-s Date: Tue, 14 Jan 2020 00:31:58 +0000 Subject: Introduce new policy to skip post verification of dll exports (#9642) * - Introduce new policy to skip post verification of dll exports (see issue #9641). * - Fixed line endings. --- scripts/ports.cmake | 3 +++ toolsrc/include/vcpkg/build.h | 2 ++ toolsrc/src/vcpkg/build.cpp | 3 +++ toolsrc/src/vcpkg/postbuildlint.cpp | 10 ++++++++-- 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/scripts/ports.cmake b/scripts/ports.cmake index cdc0bdd99..1aea1ffa3 100644 --- a/scripts/ports.cmake +++ b/scripts/ports.cmake @@ -100,6 +100,9 @@ if(CMD MATCHES "^BUILD$") if (DEFINED VCPKG_POLICY_DLLS_WITHOUT_LIBS) file(APPEND ${BUILD_INFO_FILE_PATH} "PolicyDLLsWithoutLIBs: ${VCPKG_POLICY_DLLS_WITHOUT_LIBS}\n") endif() + if (DEFINED VCPKG_POLICY_DLLS_WITHOUT_EXPORTS) + file(APPEND ${BUILD_INFO_FILE_PATH} "PolicyDLLsWithoutExports: ${VCPKG_POLICY_DLLS_WITHOUT_EXPORTS}\n") + endif() if (DEFINED VCPKG_POLICY_EMPTY_PACKAGE) file(APPEND ${BUILD_INFO_FILE_PATH} "PolicyEmptyPackage: ${VCPKG_POLICY_EMPTY_PACKAGE}\n") endif() diff --git a/toolsrc/include/vcpkg/build.h b/toolsrc/include/vcpkg/build.h index b535698dc..be5424296 100644 --- a/toolsrc/include/vcpkg/build.h +++ b/toolsrc/include/vcpkg/build.h @@ -219,6 +219,7 @@ namespace vcpkg::Build { EMPTY_PACKAGE, DLLS_WITHOUT_LIBS, + DLLS_WITHOUT_EXPORTS, ONLY_RELEASE_CRT, EMPTY_INCLUDE_FOLDER, ALLOW_OBSOLETE_MSVCRT, @@ -229,6 +230,7 @@ namespace vcpkg::Build constexpr std::array G_ALL_POLICIES = { BuildPolicy::EMPTY_PACKAGE, BuildPolicy::DLLS_WITHOUT_LIBS, + BuildPolicy::DLLS_WITHOUT_EXPORTS, BuildPolicy::ONLY_RELEASE_CRT, BuildPolicy::EMPTY_INCLUDE_FOLDER, BuildPolicy::ALLOW_OBSOLETE_MSVCRT, diff --git a/toolsrc/src/vcpkg/build.cpp b/toolsrc/src/vcpkg/build.cpp index 451f72445..f13dd2a25 100644 --- a/toolsrc/src/vcpkg/build.cpp +++ b/toolsrc/src/vcpkg/build.cpp @@ -129,6 +129,7 @@ namespace vcpkg::Build { static const std::string NAME_EMPTY_PACKAGE = "PolicyEmptyPackage"; static const std::string NAME_DLLS_WITHOUT_LIBS = "PolicyDLLsWithoutLIBs"; + static const std::string NAME_DLLS_WITHOUT_EXPORTS = "PolicyDLLsWithoutExports"; static const std::string NAME_ONLY_RELEASE_CRT = "PolicyOnlyReleaseCRT"; static const std::string NAME_EMPTY_INCLUDE_FOLDER = "PolicyEmptyIncludeFolder"; static const std::string NAME_ALLOW_OBSOLETE_MSVCRT = "PolicyAllowObsoleteMsvcrt"; @@ -139,6 +140,7 @@ namespace vcpkg::Build { case BuildPolicy::EMPTY_PACKAGE: return NAME_EMPTY_PACKAGE; case BuildPolicy::DLLS_WITHOUT_LIBS: return NAME_DLLS_WITHOUT_LIBS; + case BuildPolicy::DLLS_WITHOUT_EXPORTS: return NAME_DLLS_WITHOUT_EXPORTS; case BuildPolicy::ONLY_RELEASE_CRT: return NAME_ONLY_RELEASE_CRT; case BuildPolicy::EMPTY_INCLUDE_FOLDER: return NAME_EMPTY_INCLUDE_FOLDER; case BuildPolicy::ALLOW_OBSOLETE_MSVCRT: return NAME_ALLOW_OBSOLETE_MSVCRT; @@ -152,6 +154,7 @@ namespace vcpkg::Build { case BuildPolicy::EMPTY_PACKAGE: return "VCPKG_POLICY_EMPTY_PACKAGE"; case BuildPolicy::DLLS_WITHOUT_LIBS: return "VCPKG_POLICY_DLLS_WITHOUT_LIBS"; + case BuildPolicy::DLLS_WITHOUT_EXPORTS: return "VCPKG_POLICY_DLLS_WITHOUT_EXPORTS"; case BuildPolicy::ONLY_RELEASE_CRT: return "VCPKG_POLICY_ONLY_RELEASE_CRT"; case BuildPolicy::EMPTY_INCLUDE_FOLDER: return "VCPKG_POLICY_EMPTY_INCLUDE_FOLDER"; case BuildPolicy::ALLOW_OBSOLETE_MSVCRT: return "VCPKG_POLICY_ALLOW_OBSOLETE_MSVCRT"; diff --git a/toolsrc/src/vcpkg/postbuildlint.cpp b/toolsrc/src/vcpkg/postbuildlint.cpp index a85d879fe..2a13d2786 100644 --- a/toolsrc/src/vcpkg/postbuildlint.cpp +++ b/toolsrc/src/vcpkg/postbuildlint.cpp @@ -295,8 +295,10 @@ namespace vcpkg::PostBuildLint return LintStatus::SUCCESS; } - static LintStatus check_exports_of_dlls(const std::vector& dlls, const fs::path& dumpbin_exe) + static LintStatus check_exports_of_dlls(const Build::BuildPolicies& policies, const std::vector& dlls, const fs::path& dumpbin_exe) { + if (policies.is_enabled(BuildPolicy::DLLS_WITHOUT_EXPORTS)) return LintStatus::SUCCESS; + std::vector dlls_with_no_exports; for (const fs::path& dll : dlls) { @@ -316,6 +318,10 @@ namespace vcpkg::PostBuildLint System::print2(System::Color::warning, "The following DLLs have no exports:\n"); Files::print_paths(dlls_with_no_exports); System::print2(System::Color::warning, "DLLs without any exports are likely a bug in the build script.\n"); + System::printf(System::Color::warning, + "If this is intended, add the following line in the portfile:\n" + " SET(%s enabled)\n", + to_cmake_variable(BuildPolicy::DLLS_WITHOUT_EXPORTS)); return LintStatus::ERROR_DETECTED; } @@ -809,7 +815,7 @@ namespace vcpkg::PostBuildLint if (!toolset.dumpbin.empty()) { - error_count += check_exports_of_dlls(dlls, toolset.dumpbin); + error_count += check_exports_of_dlls(build_info.policies, dlls, toolset.dumpbin); error_count += check_uwp_bit_of_dlls(pre_build_info.cmake_system_name, dlls, toolset.dumpbin); error_count += check_outdated_crt_linkage_of_dlls(dlls, toolset.dumpbin, build_info, pre_build_info); -- cgit v1.2.3