mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-12-26 17:41:09 +08:00
[vcpkg] New policy: SKIP_ARCHITECTURE_CHECK. (#10398)
* New policy: SKIP_DLL_ARCHITECTURE_CHECK. The check only works if MS link.exe is used otherwise the second linker member is missing (according to the observed errors) * rename to VCPKG_POLICY_SKIP_ARCHITECTURE_CHECK since the dll check was ok but the lib check was failing. * fix indentation * move the if to a better position.
This commit is contained in:
parent
bf858077f2
commit
0edffcf125
34
scripts/build_info.cmake
Normal file
34
scripts/build_info.cmake
Normal file
@ -0,0 +1,34 @@
|
||||
set(BUILD_INFO_FILE_PATH ${CURRENT_PACKAGES_DIR}/BUILD_INFO)
|
||||
file(WRITE ${BUILD_INFO_FILE_PATH} "CRTLinkage: ${VCPKG_CRT_LINKAGE}\n")
|
||||
file(APPEND ${BUILD_INFO_FILE_PATH} "LibraryLinkage: ${VCPKG_LIBRARY_LINKAGE}\n")
|
||||
|
||||
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()
|
||||
if (DEFINED VCPKG_POLICY_ONLY_RELEASE_CRT)
|
||||
file(APPEND ${BUILD_INFO_FILE_PATH} "PolicyOnlyReleaseCRT: ${VCPKG_POLICY_ONLY_RELEASE_CRT}\n")
|
||||
endif()
|
||||
if (DEFINED VCPKG_POLICY_ALLOW_OBSOLETE_MSVCRT)
|
||||
file(APPEND ${BUILD_INFO_FILE_PATH} "PolicyAllowObsoleteMsvcrt: ${VCPKG_POLICY_ALLOW_OBSOLETE_MSVCRT}\n")
|
||||
endif()
|
||||
if (DEFINED VCPKG_POLICY_EMPTY_INCLUDE_FOLDER)
|
||||
file(APPEND ${BUILD_INFO_FILE_PATH} "PolicyEmptyIncludeFolder: ${VCPKG_POLICY_EMPTY_INCLUDE_FOLDER}\n")
|
||||
endif()
|
||||
if (DEFINED VCPKG_POLICY_ALLOW_RESTRICTED_HEADERS)
|
||||
file(APPEND ${BUILD_INFO_FILE_PATH} "PolicyAllowRestrictedHeaders: ${VCPKG_POLICY_ALLOW_RESTRICTED_HEADERS}\n")
|
||||
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_POLICY_SKIP_ARCHITECTURE_CHECK)
|
||||
file(APPEND ${BUILD_INFO_FILE_PATH} "PolicySkipArchitectureCheck: ${VCPKG_POLICY_SKIP_ARCHITECTURE_CHECK}\n")
|
||||
endif()
|
||||
if (DEFINED VCPKG_HEAD_VERSION)
|
||||
file(APPEND ${BUILD_INFO_FILE_PATH} "Version: ${VCPKG_HEAD_VERSION}\n")
|
||||
endif()
|
@ -88,38 +88,7 @@ if(CMD MATCHES "^BUILD$")
|
||||
include(${SCRIPTS}/cmake/vcpkg_common_definitions.cmake)
|
||||
include(${SCRIPTS}/cmake/vcpkg_common_functions.cmake)
|
||||
include(${CURRENT_PORT_DIR}/portfile.cmake)
|
||||
|
||||
set(BUILD_INFO_FILE_PATH ${CURRENT_PACKAGES_DIR}/BUILD_INFO)
|
||||
file(WRITE ${BUILD_INFO_FILE_PATH} "CRTLinkage: ${VCPKG_CRT_LINKAGE}\n")
|
||||
file(APPEND ${BUILD_INFO_FILE_PATH} "LibraryLinkage: ${VCPKG_LIBRARY_LINKAGE}\n")
|
||||
|
||||
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()
|
||||
if (DEFINED VCPKG_POLICY_ONLY_RELEASE_CRT)
|
||||
file(APPEND ${BUILD_INFO_FILE_PATH} "PolicyOnlyReleaseCRT: ${VCPKG_POLICY_ONLY_RELEASE_CRT}\n")
|
||||
endif()
|
||||
if (DEFINED VCPKG_POLICY_ALLOW_OBSOLETE_MSVCRT)
|
||||
file(APPEND ${BUILD_INFO_FILE_PATH} "PolicyAllowObsoleteMsvcrt: ${VCPKG_POLICY_ALLOW_OBSOLETE_MSVCRT}\n")
|
||||
endif()
|
||||
if (DEFINED VCPKG_POLICY_EMPTY_INCLUDE_FOLDER)
|
||||
file(APPEND ${BUILD_INFO_FILE_PATH} "PolicyEmptyIncludeFolder: ${VCPKG_POLICY_EMPTY_INCLUDE_FOLDER}\n")
|
||||
endif()
|
||||
if (DEFINED VCPKG_POLICY_ALLOW_RESTRICTED_HEADERS)
|
||||
file(APPEND ${BUILD_INFO_FILE_PATH} "PolicyAllowRestrictedHeaders: ${VCPKG_POLICY_ALLOW_RESTRICTED_HEADERS}\n")
|
||||
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)
|
||||
file(APPEND ${BUILD_INFO_FILE_PATH} "Version: ${VCPKG_HEAD_VERSION}\n")
|
||||
endif()
|
||||
include(${SCRIPTS}/build_info.cmake)
|
||||
elseif(CMD MATCHES "^CREATE$")
|
||||
file(TO_NATIVE_PATH ${VCPKG_ROOT_DIR} NATIVE_VCPKG_ROOT_DIR)
|
||||
file(TO_NATIVE_PATH ${DOWNLOADS} NATIVE_DOWNLOADS)
|
||||
|
@ -222,6 +222,7 @@ namespace vcpkg::Build
|
||||
ALLOW_OBSOLETE_MSVCRT,
|
||||
ALLOW_RESTRICTED_HEADERS,
|
||||
SKIP_DUMPBIN_CHECKS,
|
||||
SKIP_ARCHITECTURE_CHECK,
|
||||
// Must be last
|
||||
COUNT,
|
||||
};
|
||||
@ -235,6 +236,7 @@ namespace vcpkg::Build
|
||||
BuildPolicy::ALLOW_OBSOLETE_MSVCRT,
|
||||
BuildPolicy::ALLOW_RESTRICTED_HEADERS,
|
||||
BuildPolicy::SKIP_DUMPBIN_CHECKS,
|
||||
BuildPolicy::SKIP_ARCHITECTURE_CHECK
|
||||
};
|
||||
|
||||
const std::string& to_string(BuildPolicy policy);
|
||||
|
@ -160,6 +160,7 @@ namespace vcpkg::Build
|
||||
static const std::string NAME_ALLOW_OBSOLETE_MSVCRT = "PolicyAllowObsoleteMsvcrt";
|
||||
static const std::string NAME_ALLOW_RESTRICTED_HEADERS = "PolicyAllowRestrictedHeaders";
|
||||
static const std::string NAME_SKIP_DUMPBIN_CHECKS = "PolicySkipDumpbinChecks";
|
||||
static const std::string NAME_SKIP_ARCHITECTURE_CHECK = "PolicySkipArchitectureCheck";
|
||||
|
||||
const std::string& to_string(BuildPolicy policy)
|
||||
{
|
||||
@ -173,6 +174,7 @@ namespace vcpkg::Build
|
||||
case BuildPolicy::ALLOW_OBSOLETE_MSVCRT: return NAME_ALLOW_OBSOLETE_MSVCRT;
|
||||
case BuildPolicy::ALLOW_RESTRICTED_HEADERS: return NAME_ALLOW_RESTRICTED_HEADERS;
|
||||
case BuildPolicy::SKIP_DUMPBIN_CHECKS: return NAME_SKIP_DUMPBIN_CHECKS;
|
||||
case BuildPolicy::SKIP_ARCHITECTURE_CHECK: return NAME_SKIP_ARCHITECTURE_CHECK;
|
||||
default: Checks::unreachable(VCPKG_LINE_INFO);
|
||||
}
|
||||
}
|
||||
@ -189,6 +191,7 @@ namespace vcpkg::Build
|
||||
case BuildPolicy::ALLOW_OBSOLETE_MSVCRT: return "VCPKG_POLICY_ALLOW_OBSOLETE_MSVCRT";
|
||||
case BuildPolicy::ALLOW_RESTRICTED_HEADERS: return "VCPKG_POLICY_ALLOW_RESTRICTED_HEADERS";
|
||||
case BuildPolicy::SKIP_DUMPBIN_CHECKS: return "VCPKG_POLICY_SKIP_DUMPBIN_CHECKS";
|
||||
case BuildPolicy::SKIP_ARCHITECTURE_CHECK: return "VCPKG_POLICY_SKIP_ARCHITECTURE_CHECK";
|
||||
default: Checks::unreachable(VCPKG_LINE_INFO);
|
||||
}
|
||||
}
|
||||
|
@ -871,11 +871,11 @@ namespace vcpkg::PostBuildLint
|
||||
if (!pre_build_info.build_type)
|
||||
error_count += check_matching_debug_and_release_binaries(debug_libs, release_libs);
|
||||
|
||||
if (!build_info.policies.is_enabled(BuildPolicy::SKIP_ARCHITECTURE_CHECK))
|
||||
{
|
||||
std::vector<fs::path> libs;
|
||||
libs.insert(libs.cend(), debug_libs.cbegin(), debug_libs.cend());
|
||||
libs.insert(libs.cend(), release_libs.cbegin(), release_libs.cend());
|
||||
|
||||
error_count += check_lib_architecture(pre_build_info.target_architecture, libs);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user