aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/src
diff options
context:
space:
mode:
authorRobert Schumacher <roschuma@microsoft.com>2017-02-08 15:24:59 -0800
committerRobert Schumacher <roschuma@microsoft.com>2017-02-08 15:24:59 -0800
commit4d433302417d7e2b6478d731bc222847c2cd434a (patch)
tree41c93a7ad44df67657cf8413fed745048579baf5 /toolsrc/src
parent95af9aac7c39765d1524b7c9c39dc283e9f0facf (diff)
parent2e94dfe97ca44dd78b3224321b5f9e06e6635854 (diff)
downloadvcpkg-4d433302417d7e2b6478d731bc222847c2cd434a.tar.gz
vcpkg-4d433302417d7e2b6478d731bc222847c2cd434a.zip
Merge branch 'master' into codicodi-ninja-support
Diffstat (limited to 'toolsrc/src')
-rw-r--r--toolsrc/src/PostBuildLint.cpp66
-rw-r--r--toolsrc/src/PostBuildLint_BuildPolicies.cpp13
-rw-r--r--toolsrc/src/PostBuildLint_OutdatedDynamicCrt.cpp35
-rw-r--r--toolsrc/src/commands_remove.cpp35
4 files changed, 88 insertions, 61 deletions
diff --git a/toolsrc/src/PostBuildLint.cpp b/toolsrc/src/PostBuildLint.cpp
index 5954089e9..90bd55843 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,41 @@ namespace vcpkg::PostBuildLint
ERROR_DETECTED = 1
};
+ struct OutdatedDynamicCrt
+ {
+ 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<OutdatedDynamicCrt>& get_outdated_dynamic_crts()
+ {
+ static const std::vector<OutdatedDynamicCrt> v = {
+ {"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;
+ }
+
static lint_status check_for_files_in_include_directory(const fs::path& package_dir)
{
const fs::path include_dir = package_dir / "include";
@@ -516,7 +550,7 @@ namespace vcpkg::PostBuildLint
static lint_status check_outdated_crt_linkage_of_dlls(const std::vector<fs::path>& dlls, const fs::path dumpbin_exe)
{
- const std::vector<OutdatedDynamicCrt>& outdated_crts = OutdatedDynamicCrt::values();
+ const std::vector<OutdatedDynamicCrt>& outdated_crts = get_outdated_dynamic_crts();
std::vector<OutdatedDynamicCrt_and_file> dlls_with_outdated_crt;
@@ -528,7 +562,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 +576,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("");
@@ -582,16 +616,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);
@@ -663,13 +702,22 @@ namespace vcpkg::PostBuildLint
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";
diff --git a/toolsrc/src/PostBuildLint_BuildPolicies.cpp b/toolsrc/src/PostBuildLint_BuildPolicies.cpp
index d7d67c991..4e5ac3cea 100644
--- a/toolsrc/src/PostBuildLint_BuildPolicies.cpp
+++ b/toolsrc/src/PostBuildLint_BuildPolicies.cpp
@@ -5,12 +5,15 @@
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;
diff --git a/toolsrc/src/PostBuildLint_OutdatedDynamicCrt.cpp b/toolsrc/src/PostBuildLint_OutdatedDynamicCrt.cpp
deleted file mode 100644
index 67965cd93..000000000
--- a/toolsrc/src/PostBuildLint_OutdatedDynamicCrt.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
-#include "pch.h"
-#include "PostBuildLint_OutdatedDynamicCrt.h"
-
-namespace vcpkg::PostBuildLint
-{
- const OutdatedDynamicCrt OutdatedDynamicCrt::MSVCP100_DLL = OutdatedDynamicCrt("msvcp100.dll", R"(msvcp100\.dll)");
- const OutdatedDynamicCrt OutdatedDynamicCrt::MSVCP100D_DLL = OutdatedDynamicCrt("msvcp100d.dll", R"(msvcp100d\.dll)");
- const OutdatedDynamicCrt OutdatedDynamicCrt::MSVCP110_DLL = OutdatedDynamicCrt("msvcp110.dll", R"(msvcp110\.dll)");
- const OutdatedDynamicCrt OutdatedDynamicCrt::MSVCP110_WIN_DLL = OutdatedDynamicCrt("msvcp110_win.dll", R"(msvcp110_win\.dll)");
- const OutdatedDynamicCrt OutdatedDynamicCrt::MSVCP120_DLL = OutdatedDynamicCrt("msvcp120.dll", R"(msvcp120\.dll)");
- const OutdatedDynamicCrt OutdatedDynamicCrt::MSVCP120_CLR0400_DLL = OutdatedDynamicCrt("msvcp120_clr0400.dll", R"(msvcp120_clr0400\.dll)");
- const OutdatedDynamicCrt OutdatedDynamicCrt::MSVCP60_DLL = OutdatedDynamicCrt("msvcp60.dll", R"(msvcp60\.dll)");
- const OutdatedDynamicCrt OutdatedDynamicCrt::MSVCP_WIN_DLL = OutdatedDynamicCrt("msvcp60.dll", R"(msvcp60\.dll)");;
-
- const OutdatedDynamicCrt OutdatedDynamicCrt::MSVCR100_DLL = OutdatedDynamicCrt("msvcr100.dll", R"(msvcr100\.dll)");
- const OutdatedDynamicCrt OutdatedDynamicCrt::MSVCR100D_DLL = OutdatedDynamicCrt("msvcr100d.dll", R"(msvcr100d\.dll)");
- const OutdatedDynamicCrt OutdatedDynamicCrt::MSVCR100_CLR0400_DLL = OutdatedDynamicCrt("msvcr100_clr0400.dll", R"(msvcr100_clr0400\.dll)");
- const OutdatedDynamicCrt OutdatedDynamicCrt::MSVCR110_DLL = OutdatedDynamicCrt("msvcr110.dll", R"(msvcr110\.dll)");
- const OutdatedDynamicCrt OutdatedDynamicCrt::MSVCR120_DLL = OutdatedDynamicCrt("msvcr120.dll", R"(msvcr120\.dll)");
- const OutdatedDynamicCrt OutdatedDynamicCrt::MSVCR120_CLR0400_DLL = OutdatedDynamicCrt("msvcr120_clr0400.dll", R"(msvcr120_clr0400\.dll)");
- const OutdatedDynamicCrt OutdatedDynamicCrt::MSVCRT_DLL = OutdatedDynamicCrt("msvcrt.dll", R"(msvcrt\.dll)");
- const OutdatedDynamicCrt OutdatedDynamicCrt::MSVCRT20_DLL = OutdatedDynamicCrt("msvcrt20.dll", R"(msvcrt20\.dll)");;
- const OutdatedDynamicCrt OutdatedDynamicCrt::MSVCRT40_DLL = OutdatedDynamicCrt("msvcrt40.dll", R"(msvcrt40\.dll)");;
-
- std::regex OutdatedDynamicCrt::crt_regex() const
- {
- const std::regex r(this->m_crt_regex_as_string, std::regex_constants::icase);
- return r;
- }
-
- const std::string& OutdatedDynamicCrt::toString() const
- {
- return this->m_dll_name;
- }
-}
diff --git a/toolsrc/src/commands_remove.cpp b/toolsrc/src/commands_remove.cpp
index 7e8608e72..f49104d1e 100644
--- a/toolsrc/src/commands_remove.cpp
+++ b/toolsrc/src/commands_remove.cpp
@@ -196,26 +196,29 @@ namespace vcpkg::Commands::Remove
for (const package_spec_with_remove_plan& action : remove_plan)
{
- if (action.plan.plan_type == remove_plan_type::NOT_INSTALLED)
+ const std::string display_name = action.spec.display_name();
+
+ switch (action.plan.plan_type)
{
- System::println(System::color::success, "Package %s is not installed", action.spec);
+ case remove_plan_type::NOT_INSTALLED:
+ System::println(System::color::success, "Package %s is not installed", display_name);
+ break;
+ case remove_plan_type::REMOVE:
+ System::println("Removing package %s... ", display_name);
+ remove_package(paths, action.spec, &status_db);
+ System::println(System::color::success, "Removing package %s... done", display_name);
+ break;
+ case remove_plan_type::UNKNOWN:
+ default:
+ Checks::unreachable();
}
- else if (action.plan.plan_type == remove_plan_type::REMOVE)
- {
- const std::string display_name = action.spec.display_name();
- System::println("Removing package %s... ", display_name);
- remove_package(paths, action.spec, &status_db);
- System::println(System::color::success, "Removing package %s... done", display_name);
- if (alsoRemoveFolderFromPackages)
- {
- System::println("Purging package %s... ", display_name);
- delete_directory(paths.packages / action.spec.dir());
- System::println(System::color::success, "Purging package %s... done", display_name);
- }
+ if (alsoRemoveFolderFromPackages)
+ {
+ System::println("Purging package %s... ", display_name);
+ delete_directory(paths.packages / action.spec.dir());
+ System::println(System::color::success, "Purging package %s... done", display_name);
}
- else
- Checks::unreachable();
}
exit(EXIT_SUCCESS);