Skip to content

Commit

Permalink
[vcpkg_fixup_pkgconfig] Handle spaces in path, do not validate indivi…
Browse files Browse the repository at this point in the history
…dual libraries (#13126)
  • Loading branch information
ras0219 committed Dec 8, 2020
1 parent ced334b commit dd44218
Show file tree
Hide file tree
Showing 12 changed files with 148 additions and 277 deletions.
21 changes: 11 additions & 10 deletions docs/maintainers/vcpkg_fixup_pkgconfig.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ Fix common paths in *.pc files and make everything relativ to $(prefix)
vcpkg_fixup_pkgconfig(
[RELEASE_FILES <PATHS>...]
[DEBUG_FILES <PATHS>...]
[SYSTEM_LIBRARIES <NAMES>...]
[IGNORE_FLAGS <FLAGS>]
[SKIP_CHECK]
)
```
Expand All @@ -22,21 +20,24 @@ Defaults to every *.pc file in the folder ${CURRENT_PACKAGES_DIR} without ${CURR
Specifies a list of files to apply the fixes for debug paths.
Defaults to every *.pc file in the folder ${CURRENT_PACKAGES_DIR}/debug/

### SYSTEM_LIBRARIES
If the *.pc file contains system libraries outside vcpkg these need to be listed here.
VCPKG checks every -l flag for the existence of the required library within vcpkg.
### SKIP_CHECK
Skips the library checks in vcpkg_fixup_pkgconfig. Only use if the script itself has unhandled cases.

### IGNORE_FLAGS
If the *.pc file contains flags in the lib field which are not libraries. These can be listed here
### SYSTEM_PACKAGES (deprecated)
This argument has been deprecated and has no effect.

### SKIP_CHECK
Skips the library checks in vcpkg_fixup_pkgconfig. Only use if the script itself has unhandled cases.
### SYSTEM_LIBRARIES (deprecated)
This argument has been deprecated and has no effect.

### IGNORE_FLAGS (deprecated)
This argument has been deprecated and has no effect.

## Notes
Still work in progress. If there are more cases which can be handled here feel free to add them

## Examples
Just call `vcpkg_fixup_pkgconfig()` after any install step which installs *.pc files.

* [brotli](https://github.com/Microsoft/vcpkg/blob/master/ports/brotli/portfile.cmake)

## Source
[scripts/cmake/vcpkg_fixup_pkgconfig.cmake](https://github.com/Microsoft/vcpkg/blob/master/scripts/cmake/vcpkg_fixup_pkgconfig.cmake)
2 changes: 2 additions & 0 deletions ports/ceres/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ vcpkg_configure_cmake(
-DBUILD_BENCHMARKS=OFF
-DBUILD_EXAMPLES=OFF
-DBUILD_TESTING=OFF
-DBUILD_BENCHMARKS=OFF
-DPROVIDE_UNINSTALL_TARGET=OFF
-DMSVC_USE_STATIC_CRT=${MSVC_USE_STATIC_CRT_VALUE}
-DLIB_SUFFIX=${LIB_SUFFIX}
)
Expand Down
2 changes: 1 addition & 1 deletion ports/libbson/CONTROL
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Source: libbson
Version: 1.16.1
Port-Version: 1
Port-Version: 2
Description: libbson is a library providing useful routines related to building, parsing, and iterating BSON documents.
Homepage: https://github.com/mongodb/libbson
4 changes: 4 additions & 0 deletions ports/libbson/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ file(READ ${CMAKE_CURRENT_LIST_DIR}/CONTROL _contents)
string(REGEX MATCH "\nVersion:[ ]*[^ \n]+" _contents "${_contents}")
string(REGEX REPLACE ".+Version:[ ]*([\\.0-9]+).*" "\\1" BUILD_VERSION "${_contents}")

file(WRITE "${BUILD_VERSION}" ${SOURCE_PATH}/VERSION_CURRENT)

vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
Expand All @@ -31,6 +33,7 @@ vcpkg_configure_cmake(
-DENABLE_EXAMPLES=OFF
-DENABLE_STATIC=${ENABLE_STATIC}
-DBUILD_VERSION=${BUILD_VERSION}
-DCMAKE_DISABLE_FIND_PACKAGE_PythonInterp=ON
)

vcpkg_install_cmake()
Expand All @@ -44,6 +47,7 @@ if (VCPKG_LIBRARY_LINKAGE STREQUAL static)
else()
vcpkg_fixup_cmake_targets(CONFIG_PATH lib/cmake/libbson-${PORT_POSTFIX} TARGET_PATH share/bson-${PORT_POSTFIX})
endif()

file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/share)
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/share/mongo-c-driver)

Expand Down
4 changes: 2 additions & 2 deletions ports/mongo-c-driver/CONTROL
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Source: mongo-c-driver
Version: 1.16.1-1
Port-Version: 1
Version: 1.16.1
Port-Version: 3
Build-Depends: libbson, openssl (!windows), zlib
Description: Client library written in C for MongoDB.
Homepage: https://github.com/mongodb/mongo-c-driver
Expand Down
3 changes: 3 additions & 0 deletions ports/mongo-c-driver/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ file(READ ${CMAKE_CURRENT_LIST_DIR}/CONTROL _contents)
string(REGEX MATCH "\nVersion:[ ]*[^ \n]+" _contents "${_contents}")
string(REGEX REPLACE ".+Version:[ ]*([\\.0-9]+).*" "\\1" BUILD_VERSION "${_contents}")

file(WRITE "${BUILD_VERSION}" ${SOURCE_PATH}/VERSION_CURRENT)

vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
Expand All @@ -55,6 +57,7 @@ vcpkg_configure_cmake(
-DENABLE_ZLIB=SYSTEM
-DENABLE_STATIC=${ENABLE_STATIC}
-DBUILD_VERSION=${BUILD_VERSION}
-DCMAKE_DISABLE_FIND_PACKAGE_PythonInterp=ON
${FEATURE_OPTIONS}
)

Expand Down
2 changes: 1 addition & 1 deletion ports/nettle/CONTROL
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Source: nettle
Version: 3.5.1
Port-Version: 4
Port-Version: 5
Homepage: https://git.lysator.liu.se/nettle/nettle
Description: Nettle is a low-level cryptographic library that is designed to fit easily in more or less any context: In crypto toolkits for object-oriented languages (C++, Python, Pike, ...), in applications like LSH or GNUPG, or even in kernel space.
Build-Depends: gmp, vs-yasm (windows), yasm-tool-helper (windows)
4 changes: 2 additions & 2 deletions ports/nettle/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ if(VCPKG_TARGET_IS_WINDOWS)
set(exec_prefix "\${prefix}")
set(libdir "\${prefix}/lib")
set(includedir "\${prefix}/include")
set(LIBS -lnettle -lgmp)
set(LIBS "-lnettle -lgmp")
configure_file("${SOURCE_PATH}/nettle.pc.in" "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/nettle.pc" @ONLY)
set(HOGWEED -lhogweed)
set(LIBS -lnettle)
Expand All @@ -93,7 +93,7 @@ if(VCPKG_TARGET_IS_WINDOWS)
set(exec_prefix "\${prefix}")
set(libdir "\${prefix}/lib")
set(includedir "\${prefix}/../include")
set(LIBS -lnettled -lgmpd)
set(LIBS "-lnettled -lgmpd")
configure_file("${SOURCE_PATH}/nettle.pc.in" "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/nettle.pc" @ONLY)
set(LIBS -lnettled)
set(HOGWEED -lhogweedd)
Expand Down
2 changes: 1 addition & 1 deletion ports/x265/CONTROL
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Source: x265
Version: 3.4
Port-Version: 1
Port-Version: 2
Homepage: https://github.com/videolan/x265
Description: x265 is a H.265 / HEVC video encoder application library, designed to encode video or images into an H.265 / HEVC encoded bitstream.
11 changes: 11 additions & 0 deletions ports/x265/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,17 @@ if(VCPKG_TARGET_IS_MINGW AND ENABLE_SHARED)
endif()

if(UNIX)
foreach(FILE "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/x265.pc" "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/x265.pc")
if(EXISTS "${FILE}")
file(READ "${FILE}" _contents)
string(REPLACE " -lstdc++" "" _contents "${_contents}")
string(REPLACE " -lc++" "" _contents "${_contents}")
string(REPLACE " -lgcc_s" "" _contents "${_contents}")
string(REPLACE " -lgcc" "" _contents "${_contents}")
string(REPLACE " -lrt" "" _contents "${_contents}")
file(WRITE "${FILE}" "${_contents}")
endif()
endforeach()
vcpkg_fixup_pkgconfig(SYSTEM_LIBRARIES numa)
else()
vcpkg_fixup_pkgconfig()
Expand Down
12 changes: 12 additions & 0 deletions scripts/azure-pipelines/end-to-end-tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,18 @@ function Run-Vcpkg {
./vcpkg @testArgs
}

##### Test spaces in the path
Refresh-TestRoot
$CurrentTest = "zlib with spaces in path"
Write-Host $CurrentTest
./vcpkg install zlib "--triplet" $Triplet `
"--no-binarycaching" `
"--x-buildtrees-root=$TestingRoot/build Trees" `
"--x-install-root=$TestingRoot/instalL ed" `
"--x-packages-root=$TestingRoot/packaG es"
Throw-IfFailed

##### Binary caching tests
if (-not $IsLinux -and -not $IsMacOS) {
Refresh-TestRoot
# Test msbuild props and targets
Expand Down
Loading

0 comments on commit dd44218

Please sign in to comment.