Merge pull request #9901 from Neumann-A/skip_dumpbin

[vcpkg] Add policy VCPKG_POLICY_SKIP_DUMPBIN_CHECKS
This commit is contained in:
Robert Schumacher 2020-02-06 15:41:38 -08:00 committed by GitHub
commit 5affb590fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 10 deletions

View File

@ -114,6 +114,9 @@ if(CMD MATCHES "^BUILD$")
if (DEFINED VCPKG_POLICY_ALLOW_RESTRICTED_HEADERS) if (DEFINED VCPKG_POLICY_ALLOW_RESTRICTED_HEADERS)
file(APPEND ${BUILD_INFO_FILE_PATH} "PolicyAllowRestrictedHeaders: ${VCPKG_POLICY_ALLOW_RESTRICTED_HEADERS}\n") file(APPEND ${BUILD_INFO_FILE_PATH} "PolicyAllowRestrictedHeaders: ${VCPKG_POLICY_ALLOW_RESTRICTED_HEADERS}\n")
endif() endif()
if (DEFINED VCPKG_POLICY_SKIP_DUMPBIN_CHECKS)
file(APPEND ${BUILD_INFO_FILE_PATH} "PolicySkipDumpbinChecks: ${VCPKG_POLICY_SKIP_DUMPBIN_CHECKS}\n")
endif()
if (DEFINED VCPKG_HEAD_VERSION) if (DEFINED VCPKG_HEAD_VERSION)
file(APPEND ${BUILD_INFO_FILE_PATH} "Version: ${VCPKG_HEAD_VERSION}\n") file(APPEND ${BUILD_INFO_FILE_PATH} "Version: ${VCPKG_HEAD_VERSION}\n")
endif() endif()

View File

@ -240,6 +240,7 @@ namespace vcpkg::Build
EMPTY_INCLUDE_FOLDER, EMPTY_INCLUDE_FOLDER,
ALLOW_OBSOLETE_MSVCRT, ALLOW_OBSOLETE_MSVCRT,
ALLOW_RESTRICTED_HEADERS, ALLOW_RESTRICTED_HEADERS,
SKIP_DUMPBIN_CHECKS,
// Must be last // Must be last
COUNT, COUNT,
}; };
@ -252,6 +253,7 @@ namespace vcpkg::Build
BuildPolicy::EMPTY_INCLUDE_FOLDER, BuildPolicy::EMPTY_INCLUDE_FOLDER,
BuildPolicy::ALLOW_OBSOLETE_MSVCRT, BuildPolicy::ALLOW_OBSOLETE_MSVCRT,
BuildPolicy::ALLOW_RESTRICTED_HEADERS, BuildPolicy::ALLOW_RESTRICTED_HEADERS,
BuildPolicy::SKIP_DUMPBIN_CHECKS
}; };
const std::string& to_string(BuildPolicy policy); const std::string& to_string(BuildPolicy policy);

View File

@ -173,6 +173,7 @@ namespace vcpkg::Build
static const std::string NAME_EMPTY_INCLUDE_FOLDER = "PolicyEmptyIncludeFolder"; static const std::string NAME_EMPTY_INCLUDE_FOLDER = "PolicyEmptyIncludeFolder";
static const std::string NAME_ALLOW_OBSOLETE_MSVCRT = "PolicyAllowObsoleteMsvcrt"; static const std::string NAME_ALLOW_OBSOLETE_MSVCRT = "PolicyAllowObsoleteMsvcrt";
static const std::string NAME_ALLOW_RESTRICTED_HEADERS = "PolicyAllowRestrictedHeaders"; static const std::string NAME_ALLOW_RESTRICTED_HEADERS = "PolicyAllowRestrictedHeaders";
static const std::string NAME_SKIP_DUMPBIN_CHECKS = "PolicySkipDumpbinChecks";
const std::string& to_string(BuildPolicy policy) const std::string& to_string(BuildPolicy policy)
{ {
@ -185,6 +186,7 @@ namespace vcpkg::Build
case BuildPolicy::EMPTY_INCLUDE_FOLDER: return NAME_EMPTY_INCLUDE_FOLDER; case BuildPolicy::EMPTY_INCLUDE_FOLDER: return NAME_EMPTY_INCLUDE_FOLDER;
case BuildPolicy::ALLOW_OBSOLETE_MSVCRT: return NAME_ALLOW_OBSOLETE_MSVCRT; case BuildPolicy::ALLOW_OBSOLETE_MSVCRT: return NAME_ALLOW_OBSOLETE_MSVCRT;
case BuildPolicy::ALLOW_RESTRICTED_HEADERS: return NAME_ALLOW_RESTRICTED_HEADERS; case BuildPolicy::ALLOW_RESTRICTED_HEADERS: return NAME_ALLOW_RESTRICTED_HEADERS;
case BuildPolicy::SKIP_DUMPBIN_CHECKS: return NAME_SKIP_DUMPBIN_CHECKS;
default: Checks::unreachable(VCPKG_LINE_INFO); default: Checks::unreachable(VCPKG_LINE_INFO);
} }
} }
@ -200,6 +202,7 @@ namespace vcpkg::Build
case BuildPolicy::EMPTY_INCLUDE_FOLDER: return "VCPKG_POLICY_EMPTY_INCLUDE_FOLDER"; case BuildPolicy::EMPTY_INCLUDE_FOLDER: return "VCPKG_POLICY_EMPTY_INCLUDE_FOLDER";
case BuildPolicy::ALLOW_OBSOLETE_MSVCRT: return "VCPKG_POLICY_ALLOW_OBSOLETE_MSVCRT"; case BuildPolicy::ALLOW_OBSOLETE_MSVCRT: return "VCPKG_POLICY_ALLOW_OBSOLETE_MSVCRT";
case BuildPolicy::ALLOW_RESTRICTED_HEADERS: return "VCPKG_POLICY_ALLOW_RESTRICTED_HEADERS"; case BuildPolicy::ALLOW_RESTRICTED_HEADERS: return "VCPKG_POLICY_ALLOW_RESTRICTED_HEADERS";
case BuildPolicy::SKIP_DUMPBIN_CHECKS: return "VCPKG_POLICY_SKIP_DUMPBIN_CHECKS";
default: Checks::unreachable(VCPKG_LINE_INFO); default: Checks::unreachable(VCPKG_LINE_INFO);
} }
} }

View File

@ -200,7 +200,7 @@ namespace vcpkg::PostBuildLint
System::print2(System::Color::warning, System::print2(System::Color::warning,
"Include files should not be duplicated into the /debug/include directory. If this cannot " "Include files should not be duplicated into the /debug/include directory. If this cannot "
"be disabled in the project cmake, use\n" "be disabled in the project cmake, use\n"
" file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)\n"); " file(REMOVE_RECURSE \"${CURRENT_PACKAGES_DIR}/debug/include\")\n");
return LintStatus::ERROR_DETECTED; return LintStatus::ERROR_DETECTED;
} }
@ -215,7 +215,7 @@ namespace vcpkg::PostBuildLint
{ {
System::print2(System::Color::warning, System::print2(System::Color::warning,
"/debug/share should not exist. Please reorganize any important files, then use\n" "/debug/share should not exist. Please reorganize any important files, then use\n"
" file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/share)\n"); " file(REMOVE_RECURSE \"${CURRENT_PACKAGES_DIR}/debug/share\")\n");
return LintStatus::ERROR_DETECTED; return LintStatus::ERROR_DETECTED;
} }
@ -349,11 +349,8 @@ namespace vcpkg::PostBuildLint
const fs::path relative_path = found_file.string().erase( const fs::path relative_path = found_file.string().erase(
0, current_buildtrees_dir.string().size() + 1); // The +1 is needed to remove the "/" 0, current_buildtrees_dir.string().size() + 1); // The +1 is needed to remove the "/"
System::printf( System::printf(
"\n file(COPY ${CURRENT_BUILDTREES_DIR}/%s DESTINATION ${CURRENT_PACKAGES_DIR}/share/%s)\n" "\n configure_file(\"${CURRENT_BUILDTREES_DIR}/%s/%s\" \"${CURRENT_PACKAGES_DIR}/share/%s/copyright\" COPYONLY)\n",
" file(RENAME ${CURRENT_PACKAGES_DIR}/share/%s/%s ${CURRENT_PACKAGES_DIR}/share/%s/copyright)\n",
relative_path.generic_string(), relative_path.generic_string(),
spec.name(),
spec.name(),
found_file.filename().generic_string(), found_file.filename().generic_string(),
spec.name()); spec.name());
} }
@ -662,7 +659,7 @@ namespace vcpkg::PostBuildLint
"\n" "\n"
R"###( if(VCPKG_LIBRARY_LINKAGE STREQUAL "static"))###" R"###( if(VCPKG_LIBRARY_LINKAGE STREQUAL "static"))###"
"\n" "\n"
R"###( file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/bin ${CURRENT_PACKAGES_DIR}/debug/bin))###" R"###( file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin" "${CURRENT_PACKAGES_DIR}/debug/bin"))###"
"\n" "\n"
R"###( endif())###" R"###( endif())###"
"\n\n"); "\n\n");
@ -689,7 +686,7 @@ namespace vcpkg::PostBuildLint
"If the directories are not needed and their creation cannot be disabled, use something like this in " "If the directories are not needed and their creation cannot be disabled, use something like this in "
"the portfile to remove them:\n" "the portfile to remove them:\n"
"\n" "\n"
R"###( file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/a/dir ${CURRENT_PACKAGES_DIR}/some/other/dir))###" R"###( file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/a/dir" "${CURRENT_PACKAGES_DIR}/some/other/dir"))###"
"\n" "\n"
"\n" "\n"
"\n"); "\n");
@ -903,7 +900,7 @@ namespace vcpkg::PostBuildLint
dlls.insert(dlls.cend(), debug_dlls.cbegin(), debug_dlls.cend()); dlls.insert(dlls.cend(), debug_dlls.cbegin(), debug_dlls.cend());
dlls.insert(dlls.cend(), release_dlls.cbegin(), release_dlls.cend()); dlls.insert(dlls.cend(), release_dlls.cbegin(), release_dlls.cend());
if (!toolset.dumpbin.empty()) if (!toolset.dumpbin.empty() && !build_info.policies.is_enabled(BuildPolicy::SKIP_DUMPBIN_CHECKS))
{ {
error_count += check_exports_of_dlls(build_info.policies, 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_uwp_bit_of_dlls(pre_build_info.cmake_system_name, dlls, toolset.dumpbin);
@ -924,7 +921,7 @@ namespace vcpkg::PostBuildLint
error_count += check_bin_folders_are_not_present_in_static_build(fs, package_dir); error_count += check_bin_folders_are_not_present_in_static_build(fs, package_dir);
if (!toolset.dumpbin.empty()) if (!toolset.dumpbin.empty() && !build_info.policies.is_enabled(BuildPolicy::SKIP_DUMPBIN_CHECKS))
{ {
if (!build_info.policies.is_enabled(BuildPolicy::ONLY_RELEASE_CRT)) if (!build_info.policies.is_enabled(BuildPolicy::ONLY_RELEASE_CRT))
{ {