Adding policy ALLOW_OBSOLETE_MSVCRT suppressing dependency check for msvcrt.dll

This commit is contained in:
Hartmut Kaiser 2017-05-22 21:30:50 -05:00
parent 9f0a7173a2
commit 3dd8bde9bd
3 changed files with 47 additions and 30 deletions

View File

@ -13,7 +13,8 @@ namespace vcpkg::PostBuildLint
EMPTY_PACKAGE,
DLLS_WITHOUT_LIBS,
ONLY_RELEASE_CRT,
EMPTY_INCLUDE_FOLDER
EMPTY_INCLUDE_FOLDER,
ALLOW_OBSOLETE_MSVCRT
};
static BuildPolicies parse(const std::string& s);
@ -38,8 +39,9 @@ namespace vcpkg::PostBuildLint
static constexpr BuildPolicies DLLS_WITHOUT_LIBS(BuildPolicies::BackingEnum::DLLS_WITHOUT_LIBS);
static constexpr BuildPolicies ONLY_RELEASE_CRT(BuildPolicies::BackingEnum::ONLY_RELEASE_CRT);
static constexpr BuildPolicies EMPTY_INCLUDE_FOLDER(BuildPolicies::BackingEnum::EMPTY_INCLUDE_FOLDER);
static constexpr BuildPolicies ALLOW_OBSOLETE_MSVCRT(BuildPolicies::BackingEnum::ALLOW_OBSOLETE_MSVCRT);
static constexpr std::array<BuildPolicies, 4> VALUES = {
EMPTY_PACKAGE, DLLS_WITHOUT_LIBS, ONLY_RELEASE_CRT, EMPTY_INCLUDE_FOLDER};
static constexpr std::array<BuildPolicies, 5> VALUES = {
EMPTY_PACKAGE, DLLS_WITHOUT_LIBS, ONLY_RELEASE_CRT, EMPTY_INCLUDE_FOLDER, ALLOW_OBSOLETE_MSVCRT};
}
}

View File

@ -37,30 +37,6 @@ namespace vcpkg::PostBuildLint
}
};
const std::vector<OutdatedDynamicCrt>& get_outdated_dynamic_crts()
{
static const std::vector<OutdatedDynamicCrt> v = {{"msvcp100.dll", R"(msvcp100\.dll)"},
{"msvcp100d.dll", R"(msvcp100d\.dll)"},
{"msvcp110.dll", R"(msvcp110\.dll)"},
{"msvcp110_win.dll", R"(msvcp110_win\.dll)"},
{"msvcp120.dll", R"(msvcp120\.dll)"},
{"msvcp120_clr0400.dll", R"(msvcp120_clr0400\.dll)"},
{"msvcp60.dll", R"(msvcp60\.dll)"},
{"msvcp60.dll", R"(msvcp60\.dll)"},
{"msvcr100.dll", R"(msvcr100\.dll)"},
{"msvcr100d.dll", R"(msvcr100d\.dll)"},
{"msvcr100_clr0400.dll", R"(msvcr100_clr0400\.dll)"},
{"msvcr110.dll", R"(msvcr110\.dll)"},
{"msvcr120.dll", R"(msvcr120\.dll)"},
{"msvcr120_clr0400.dll", R"(msvcr120_clr0400\.dll)"},
{"msvcrt.dll", R"(msvcrt\.dll)"},
{"msvcrt20.dll", R"(msvcrt20\.dll)"},
{"msvcrt40.dll", R"(msvcrt40\.dll)"}};
return v;
}
template<class T>
static bool contains_and_enabled(const std::map<T, bool> map, const T& key)
{
@ -70,6 +46,34 @@ namespace vcpkg::PostBuildLint
return false;
}
const std::vector<OutdatedDynamicCrt>& get_outdated_dynamic_crts(const std::map<BuildPolicies, bool>& policies)
{
static std::vector<OutdatedDynamicCrt> v = {{"msvcp100.dll", R"(msvcp100\.dll)"},
{"msvcp100d.dll", R"(msvcp100d\.dll)"},
{"msvcp110.dll", R"(msvcp110\.dll)"},
{"msvcp110_win.dll", R"(msvcp110_win\.dll)"},
{"msvcp120.dll", R"(msvcp120\.dll)"},
{"msvcp120_clr0400.dll", R"(msvcp120_clr0400\.dll)"},
{"msvcp60.dll", R"(msvcp60\.dll)"},
{"msvcp60.dll", R"(msvcp60\.dll)"},
{"msvcr100.dll", R"(msvcr100\.dll)"},
{"msvcr100d.dll", R"(msvcr100d\.dll)"},
{"msvcr100_clr0400.dll", R"(msvcr100_clr0400\.dll)"},
{"msvcr110.dll", R"(msvcr110\.dll)"},
{"msvcr120.dll", R"(msvcr120\.dll)"},
{"msvcr120_clr0400.dll", R"(msvcr120_clr0400\.dll)"},
{"msvcrt20.dll", R"(msvcrt20\.dll)"},
{"msvcrt40.dll", R"(msvcrt40\.dll)"}};
if (contains_and_enabled(policies, BuildPoliciesC::ALLOW_OBSOLETE_MSVCRT))
{
v.push_back(OutdatedDynamicCrt{"msvcrt.dll", R"(msvcrt\.dll)"});
}
return v;
}
static LintStatus check_for_files_in_include_directory(const Files::Filesystem& fs,
const std::map<BuildPolicies, bool>& policies,
const fs::path& package_dir)
@ -656,9 +660,11 @@ namespace vcpkg::PostBuildLint
OutdatedDynamicCrt_and_file() = delete;
};
static LintStatus check_outdated_crt_linkage_of_dlls(const std::vector<fs::path>& dlls, const fs::path dumpbin_exe)
static LintStatus check_outdated_crt_linkage_of_dlls(const std::vector<fs::path>& dlls,
const fs::path dumpbin_exe,
const BuildInfo& build_info)
{
const std::vector<OutdatedDynamicCrt>& outdated_crts = get_outdated_dynamic_crts();
const std::vector<OutdatedDynamicCrt>& outdated_crts = get_outdated_dynamic_crts(build_info.policies);
std::vector<OutdatedDynamicCrt_and_file> dlls_with_outdated_crt;
@ -798,7 +804,7 @@ namespace vcpkg::PostBuildLint
error_count += check_uwp_bit_of_dlls(pre_build_info.cmake_system_name, dlls, toolset.dumpbin);
error_count += check_dll_architecture(pre_build_info.target_architecture, dlls);
error_count += check_outdated_crt_linkage_of_dlls(dlls, toolset.dumpbin);
error_count += check_outdated_crt_linkage_of_dlls(dlls, toolset.dumpbin, build_info);
break;
}
case LinkageType::BackingEnum::STATIC:

View File

@ -12,6 +12,7 @@ namespace vcpkg::PostBuildLint
static const std::string NAME_DLLS_WITHOUT_LIBS = "PolicyDLLsWithoutLIBs";
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";
BuildPolicies BuildPolicies::parse(const std::string& s)
{
@ -35,6 +36,11 @@ namespace vcpkg::PostBuildLint
return BuildPoliciesC::EMPTY_INCLUDE_FOLDER;
}
if (s == NAME_ALLOW_OBSOLETE_MSVCRT)
{
return BuildPoliciesC::ALLOW_OBSOLETE_MSVCRT;
}
return BuildPoliciesC::NULLVALUE;
}
@ -46,6 +52,7 @@ namespace vcpkg::PostBuildLint
case BuildPoliciesC::DLLS_WITHOUT_LIBS: return NAME_DLLS_WITHOUT_LIBS;
case BuildPoliciesC::ONLY_RELEASE_CRT: return NAME_ONLY_RELEASE_CRT;
case BuildPoliciesC::EMPTY_INCLUDE_FOLDER: return NAME_EMPTY_INCLUDE_FOLDER;
case BuildPoliciesC::ALLOW_OBSOLETE_MSVCRT: return NAME_ALLOW_OBSOLETE_MSVCRT;
case BuildPoliciesC::NULLVALUE: return NULLVALUE_STRING;
default: Checks::unreachable(VCPKG_LINE_INFO);
}
@ -57,6 +64,7 @@ namespace vcpkg::PostBuildLint
static const std::string CMAKE_VARIABLE_DLLS_WITHOUT_LIBS = "VCPKG_POLICY_DLLS_WITHOUT_LIBS";
static const std::string CMAKE_VARIABLE_ONLY_RELEASE_CRT = "VCPKG_POLICY_ONLY_RELEASE_CRT";
static const std::string CMAKE_VARIABLE_EMPTY_INCLUDE_FOLDER = "VCPKG_POLICY_EMPTY_INCLUDE_FOLDER";
static const std::string CMAKE_VARIABLE_ALLOW_OBSOLETE_MSVCRT = "VCPKG_POLICY_ALLOW_OBSOLETE_MSVCRT";
switch (this->backing_enum)
{
@ -64,6 +72,7 @@ namespace vcpkg::PostBuildLint
case BuildPoliciesC::DLLS_WITHOUT_LIBS: return CMAKE_VARIABLE_DLLS_WITHOUT_LIBS;
case BuildPoliciesC::ONLY_RELEASE_CRT: return CMAKE_VARIABLE_ONLY_RELEASE_CRT;
case BuildPoliciesC::EMPTY_INCLUDE_FOLDER: return CMAKE_VARIABLE_EMPTY_INCLUDE_FOLDER;
case BuildPoliciesC::ALLOW_OBSOLETE_MSVCRT: return CMAKE_VARIABLE_ALLOW_OBSOLETE_MSVCRT;
case BuildPoliciesC::NULLVALUE: Enums::nullvalue_used(VCPKG_LINE_INFO, BuildPoliciesC::ENUM_NAME);
default: Checks::unreachable(VCPKG_LINE_INFO);
}