Skip to content

Commit

Permalink
[mingw] fix lib arch checks (#426)
Browse files Browse the repository at this point in the history
* no lib arch checks for mingw

The cofffilereader fails when reading .a files with 'Could not find proper second linker member'

* do this a different way that makes it act the same way as before

Co-authored-by: nicole mazzuca <[email protected]>
  • Loading branch information
autoantwort and strega-nil authored Mar 9, 2022
1 parent cb09f11 commit 1affd32
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
4 changes: 3 additions & 1 deletion include/vcpkg/base/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ namespace vcpkg::Util
template<class Vec, class Key>
bool contains(const Vec& container, const Key& item)
{
return std::find(container.begin(), container.end(), item) != container.end();
using std::begin;
using std::end;
return std::find(begin(container), end(container), item) != end(container);
}
template<class T>
std::vector<T> concat(View<T> r1, View<T> r2)
Expand Down
31 changes: 17 additions & 14 deletions src/vcpkg/postbuildlint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ using vcpkg::Build::PreBuildInfo;

namespace vcpkg::PostBuildLint
{
constexpr static const StringLiteral windows_system_names[] = {
"",
"Windows",
"WindowsStore",
"MinGW",
};

enum class LintStatus
{
SUCCESS = 0,
Expand Down Expand Up @@ -556,8 +563,7 @@ namespace vcpkg::PostBuildLint
const Filesystem& fs)
{
std::vector<FileAndArch> binaries_with_invalid_architecture;
if (cmake_system_name.empty() || cmake_system_name == "Windows" || cmake_system_name == "WindowsStore" ||
cmake_system_name == "MinGW")
if (Util::Vectors::contains(windows_system_names, cmake_system_name))
{
for (const Path& file : files)
{
Expand Down Expand Up @@ -1033,18 +1039,15 @@ namespace vcpkg::PostBuildLint
const auto debug_bin_dir = package_dir / "debug" / "bin";
const auto release_bin_dir = package_dir / "bin";

const auto lib_filter = [&pre_build_info]() {
if (pre_build_info.cmake_system_name.empty() || pre_build_info.cmake_system_name == "Windows" ||
pre_build_info.cmake_system_name == "WindowsStore")
{
return NotExtensionsCaseInsensitive{{".lib"}};
}
if (pre_build_info.cmake_system_name == "MinGW")
{
return NotExtensionsCaseInsensitive{{".lib", ".a"}};
}
return NotExtensionsCaseInsensitive{{".so", ".a", ".dylib"}};
}();
NotExtensionsCaseInsensitive lib_filter;
if (Util::Vectors::contains(windows_system_names, pre_build_info.cmake_system_name))
{
lib_filter = NotExtensionsCaseInsensitive{{".lib"}};
}
else
{
lib_filter = NotExtensionsCaseInsensitive{{".so", ".a", ".dylib"}};
}

std::vector<Path> debug_libs = fs.get_regular_files_recursive(debug_lib_dir, IgnoreErrors{});
Util::erase_remove_if(debug_libs, lib_filter);
Expand Down

0 comments on commit 1affd32

Please sign in to comment.