Add new Policy: Empty Package
MODIFY
include/PostBuildLint_BuildPolicies.h
include/PostBuildLint_BuildPolicies.h
@@ -6,6 +6,7 @@ namespace vcpkg::PostBuildLint::BuildPolicies
enum class backing_enum_t
{
UNKNOWN = 0,
+ EMPTY_PACKAGE,
DLLS_WITHOUT_LIBS
};
@@ -22,10 +23,12 @@ namespace vcpkg::PostBuildLint::BuildPolicies
backing_enum_t backing_enum;
};
- static constexpr int value_count = 2;
+ static constexpr int value_count = 3;
const std::vector<type>& values();
+
static constexpr type UNKNOWN(backing_enum_t::UNKNOWN);
+ static constexpr type EMPTY_PACKAGE(backing_enum_t::EMPTY_PACKAGE);
static constexpr type DLLS_WITHOUT_LIBS(backing_enum_t::DLLS_WITHOUT_LIBS);
type parse(const std::string& s);

MODIFY
src/PostBuildLint.cpp
src/PostBuildLint.cpp
@@ -582,16 +582,21 @@ namespace vcpkg::PostBuildLint
left += static_cast<size_t>(right);
}
- void perform_all_checks(const package_spec& spec, const vcpkg_paths& paths)
+ static size_t perform_all_checks_and_return_error_count(const package_spec& spec, const vcpkg_paths& paths)
{
const fs::path dumpbin_exe = Environment::get_dumpbin_exe(paths);
- System::println("-- Performing post-build validation");
-
BuildInfo build_info = read_build_info(paths.build_info_file_path(spec));
const fs::path package_dir = paths.package_dir(spec);
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)
+ {
+ return error_count;
+ }
+
error_count += check_for_files_in_include_directory(package_dir);
error_count += check_for_files_in_debug_include_directory(package_dir);
error_count += check_for_files_in_debug_share_directory(package_dir);
@@ -670,6 +675,15 @@ namespace vcpkg::PostBuildLint
error_count += check_no_empty_folders(package_dir);
error_count += check_no_files_in_package_dir_and_debug_dir(package_dir);
+ return error_count;
+ }
+
+ void perform_all_checks(const package_spec& spec, const vcpkg_paths& paths)
+ {
+ System::println("-- Performing post-build validation");
+
+ const size_t error_count = perform_all_checks_and_return_error_count(spec, paths);
+
if (error_count != 0)
{
const fs::path portfile = paths.ports / spec.name() / "portfile.cmake";

MODIFY
src/PostBuildLint_BuildPolicies.cpp
src/PostBuildLint_BuildPolicies.cpp
namespace vcpkg::PostBuildLint::BuildPolicies
{
static const std::string NAME_UNKNOWN = "PolicyUnknown";
+ static const std::string NAME_EMPTY_PACKAGE = "PolicyEmptyPackage";
static const std::string NAME_DLLS_WITHOUT_LIBS = "PolicyDLLsWithoutLIBs";
const std::string& type::toString() const
{
switch (this->backing_enum)
{
+ case EMPTY_PACKAGE:
+ return NAME_EMPTY_PACKAGE;
case DLLS_WITHOUT_LIBS:
return NAME_DLLS_WITHOUT_LIBS;
case UNKNOWN:
@@ -22,10 +25,13 @@ namespace vcpkg::PostBuildLint::BuildPolicies
const std::string& type::cmake_variable() const
{
+ 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";
switch (this->backing_enum)
{
+ case EMPTY_PACKAGE:
+ return CMAKE_VARIABLE_EMPTY_PACKAGE;
case DLLS_WITHOUT_LIBS:
return CMAKE_VARIABLE_DLLS_WITHOUT_LIBS;
case UNKNOWN:
@@ -39,12 +45,17 @@ namespace vcpkg::PostBuildLint::BuildPolicies
const std::vector<type>& values()
{
- static const std::vector<type>& v = {UNKNOWN, DLLS_WITHOUT_LIBS};
+ static const std::vector<type>& v = {UNKNOWN, EMPTY_PACKAGE, DLLS_WITHOUT_LIBS};
return v;
}
type parse(const std::string& s)
{
+ if (s == NAME_EMPTY_PACKAGE)
+ {
+ return BuildPolicies::EMPTY_PACKAGE;
+ }
+
if (s == NAME_DLLS_WITHOUT_LIBS)
{
return BuildPolicies::DLLS_WITHOUT_LIBS;

Add new Policy: Empty Package