mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-12-18 19:30:15 +08:00
Remove OutdatedDynamicCrt enum. Replace with vector<struct>
This commit is contained in:
parent
d4fa0b34c0
commit
d36a1b7cb0
@ -1,59 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include <vector>
|
|
||||||
#include <regex>
|
|
||||||
|
|
||||||
namespace vcpkg::PostBuildLint
|
|
||||||
{
|
|
||||||
struct OutdatedDynamicCrt
|
|
||||||
{
|
|
||||||
// Old CPP
|
|
||||||
static const OutdatedDynamicCrt MSVCP100_DLL;
|
|
||||||
static const OutdatedDynamicCrt MSVCP100D_DLL;
|
|
||||||
static const OutdatedDynamicCrt MSVCP110_DLL;
|
|
||||||
static const OutdatedDynamicCrt MSVCP110_WIN_DLL;
|
|
||||||
static const OutdatedDynamicCrt MSVCP120_DLL;
|
|
||||||
static const OutdatedDynamicCrt MSVCP120_CLR0400_DLL;
|
|
||||||
static const OutdatedDynamicCrt MSVCP60_DLL;
|
|
||||||
static const OutdatedDynamicCrt MSVCP_WIN_DLL;
|
|
||||||
|
|
||||||
// Old C
|
|
||||||
static const OutdatedDynamicCrt MSVCR100_DLL;
|
|
||||||
static const OutdatedDynamicCrt MSVCR100D_DLL;
|
|
||||||
static const OutdatedDynamicCrt MSVCR100_CLR0400_DLL;
|
|
||||||
static const OutdatedDynamicCrt MSVCR110_DLL;
|
|
||||||
static const OutdatedDynamicCrt MSVCR120_DLL;
|
|
||||||
static const OutdatedDynamicCrt MSVCR120_CLR0400_DLL;
|
|
||||||
static const OutdatedDynamicCrt MSVCRT_DLL;
|
|
||||||
static const OutdatedDynamicCrt MSVCRT20_DLL;
|
|
||||||
static const OutdatedDynamicCrt MSVCRT40_DLL;
|
|
||||||
|
|
||||||
static const std::vector<OutdatedDynamicCrt>& values()
|
|
||||||
{
|
|
||||||
static const std::vector<OutdatedDynamicCrt> v = {
|
|
||||||
MSVCP100_DLL, MSVCP100D_DLL,
|
|
||||||
MSVCP110_DLL,MSVCP110_WIN_DLL,
|
|
||||||
MSVCP120_DLL, MSVCP120_CLR0400_DLL,
|
|
||||||
MSVCP60_DLL,
|
|
||||||
MSVCP_WIN_DLL,
|
|
||||||
|
|
||||||
MSVCR100_DLL, MSVCR100D_DLL, MSVCR100_CLR0400_DLL,
|
|
||||||
MSVCR110_DLL,
|
|
||||||
MSVCR120_DLL, MSVCR120_CLR0400_DLL,
|
|
||||||
MSVCRT_DLL, MSVCRT20_DLL,MSVCRT40_DLL
|
|
||||||
};
|
|
||||||
return v;
|
|
||||||
}
|
|
||||||
|
|
||||||
OutdatedDynamicCrt() = delete;
|
|
||||||
|
|
||||||
std::regex crt_regex() const;
|
|
||||||
const std::string& toString() const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
explicit OutdatedDynamicCrt(const std::string& dll_name, const std::string& crt_regex_as_string)
|
|
||||||
: m_dll_name(dll_name), m_crt_regex_as_string(crt_regex_as_string) { }
|
|
||||||
|
|
||||||
std::string m_dll_name;
|
|
||||||
std::string m_crt_regex_as_string;
|
|
||||||
};
|
|
||||||
}
|
|
@ -7,7 +7,6 @@
|
|||||||
#include "coff_file_reader.h"
|
#include "coff_file_reader.h"
|
||||||
#include "PostBuildLint_BuildInfo.h"
|
#include "PostBuildLint_BuildInfo.h"
|
||||||
#include "PostBuildLint_BuildType.h"
|
#include "PostBuildLint_BuildType.h"
|
||||||
#include "PostBuildLint_OutdatedDynamicCrt.h"
|
|
||||||
|
|
||||||
namespace vcpkg::PostBuildLint
|
namespace vcpkg::PostBuildLint
|
||||||
{
|
{
|
||||||
@ -17,6 +16,38 @@ namespace vcpkg::PostBuildLint
|
|||||||
ERROR_DETECTED = 1
|
ERROR_DETECTED = 1
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct OutdatedDynamicCrt
|
||||||
|
{
|
||||||
|
std::string name;
|
||||||
|
std::regex regex;
|
||||||
|
};
|
||||||
|
|
||||||
|
const std::vector<OutdatedDynamicCrt>& get_outdated_dynamic_crts()
|
||||||
|
{
|
||||||
|
static const std::vector<OutdatedDynamicCrt> 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)
|
static lint_status check_for_files_in_include_directory(const fs::path& package_dir)
|
||||||
{
|
{
|
||||||
const fs::path include_dir = package_dir / "include";
|
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<fs::path>& dlls, const fs::path dumpbin_exe)
|
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;
|
std::vector<OutdatedDynamicCrt_and_file> dlls_with_outdated_crt;
|
||||||
|
|
||||||
@ -528,7 +559,7 @@ namespace vcpkg::PostBuildLint
|
|||||||
|
|
||||||
for (const OutdatedDynamicCrt& outdated_crt : outdated_crts)
|
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});
|
dlls_with_outdated_crt.push_back({dll, outdated_crt});
|
||||||
break;
|
break;
|
||||||
@ -542,7 +573,7 @@ namespace vcpkg::PostBuildLint
|
|||||||
System::println("");
|
System::println("");
|
||||||
for (const OutdatedDynamicCrt_and_file btf : dlls_with_outdated_crt)
|
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("");
|
System::println("");
|
||||||
|
|
||||||
@ -625,47 +656,47 @@ namespace vcpkg::PostBuildLint
|
|||||||
|
|
||||||
switch (linkage_type_value_of(build_info.library_linkage))
|
switch (linkage_type_value_of(build_info.library_linkage))
|
||||||
{
|
{
|
||||||
case LinkageType::DYNAMIC:
|
case LinkageType::DYNAMIC:
|
||||||
{
|
{
|
||||||
const std::vector<fs::path> debug_dlls = Files::recursive_find_files_with_extension_in_dir(debug_bin_dir, ".dll");
|
const std::vector<fs::path> debug_dlls = Files::recursive_find_files_with_extension_in_dir(debug_bin_dir, ".dll");
|
||||||
const std::vector<fs::path> release_dlls = Files::recursive_find_files_with_extension_in_dir(release_bin_dir, ".dll");
|
const std::vector<fs::path> 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, 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, release_libs.size(), release_dlls.size(), release_lib_dir);
|
||||||
|
|
||||||
std::vector<fs::path> dlls;
|
std::vector<fs::path> dlls;
|
||||||
dlls.insert(dlls.cend(), debug_dlls.cbegin(), debug_dlls.cend());
|
dlls.insert(dlls.cend(), debug_dlls.cbegin(), debug_dlls.cend());
|
||||||
dlls.insert(dlls.cend(), release_dlls.cbegin(), release_dlls.cend());
|
dlls.insert(dlls.cend(), release_dlls.cbegin(), release_dlls.cend());
|
||||||
|
|
||||||
error_count += check_exports_of_dlls(dlls, dumpbin_exe);
|
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_uwp_bit_of_dlls(spec.target_triplet().system(), dlls, dumpbin_exe);
|
||||||
error_count += check_dll_architecture(spec.target_triplet().architecture(), dlls);
|
error_count += check_dll_architecture(spec.target_triplet().architecture(), dlls);
|
||||||
|
|
||||||
error_count += check_outdated_crt_linkage_of_dlls(dlls, dumpbin_exe);
|
error_count += check_outdated_crt_linkage_of_dlls(dlls, dumpbin_exe);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case LinkageType::STATIC:
|
case LinkageType::STATIC:
|
||||||
{
|
{
|
||||||
std::vector<fs::path> dlls;
|
std::vector<fs::path> dlls;
|
||||||
Files::recursive_find_files_with_extension_in_dir(package_dir, ".dll", &dlls);
|
Files::recursive_find_files_with_extension_in_dir(package_dir, ".dll", &dlls);
|
||||||
error_count += check_no_dlls_present(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::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);
|
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;
|
break;
|
||||||
}
|
}
|
||||||
case LinkageType::UNKNOWN:
|
case LinkageType::UNKNOWN:
|
||||||
{
|
{
|
||||||
error_count += 1;
|
error_count += 1;
|
||||||
System::println(System::color::warning, "Unknown library_linkage architecture: [ %s ]", build_info.library_linkage);
|
System::println(System::color::warning, "Unknown library_linkage architecture: [ %s ]", build_info.library_linkage);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
Checks::unreachable();
|
Checks::unreachable();
|
||||||
}
|
}
|
||||||
#if 0
|
#if 0
|
||||||
error_count += check_no_subdirectories(package_dir / "lib");
|
error_count += check_no_subdirectories(package_dir / "lib");
|
||||||
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -154,7 +154,6 @@
|
|||||||
<ClInclude Include="..\include\PostBuildLint_BuildType.h" />
|
<ClInclude Include="..\include\PostBuildLint_BuildType.h" />
|
||||||
<ClInclude Include="..\include\PostBuildLint_ConfigurationType.h" />
|
<ClInclude Include="..\include\PostBuildLint_ConfigurationType.h" />
|
||||||
<ClInclude Include="..\include\PostBuildLint_LinkageType.h" />
|
<ClInclude Include="..\include\PostBuildLint_LinkageType.h" />
|
||||||
<ClInclude Include="..\include\PostBuildLint_OutdatedDynamicCrt.h" />
|
|
||||||
<ClInclude Include="..\include\SourceParagraph.h" />
|
<ClInclude Include="..\include\SourceParagraph.h" />
|
||||||
<ClInclude Include="..\include\StatusParagraph.h" />
|
<ClInclude Include="..\include\StatusParagraph.h" />
|
||||||
<ClInclude Include="..\include\StatusParagraphs.h" />
|
<ClInclude Include="..\include\StatusParagraphs.h" />
|
||||||
@ -214,7 +213,6 @@
|
|||||||
<ClCompile Include="..\src\PostBuildLint.cpp" />
|
<ClCompile Include="..\src\PostBuildLint.cpp" />
|
||||||
<ClCompile Include="..\src\PostBuildLint_ConfigurationType.cpp" />
|
<ClCompile Include="..\src\PostBuildLint_ConfigurationType.cpp" />
|
||||||
<ClCompile Include="..\src\PostBuildLint_LinkageType.cpp" />
|
<ClCompile Include="..\src\PostBuildLint_LinkageType.cpp" />
|
||||||
<ClCompile Include="..\src\PostBuildLint_OutdatedDynamicCrt.cpp" />
|
|
||||||
<ClCompile Include="..\src\PostBuildLint_BuildType.cpp" />
|
<ClCompile Include="..\src\PostBuildLint_BuildType.cpp" />
|
||||||
<ClCompile Include="..\src\Stopwatch.cpp" />
|
<ClCompile Include="..\src\Stopwatch.cpp" />
|
||||||
<ClCompile Include="..\src\vcpkglib.cpp" />
|
<ClCompile Include="..\src\vcpkglib.cpp" />
|
||||||
|
@ -165,9 +165,6 @@
|
|||||||
<ClCompile Include="..\src\PostBuildLint_ConfigurationType.cpp">
|
<ClCompile Include="..\src\PostBuildLint_ConfigurationType.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\src\PostBuildLint_OutdatedDynamicCrt.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\src\PostBuildLint_BuildType.cpp">
|
<ClCompile Include="..\src\PostBuildLint_BuildType.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
@ -293,8 +290,5 @@
|
|||||||
<ClInclude Include="..\include\PostBuildLint_BuildType.h">
|
<ClInclude Include="..\include\PostBuildLint_BuildType.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\include\PostBuildLint_OutdatedDynamicCrt.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
Loading…
Reference in New Issue
Block a user