From f9616c6994ccf66e2a64e2d62e6a1408694c190c Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Tue, 7 Feb 2017 17:02:57 -0800 Subject: Add new Policy: Empty Package --- toolsrc/src/PostBuildLint.cpp | 92 +++++++++++++++++++++++++------------------ 1 file changed, 53 insertions(+), 39 deletions(-) (limited to 'toolsrc/src/PostBuildLint.cpp') diff --git a/toolsrc/src/PostBuildLint.cpp b/toolsrc/src/PostBuildLint.cpp index 5954089e9..533e28fcf 100644 --- a/toolsrc/src/PostBuildLint.cpp +++ b/toolsrc/src/PostBuildLint.cpp @@ -582,16 +582,21 @@ namespace vcpkg::PostBuildLint left += static_cast(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); @@ -620,56 +625,65 @@ namespace vcpkg::PostBuildLint switch (linkage_type_value_of(build_info.library_linkage)) { - case LinkageType::DYNAMIC: - { - const std::vector debug_dlls = Files::recursive_find_files_with_extension_in_dir(debug_bin_dir, ".dll"); - const std::vector release_dlls = Files::recursive_find_files_with_extension_in_dir(release_bin_dir, ".dll"); + case LinkageType::DYNAMIC: + { + const std::vector debug_dlls = Files::recursive_find_files_with_extension_in_dir(debug_bin_dir, ".dll"); + const std::vector release_dlls = Files::recursive_find_files_with_extension_in_dir(release_bin_dir, ".dll"); - error_count += check_matching_debug_and_release_binaries(debug_dlls, release_dlls); + error_count += check_matching_debug_and_release_binaries(debug_dlls, release_dlls); - error_count += check_lib_files_are_available_if_dlls_are_available(build_info.policies, debug_libs.size(), debug_dlls.size(), debug_lib_dir); - error_count += check_lib_files_are_available_if_dlls_are_available(build_info.policies, release_libs.size(), release_dlls.size(), release_lib_dir); + error_count += check_lib_files_are_available_if_dlls_are_available(build_info.policies, debug_libs.size(), debug_dlls.size(), debug_lib_dir); + error_count += check_lib_files_are_available_if_dlls_are_available(build_info.policies, release_libs.size(), release_dlls.size(), release_lib_dir); - std::vector dlls; - dlls.insert(dlls.cend(), debug_dlls.cbegin(), debug_dlls.cend()); - dlls.insert(dlls.cend(), release_dlls.cbegin(), release_dlls.cend()); + std::vector dlls; + dlls.insert(dlls.cend(), debug_dlls.cbegin(), debug_dlls.cend()); + dlls.insert(dlls.cend(), release_dlls.cbegin(), release_dlls.cend()); - error_count += check_exports_of_dlls(dlls, dumpbin_exe); - error_count += check_uwp_bit_of_dlls(spec.target_triplet().system(), dlls, dumpbin_exe); - error_count += check_dll_architecture(spec.target_triplet().architecture(), dlls); + error_count += check_exports_of_dlls(dlls, dumpbin_exe); + error_count += check_uwp_bit_of_dlls(spec.target_triplet().system(), dlls, dumpbin_exe); + error_count += check_dll_architecture(spec.target_triplet().architecture(), dlls); - error_count += check_outdated_crt_linkage_of_dlls(dlls, dumpbin_exe); - break; - } - case LinkageType::STATIC: - { - std::vector dlls; - Files::recursive_find_files_with_extension_in_dir(package_dir, ".dll", &dlls); - error_count += check_no_dlls_present(dlls); + error_count += check_outdated_crt_linkage_of_dlls(dlls, dumpbin_exe); + break; + } + case LinkageType::STATIC: + { + std::vector dlls; + Files::recursive_find_files_with_extension_in_dir(package_dir, ".dll", &dlls); + error_count += check_no_dlls_present(dlls); - error_count += check_bin_folders_are_not_present_in_static_build(package_dir); + 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, linkage_type_value_of(build_info.crt_linkage)), debug_libs, dumpbin_exe); - error_count += check_crt_linkage_of_libs(BuildType::value_of(ConfigurationType::RELEASE, linkage_type_value_of(build_info.crt_linkage)), release_libs, dumpbin_exe); - break; - } - case LinkageType::UNKNOWN: - { - error_count += 1; - System::println(System::color::warning, "Unknown library_linkage architecture: [ %s ]", build_info.library_linkage); - break; - } - default: - Checks::unreachable(); + error_count += check_crt_linkage_of_libs(BuildType::value_of(ConfigurationType::DEBUG, linkage_type_value_of(build_info.crt_linkage)), debug_libs, dumpbin_exe); + error_count += check_crt_linkage_of_libs(BuildType::value_of(ConfigurationType::RELEASE, linkage_type_value_of(build_info.crt_linkage)), release_libs, dumpbin_exe); + break; + } + case LinkageType::UNKNOWN: + { + error_count += 1; + System::println(System::color::warning, "Unknown library_linkage architecture: [ %s ]", build_info.library_linkage); + break; + } + default: + Checks::unreachable(); } #if 0 - error_count += check_no_subdirectories(package_dir / "lib"); - error_count += check_no_subdirectories(package_dir / "debug" / "lib"); + error_count += check_no_subdirectories(package_dir / "lib"); + error_count += check_no_subdirectories(package_dir / "debug" / "lib"); #endif 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"; -- cgit v1.2.3 From d36a1b7cb0b8be59e7826a7a699d9951e91abc2c Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Tue, 7 Feb 2017 22:57:37 -0800 Subject: Remove OutdatedDynamicCrt enum. Replace with vector --- toolsrc/src/PostBuildLint.cpp | 107 +++++++++++++++++++++++++++--------------- 1 file changed, 69 insertions(+), 38 deletions(-) (limited to 'toolsrc/src/PostBuildLint.cpp') diff --git a/toolsrc/src/PostBuildLint.cpp b/toolsrc/src/PostBuildLint.cpp index 533e28fcf..7986d913a 100644 --- a/toolsrc/src/PostBuildLint.cpp +++ b/toolsrc/src/PostBuildLint.cpp @@ -7,7 +7,6 @@ #include "coff_file_reader.h" #include "PostBuildLint_BuildInfo.h" #include "PostBuildLint_BuildType.h" -#include "PostBuildLint_OutdatedDynamicCrt.h" namespace vcpkg::PostBuildLint { @@ -17,6 +16,38 @@ namespace vcpkg::PostBuildLint ERROR_DETECTED = 1 }; + struct OutdatedDynamicCrt + { + std::string name; + std::regex regex; + }; + + const std::vector& get_outdated_dynamic_crts() + { + static const std::vector v = { + {"msvcp100.dll", std::regex(R"(msvcp100\.dll)")}, + {"msvcp100d.dll", std::regex(R"(msvcp100d\.dll)")}, + {"msvcp110.dll", std::regex(R"(msvcp110\.dll)")}, + {"msvcp110_win.dll", std::regex(R"(msvcp110_win\.dll)")}, + {"msvcp120.dll", std::regex(R"(msvcp120\.dll)")}, + {"msvcp120_clr0400.dll", std::regex(R"(msvcp120_clr0400\.dll)")}, + {"msvcp60.dll", std::regex(R"(msvcp60\.dll)")}, + {"msvcp60.dll", std::regex(R"(msvcp60\.dll)")}, + + {"msvcr100.dll", std::regex(R"(msvcr100\.dll)")}, + {"msvcr100d.dll", std::regex(R"(msvcr100d\.dll)")}, + {"msvcr100_clr0400.dll", std::regex(R"(msvcr100_clr0400\.dll)")}, + {"msvcr110.dll", std::regex(R"(msvcr110\.dll)")}, + {"msvcr120.dll", std::regex(R"(msvcr120\.dll)")}, + {"msvcr120_clr0400.dll", std::regex(R"(msvcr120_clr0400\.dll)")}, + {"msvcrt.dll", std::regex(R"(msvcrt\.dll)")}, + {"msvcrt20.dll", std::regex(R"(msvcrt20\.dll)")}, + {"msvcrt40.dll", std::regex(R"(msvcrt40\.dll)")} + }; + + return v; + } + static lint_status check_for_files_in_include_directory(const fs::path& package_dir) { const fs::path include_dir = package_dir / "include"; @@ -516,7 +547,7 @@ namespace vcpkg::PostBuildLint static lint_status check_outdated_crt_linkage_of_dlls(const std::vector& dlls, const fs::path dumpbin_exe) { - const std::vector& outdated_crts = OutdatedDynamicCrt::values(); + const std::vector& outdated_crts = get_outdated_dynamic_crts(); std::vector dlls_with_outdated_crt; @@ -528,7 +559,7 @@ namespace vcpkg::PostBuildLint for (const OutdatedDynamicCrt& outdated_crt : outdated_crts) { - if (std::regex_search(ec_data.output.cbegin(), ec_data.output.cend(), outdated_crt.crt_regex())) + if (std::regex_search(ec_data.output.cbegin(), ec_data.output.cend(), outdated_crt.regex)) { dlls_with_outdated_crt.push_back({dll, outdated_crt}); break; @@ -542,7 +573,7 @@ namespace vcpkg::PostBuildLint System::println(""); for (const OutdatedDynamicCrt_and_file btf : dlls_with_outdated_crt) { - System::println(" %s: %s", btf.file.generic_string(), btf.outdated_crt.toString()); + System::println(" %s: %s", btf.file.generic_string(), btf.outdated_crt.name); } System::println(""); @@ -625,47 +656,47 @@ namespace vcpkg::PostBuildLint switch (linkage_type_value_of(build_info.library_linkage)) { - case LinkageType::DYNAMIC: - { - const std::vector debug_dlls = Files::recursive_find_files_with_extension_in_dir(debug_bin_dir, ".dll"); - const std::vector release_dlls = Files::recursive_find_files_with_extension_in_dir(release_bin_dir, ".dll"); + case LinkageType::DYNAMIC: + { + const std::vector debug_dlls = Files::recursive_find_files_with_extension_in_dir(debug_bin_dir, ".dll"); + const std::vector release_dlls = Files::recursive_find_files_with_extension_in_dir(release_bin_dir, ".dll"); - error_count += check_matching_debug_and_release_binaries(debug_dlls, release_dlls); + error_count += check_matching_debug_and_release_binaries(debug_dlls, release_dlls); - error_count += check_lib_files_are_available_if_dlls_are_available(build_info.policies, debug_libs.size(), debug_dlls.size(), debug_lib_dir); - error_count += check_lib_files_are_available_if_dlls_are_available(build_info.policies, release_libs.size(), release_dlls.size(), release_lib_dir); + error_count += check_lib_files_are_available_if_dlls_are_available(build_info.policies, debug_libs.size(), debug_dlls.size(), debug_lib_dir); + error_count += check_lib_files_are_available_if_dlls_are_available(build_info.policies, release_libs.size(), release_dlls.size(), release_lib_dir); - std::vector dlls; - dlls.insert(dlls.cend(), debug_dlls.cbegin(), debug_dlls.cend()); - dlls.insert(dlls.cend(), release_dlls.cbegin(), release_dlls.cend()); + std::vector dlls; + dlls.insert(dlls.cend(), debug_dlls.cbegin(), debug_dlls.cend()); + dlls.insert(dlls.cend(), release_dlls.cbegin(), release_dlls.cend()); - error_count += check_exports_of_dlls(dlls, dumpbin_exe); - error_count += check_uwp_bit_of_dlls(spec.target_triplet().system(), dlls, dumpbin_exe); - error_count += check_dll_architecture(spec.target_triplet().architecture(), dlls); + error_count += check_exports_of_dlls(dlls, dumpbin_exe); + error_count += check_uwp_bit_of_dlls(spec.target_triplet().system(), dlls, dumpbin_exe); + error_count += check_dll_architecture(spec.target_triplet().architecture(), dlls); - error_count += check_outdated_crt_linkage_of_dlls(dlls, dumpbin_exe); - break; - } - case LinkageType::STATIC: - { - std::vector dlls; - Files::recursive_find_files_with_extension_in_dir(package_dir, ".dll", &dlls); - error_count += check_no_dlls_present(dlls); + error_count += check_outdated_crt_linkage_of_dlls(dlls, dumpbin_exe); + break; + } + case LinkageType::STATIC: + { + std::vector dlls; + Files::recursive_find_files_with_extension_in_dir(package_dir, ".dll", &dlls); + error_count += check_no_dlls_present(dlls); - error_count += check_bin_folders_are_not_present_in_static_build(package_dir); + 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, linkage_type_value_of(build_info.crt_linkage)), debug_libs, dumpbin_exe); - error_count += check_crt_linkage_of_libs(BuildType::value_of(ConfigurationType::RELEASE, linkage_type_value_of(build_info.crt_linkage)), release_libs, dumpbin_exe); - break; - } - case LinkageType::UNKNOWN: - { - error_count += 1; - System::println(System::color::warning, "Unknown library_linkage architecture: [ %s ]", build_info.library_linkage); - break; - } - default: - Checks::unreachable(); + error_count += check_crt_linkage_of_libs(BuildType::value_of(ConfigurationType::DEBUG, linkage_type_value_of(build_info.crt_linkage)), debug_libs, dumpbin_exe); + error_count += check_crt_linkage_of_libs(BuildType::value_of(ConfigurationType::RELEASE, linkage_type_value_of(build_info.crt_linkage)), release_libs, dumpbin_exe); + break; + } + case LinkageType::UNKNOWN: + { + error_count += 1; + System::println(System::color::warning, "Unknown library_linkage architecture: [ %s ]", build_info.library_linkage); + break; + } + default: + Checks::unreachable(); } #if 0 error_count += check_no_subdirectories(package_dir / "lib"); -- cgit v1.2.3 From a9f7fc6e90feaad50c1221ef9bd56e2620302215 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Wed, 8 Feb 2017 12:36:32 -0800 Subject: Make regex for OutdatedDyanmicCRTs case insensitive --- toolsrc/src/PostBuildLint.cpp | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) (limited to 'toolsrc/src/PostBuildLint.cpp') diff --git a/toolsrc/src/PostBuildLint.cpp b/toolsrc/src/PostBuildLint.cpp index 7986d913a..90bd55843 100644 --- a/toolsrc/src/PostBuildLint.cpp +++ b/toolsrc/src/PostBuildLint.cpp @@ -20,29 +20,32 @@ namespace vcpkg::PostBuildLint { std::string name; std::regex regex; + + OutdatedDynamicCrt(const std::string& name, const std::string& regex_as_string) + : name(name), regex(std::regex(regex_as_string, std::regex_constants::icase)) {} }; const std::vector& get_outdated_dynamic_crts() { static const std::vector v = { - {"msvcp100.dll", std::regex(R"(msvcp100\.dll)")}, - {"msvcp100d.dll", std::regex(R"(msvcp100d\.dll)")}, - {"msvcp110.dll", std::regex(R"(msvcp110\.dll)")}, - {"msvcp110_win.dll", std::regex(R"(msvcp110_win\.dll)")}, - {"msvcp120.dll", std::regex(R"(msvcp120\.dll)")}, - {"msvcp120_clr0400.dll", std::regex(R"(msvcp120_clr0400\.dll)")}, - {"msvcp60.dll", std::regex(R"(msvcp60\.dll)")}, - {"msvcp60.dll", std::regex(R"(msvcp60\.dll)")}, - - {"msvcr100.dll", std::regex(R"(msvcr100\.dll)")}, - {"msvcr100d.dll", std::regex(R"(msvcr100d\.dll)")}, - {"msvcr100_clr0400.dll", std::regex(R"(msvcr100_clr0400\.dll)")}, - {"msvcr110.dll", std::regex(R"(msvcr110\.dll)")}, - {"msvcr120.dll", std::regex(R"(msvcr120\.dll)")}, - {"msvcr120_clr0400.dll", std::regex(R"(msvcr120_clr0400\.dll)")}, - {"msvcrt.dll", std::regex(R"(msvcrt\.dll)")}, - {"msvcrt20.dll", std::regex(R"(msvcrt20\.dll)")}, - {"msvcrt40.dll", std::regex(R"(msvcrt40\.dll)")} + {"msvcp100.dll", R"(msvcp100\.dll)"}, + {"msvcp100d.dll", R"(msvcp100d\.dll)"}, + {"msvcp110.dll", R"(msvcp110\.dll)"}, + {"msvcp110_win.dll", R"(msvcp110_win\.dll)"}, + {"msvcp120.dll", R"(msvcp120\.dll)"}, + {"msvcp120_clr0400.dll", R"(msvcp120_clr0400\.dll)"}, + {"msvcp60.dll", R"(msvcp60\.dll)"}, + {"msvcp60.dll", R"(msvcp60\.dll)"}, + + {"msvcr100.dll", R"(msvcr100\.dll)"}, + {"msvcr100d.dll", R"(msvcr100d\.dll)"}, + {"msvcr100_clr0400.dll", R"(msvcr100_clr0400\.dll)"}, + {"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; -- cgit v1.2.3