Adding policy ALLOW_OBSOLETE_MSVCRT suppressing dependency check for msvcrt.dll
MODIFY
include/PostBuildLint_BuildPolicies.h
include/PostBuildLint_BuildPolicies.h
@@ -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};
}
}

MODIFY
src/PostBuildLint.cpp
src/PostBuildLint.cpp
@@ -37,9 +37,18 @@ namespace vcpkg::PostBuildLint
}
};
- const std::vector<OutdatedDynamicCrt>& get_outdated_dynamic_crts()
+ template<class T>
+ static bool contains_and_enabled(const std::map<T, bool> map, const T& key)
+ {
+ auto it = map.find(key);
+ if (it != map.cend()) return it->second;
+
+ return false;
+ }
+
+ const std::vector<OutdatedDynamicCrt>& get_outdated_dynamic_crts(const std::map<BuildPolicies, bool>& policies)
{
- static const std::vector<OutdatedDynamicCrt> v = {{"msvcp100.dll", R"(msvcp100\.dll)"},
+ 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)"},
@@ -54,20 +63,15 @@ namespace vcpkg::PostBuildLint
{"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)
+ if (contains_and_enabled(policies, BuildPoliciesC::ALLOW_OBSOLETE_MSVCRT))
{
- auto it = map.find(key);
- if (it != map.cend()) return it->second;
+ v.push_back(OutdatedDynamicCrt{"msvcrt.dll", R"(msvcrt\.dll)"});
+ }
- return false;
+ return v;
}
static LintStatus check_for_files_in_include_directory(const Files::Filesystem& fs,
@@ -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:

MODIFY
src/PostBuildLint_BuildPolicies.cpp
src/PostBuildLint_BuildPolicies.cpp
@@ -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);
}

Adding policy ALLOW_OBSOLETE_MSVCRT suppressing dependency check for msvcrt.dll