diff options
| author | Alexander Karatarakis <alkarata@microsoft.com> | 2017-03-03 19:00:48 -0800 |
|---|---|---|
| committer | Alexander Karatarakis <alkarata@microsoft.com> | 2017-03-03 19:00:48 -0800 |
| commit | c2a368976dcd42640290a6ef30c5a4fc8a4a825d (patch) | |
| tree | f9ab145ac87ed8de668aa822b16f99560f98b6fd | |
| parent | e44aae7210a5c13e8748854dff478905c371defa (diff) | |
| download | vcpkg-c2a368976dcd42640290a6ef30c5a4fc8a4a825d.tar.gz vcpkg-c2a368976dcd42640290a6ef30c5a4fc8a4a825d.zip | |
Add policy: NoDebugBinaries
| -rw-r--r-- | scripts/ports.cmake | 3 | ||||
| -rw-r--r-- | toolsrc/include/PostBuildLint_BuildPolicies.h | 6 | ||||
| -rw-r--r-- | toolsrc/src/PostBuildLint.cpp | 19 | ||||
| -rw-r--r-- | toolsrc/src/PostBuildLint_BuildPolicies.cpp | 11 |
4 files changed, 34 insertions, 5 deletions
diff --git a/scripts/ports.cmake b/scripts/ports.cmake index c03b005ea..dbc547676 100644 --- a/scripts/ports.cmake +++ b/scripts/ports.cmake @@ -82,6 +82,9 @@ if(CMD MATCHES "^BUILD$") if (DEFINED VCPKG_POLICY_EMPTY_PACKAGE) file(APPEND ${BUILD_INFO_FILE_PATH} "PolicyEmptyPackage: ${VCPKG_POLICY_EMPTY_PACKAGE}\n") endif() + if (DEFINED VCPKG_POLICY_NO_DEBUG_BINARIES) + file(APPEND ${BUILD_INFO_FILE_PATH} "PolicyNoDebugBinaries: ${VCPKG_POLICY_NO_DEBUG_BINARIES}\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 082de31d0..42bd3d718 100644 --- a/toolsrc/include/PostBuildLint_BuildPolicies.h +++ b/toolsrc/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); } diff --git a/toolsrc/src/PostBuildLint.cpp b/toolsrc/src/PostBuildLint.cpp index bc02a16a8..b0edaf805 100644 --- a/toolsrc/src/PostBuildLint.cpp +++ b/toolsrc/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); - error_count += check_crt_linkage_of_libs(BuildType::value_of(ConfigurationType::DEBUG, build_info.crt_linkage), debug_libs, dumpbin_exe); + 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; } diff --git a/toolsrc/src/PostBuildLint_BuildPolicies.cpp b/toolsrc/src/PostBuildLint_BuildPolicies.cpp index 53dfcf95a..2e0a1713b 100644 --- a/toolsrc/src/PostBuildLint_BuildPolicies.cpp +++ b/toolsrc/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; } } |
