Add policy: NoDebugBinaries
MODIFY
include/PostBuildLint_BuildPolicies.h
include/PostBuildLint_BuildPolicies.h
@@ -8,7 +8,8 @@ namespace vcpkg::PostBuildLint::BuildPolicies
{
NULLVALUE = 0,
EMPTY_PACKAGE,
- DLLS_WITHOUT_LIBS
+ DLLS_WITHOUT_LIBS,
+ NO_DEBUG_BINARIES
};
struct type
@@ -29,8 +30,9 @@ namespace vcpkg::PostBuildLint::BuildPolicies
static constexpr type NULLVALUE(backing_enum_t::NULLVALUE);
static constexpr type EMPTY_PACKAGE(backing_enum_t::EMPTY_PACKAGE);
static constexpr type DLLS_WITHOUT_LIBS(backing_enum_t::DLLS_WITHOUT_LIBS);
+ static constexpr type NO_DEBUG_BINARIES(backing_enum_t::NO_DEBUG_BINARIES);
- static constexpr std::array<type, 2> values = { EMPTY_PACKAGE, DLLS_WITHOUT_LIBS };
+ static constexpr std::array<type, 3> values = { EMPTY_PACKAGE, DLLS_WITHOUT_LIBS, NO_DEBUG_BINARIES };
type parse(const std::string& s);
}

MODIFY
src/PostBuildLint.cpp
src/PostBuildLint.cpp
@@ -601,6 +601,17 @@ namespace vcpkg::PostBuildLint
left += static_cast<size_t>(right);
}
+ template <class T>
+ static bool contains_and_enabled(const std::map<T, opt_bool_t> map, const T& key)
+ {
+ auto it = map.find(key);
+ if (it != map.cend() && it->second == opt_bool_t::ENABLED)
+ {
+ return true;
+ }
+
+ return false;
+ }
static size_t perform_all_checks_and_return_error_count(const package_spec& spec, const vcpkg_paths& paths)
{
@@ -611,8 +622,7 @@ namespace vcpkg::PostBuildLint
size_t error_count = 0;
- auto it = build_info.policies.find(BuildPolicies::EMPTY_PACKAGE);
- if (it != build_info.policies.cend() && it->second == opt_bool_t::ENABLED)
+ if (contains_and_enabled(build_info.policies, BuildPolicies::EMPTY_PACKAGE))
{
return error_count;
}
@@ -674,7 +684,10 @@ namespace vcpkg::PostBuildLint
error_count += check_bin_folders_are_not_present_in_static_build(package_dir);
+ if (!contains_and_enabled(build_info.policies, BuildPolicies::NO_DEBUG_BINARIES))
+ {
error_count += check_crt_linkage_of_libs(BuildType::value_of(ConfigurationType::DEBUG, build_info.crt_linkage), debug_libs, dumpbin_exe);
+ }
error_count += check_crt_linkage_of_libs(BuildType::value_of(ConfigurationType::RELEASE, build_info.crt_linkage), release_libs, dumpbin_exe);
break;
}

MODIFY
src/PostBuildLint_BuildPolicies.cpp
src/PostBuildLint_BuildPolicies.cpp
@@ -8,6 +8,7 @@ namespace vcpkg::PostBuildLint::BuildPolicies
static const std::string NAME_EMPTY_PACKAGE = "PolicyEmptyPackage";
static const std::string NAME_DLLS_WITHOUT_LIBS = "PolicyDLLsWithoutLIBs";
+ static const std::string NAME_NO_DEBUG_BINARIES = "PolicyNoDebugBinaries";
const std::string& type::toString() const
{
@@ -17,6 +18,8 @@ namespace vcpkg::PostBuildLint::BuildPolicies
return NAME_EMPTY_PACKAGE;
case DLLS_WITHOUT_LIBS:
return NAME_DLLS_WITHOUT_LIBS;
+ case NO_DEBUG_BINARIES:
+ return NAME_NO_DEBUG_BINARIES;
case NULLVALUE:
return NULLVALUE_STRING;
default:
@@ -28,6 +31,7 @@ namespace vcpkg::PostBuildLint::BuildPolicies
{
static const std::string CMAKE_VARIABLE_EMPTY_PACKAGE = "VCPKG_POLICY_EMPTY_PACKAGE";
static const std::string CMAKE_VARIABLE_DLLS_WITHOUT_LIBS = "VCPKG_POLICY_DLLS_WITHOUT_LIBS";
+ static const std::string CMAKE_VARIABLE_NO_DEBUG_BINARIES = "VCPKG_POLICY_NO_DEBUG_BINARIES";
switch (this->backing_enum)
{
@@ -35,6 +39,8 @@ namespace vcpkg::PostBuildLint::BuildPolicies
return CMAKE_VARIABLE_EMPTY_PACKAGE;
case DLLS_WITHOUT_LIBS:
return CMAKE_VARIABLE_DLLS_WITHOUT_LIBS;
+ case NO_DEBUG_BINARIES:
+ return CMAKE_VARIABLE_NO_DEBUG_BINARIES;
case NULLVALUE:
Enums::nullvalue_used(ENUM_NAME);
default:
@@ -54,6 +60,11 @@ namespace vcpkg::PostBuildLint::BuildPolicies
return BuildPolicies::DLLS_WITHOUT_LIBS;
}
+ if (s == NAME_NO_DEBUG_BINARIES)
+ {
+ return BuildPolicies::NO_DEBUG_BINARIES;
+ }
+
return BuildPolicies::NULLVALUE;
}
}

Add policy: NoDebugBinaries