Skip to content

Commit

Permalink
post build check: Always allow .pc files in lib/pkgconfig and debug/l…
Browse files Browse the repository at this point in the history
…ib/pkgconfig (#906)
  • Loading branch information
autoantwort authored Feb 15, 2023
1 parent 931d804 commit 874159c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ set(VCPKG_POLICY_EMPTY_INCLUDE_FOLDER enabled)
if("header-only-good" IN_LIST FEATURES)
configure_file("${CMAKE_CURRENT_LIST_DIR}/wrong-pkgconfig.pc.in" "${CURRENT_PACKAGES_DIR}/share/pkgconfig/wrong-pkgconfig.pc" @ONLY)
endif()
if("header-only-bad" IN_LIST FEATURES)
if("header-only-in-lib" IN_LIST FEATURES)
configure_file("${CMAKE_CURRENT_LIST_DIR}/wrong-pkgconfig.pc.in" "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/wrong-pkgconfig.pc" @ONLY)
endif()
if("header-only-bad" IN_LIST FEATURES)
configure_file("${CMAKE_CURRENT_LIST_DIR}/wrong-pkgconfig.pc.in" "${CURRENT_PACKAGES_DIR}/share/configs/wrong-pkgconfig.pc" @ONLY)
endif()
set(LIBS "Libs: \"-L${libdir}\" -lwrong-pkgconfig")
if("lib-good" IN_LIST FEATURES)
configure_file("${CMAKE_CURRENT_LIST_DIR}/wrong-pkgconfig.pc.in" "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/wrong-pkgconfig.pc" @ONLY)
Expand Down
3 changes: 3 additions & 0 deletions azure-pipelines/e2e_ports/overlays/wrong-pkgconfig/vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
"header-only-good": {
"description": ""
},
"header-only-in-lib": {
"description": ""
},
"header-only-bad": {
"description": ""
},
Expand Down
4 changes: 4 additions & 0 deletions azure-pipelines/end-to-end-tests-dir/wrong-pkgconfig.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ Run-Vcpkg @commonArgs install "wrong-pkgconfig[header-only-good]"
Throw-IfFailed
Remove-Item -Recurse -Force $installRoot

Run-Vcpkg @commonArgs install "wrong-pkgconfig[header-only-in-lib]"
Throw-IfFailed
Remove-Item -Recurse -Force $installRoot

Run-Vcpkg @commonArgs install "wrong-pkgconfig[header-only-bad]"
Throw-IfNotFailed
Remove-Item -Recurse -Force $installRoot
Expand Down
5 changes: 3 additions & 2 deletions src/vcpkg/postbuildlint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -837,6 +837,9 @@ namespace vcpkg
{
if (!Strings::ends_with(path, ".pc")) continue;
const auto parent_path = Path(path.parent_path());
// Always allow .pc files at 'lib/pkgconfig' and 'debug/lib/pkgconfig'
if (parent_path == lib_dir || parent_path == debug_dir) continue;

const bool contains_libs =
Util::any_of(fs.read_lines(path).value_or_exit(VCPKG_LINE_INFO), [](const std::string& line) {
if (Strings::starts_with(line, "Libs"))
Expand All @@ -860,13 +863,11 @@ namespace vcpkg
const bool is_debug = Strings::starts_with(path, Path(dir) / "debug");
if (is_debug)
{
if (parent_path == debug_dir) continue;
misplaced_pkgconfig_files.push_back({std::move(path), MisplacedFile::Type::Debug});
contains_debug = true;
}
else
{
if (parent_path == lib_dir) continue;
misplaced_pkgconfig_files.push_back({std::move(path), MisplacedFile::Type::Release});
contains_release = true;
}
Expand Down

0 comments on commit 874159c

Please sign in to comment.