aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Karatarakis <alkarata@microsoft.com>2017-03-24 12:49:08 -0700
committerAlexander Karatarakis <alkarata@microsoft.com>2017-03-24 12:49:08 -0700
commit3b511adfe483ebde8a3680fefbd96723201a6667 (patch)
tree5a449ab0e1a86eca83621cf9a14ec4a762da0a43
parentcbfc4c0e54bd70f38b8b82d426d7a7291c5f2c0d (diff)
downloadvcpkg-3b511adfe483ebde8a3680fefbd96723201a6667.tar.gz
vcpkg-3b511adfe483ebde8a3680fefbd96723201a6667.zip
Add EMPTY_INCLUDE_FOLDER policy. Resolves #816
-rw-r--r--scripts/ports.cmake3
-rw-r--r--toolsrc/include/PostBuildLint_BuildPolicies.h6
-rw-r--r--toolsrc/src/PostBuildLint.cpp34
-rw-r--r--toolsrc/src/PostBuildLint_BuildPolicies.cpp11
4 files changed, 38 insertions, 16 deletions
diff --git a/scripts/ports.cmake b/scripts/ports.cmake
index e83b83d88..721201b49 100644
--- a/scripts/ports.cmake
+++ b/scripts/ports.cmake
@@ -85,6 +85,9 @@ if(CMD MATCHES "^BUILD$")
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_EMPTY_INCLUDE_FOLDER)
+ file(APPEND ${BUILD_INFO_FILE_PATH} "PolicyEmptyIncludeFolder: ${VCPKG_POLICY_EMPTY_INCLUDE_FOLDER}\n")
+ endif()
elseif(CMD MATCHES "^CREATE$")
file(TO_NATIVE_PATH ${VCPKG_ROOT_DIR} NATIVE_VCPKG_ROOT_DIR)
file(TO_NATIVE_PATH ${DOWNLOADS} NATIVE_DOWNLOADS)
diff --git a/toolsrc/include/PostBuildLint_BuildPolicies.h b/toolsrc/include/PostBuildLint_BuildPolicies.h
index d815c6d27..67da686fb 100644
--- a/toolsrc/include/PostBuildLint_BuildPolicies.h
+++ b/toolsrc/include/PostBuildLint_BuildPolicies.h
@@ -9,7 +9,8 @@ namespace vcpkg::PostBuildLint::BuildPolicies
NULLVALUE = 0,
EMPTY_PACKAGE,
DLLS_WITHOUT_LIBS,
- ONLY_RELEASE_CRT
+ ONLY_RELEASE_CRT,
+ EMPTY_INCLUDE_FOLDER
};
struct type
@@ -31,8 +32,9 @@ namespace vcpkg::PostBuildLint::BuildPolicies
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 ONLY_RELEASE_CRT(backing_enum_t::ONLY_RELEASE_CRT);
+ static constexpr type EMPTY_INCLUDE_FOLDER(backing_enum_t::EMPTY_INCLUDE_FOLDER);
- static constexpr std::array<type, 3> values = { EMPTY_PACKAGE, DLLS_WITHOUT_LIBS, ONLY_RELEASE_CRT };
+ static constexpr std::array<type, 4> values = { EMPTY_PACKAGE, DLLS_WITHOUT_LIBS, ONLY_RELEASE_CRT, EMPTY_INCLUDE_FOLDER };
type parse(const std::string& s);
}
diff --git a/toolsrc/src/PostBuildLint.cpp b/toolsrc/src/PostBuildLint.cpp
index 9032a3c11..5f271d84f 100644
--- a/toolsrc/src/PostBuildLint.cpp
+++ b/toolsrc/src/PostBuildLint.cpp
@@ -7,6 +7,7 @@
#include "coff_file_reader.h"
#include "PostBuildLint_BuildInfo.h"
#include "PostBuildLint_BuildType.h"
+#include "PostBuildLint.h"
namespace vcpkg::PostBuildLint
{
@@ -52,8 +53,25 @@ namespace vcpkg::PostBuildLint
return v;
}
- static lint_status check_for_files_in_include_directory(const fs::path& package_dir)
+ 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 lint_status check_for_files_in_include_directory(const std::map<BuildPolicies::type, opt_bool_t>& policies, const fs::path& package_dir)
{
+ if (contains_and_enabled(policies, BuildPolicies::EMPTY_INCLUDE_FOLDER))
+ {
+ return lint_status::SUCCESS;
+ }
+
const fs::path include_dir = package_dir / "include";
if (!fs::exists(include_dir) || fs::is_empty(include_dir))
{
@@ -601,18 +619,6 @@ 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)
{
const fs::path dumpbin_exe = Environment::get_dumpbin_exe(paths);
@@ -627,7 +633,7 @@ namespace vcpkg::PostBuildLint
return error_count;
}
- error_count += check_for_files_in_include_directory(package_dir);
+ error_count += check_for_files_in_include_directory(build_info.policies, package_dir);
error_count += check_for_files_in_debug_include_directory(package_dir);
error_count += check_for_files_in_debug_share_directory(package_dir);
error_count += check_folder_lib_cmake(package_dir, spec);
diff --git a/toolsrc/src/PostBuildLint_BuildPolicies.cpp b/toolsrc/src/PostBuildLint_BuildPolicies.cpp
index b7ebf5380..dab27b72a 100644
--- a/toolsrc/src/PostBuildLint_BuildPolicies.cpp
+++ b/toolsrc/src/PostBuildLint_BuildPolicies.cpp
@@ -10,6 +10,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_ONLY_RELEASE_CRT = "PolicyOnlyReleaseCRT";
+ static const std::string NAME_EMPTY_INCLUDE_FOLDER = "PolicyEmptyIncludeFolder";
const std::string& type::toString() const
{
@@ -21,6 +22,8 @@ namespace vcpkg::PostBuildLint::BuildPolicies
return NAME_DLLS_WITHOUT_LIBS;
case ONLY_RELEASE_CRT:
return NAME_ONLY_RELEASE_CRT;
+ case EMPTY_INCLUDE_FOLDER:
+ return NAME_EMPTY_INCLUDE_FOLDER;
case NULLVALUE:
return NULLVALUE_STRING;
default:
@@ -33,6 +36,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_ONLY_RELEASE_CRT = "VCPKG_POLICY_ONLY_RELEASE_CRT";
+ static const std::string CMAKE_VARIABLE_EMPTY_INCLUDE_FOLDER = "VCPKG_POLICY_EMPTY_INCLUDE_FOLDER";
switch (this->backing_enum)
{
@@ -42,6 +46,8 @@ namespace vcpkg::PostBuildLint::BuildPolicies
return CMAKE_VARIABLE_DLLS_WITHOUT_LIBS;
case ONLY_RELEASE_CRT:
return CMAKE_VARIABLE_ONLY_RELEASE_CRT;
+ case EMPTY_INCLUDE_FOLDER:
+ return CMAKE_VARIABLE_EMPTY_INCLUDE_FOLDER;
case NULLVALUE:
Enums::nullvalue_used(VCPKG_LINE_INFO, ENUM_NAME);
default:
@@ -66,6 +72,11 @@ namespace vcpkg::PostBuildLint::BuildPolicies
return BuildPolicies::ONLY_RELEASE_CRT;
}
+ if (s == NAME_EMPTY_INCLUDE_FOLDER)
+ {
+ return BuildPolicies::EMPTY_INCLUDE_FOLDER;
+ }
+
return BuildPolicies::NULLVALUE;
}
}