[apr-util] Fix incorrect codes in apu.h (#27456)

* [apr-util] Fix incorrect header file

* x-add-version

* fix deprecated function and remove unused option

* x-add-version

* format

* x-add-version

* * Add comment explaining how APU_DECLARE_STATIC embedding works.
* Use vcpkg_replace_string.
* Quotes/formatting/trailing whitespace.

Co-authored-by: Billy O'Neal <bion@microsoft.com>
This commit is contained in:
Lily Wang 2022-10-26 12:56:35 -07:00 committed by GitHub
parent fc6685331b
commit 1be5a98d09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 35 additions and 28 deletions

View File

@ -2,12 +2,11 @@ vcpkg_download_distfile(ARCHIVE
URLS "https://archive.apache.org/dist/apr/apr-util-1.6.1.tar.bz2"
FILENAME "apr-util-1.6.1.tar.bz2"
SHA512 40eff8a37c0634f7fdddd6ca5e596b38de15fd10767a34c30bbe49c632816e8f3e1e230678034f578dd5816a94f246fb5dfdf48d644829af13bf28de3225205d
)
if(VCPKG_TARGET_IS_WINDOWS)
vcpkg_extract_source_archive_ex(
OUT_SOURCE_PATH SOURCE_PATH
vcpkg_extract_source_archive(
SOURCE_PATH
ARCHIVE "${ARCHIVE}"
PATCHES
use-vcpkg-expat.patch
@ -15,19 +14,8 @@ if(VCPKG_TARGET_IS_WINDOWS)
unglue.patch
)
if(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic)
set(APU_DECLARE_EXPORT ON)
set(APU_DECLARE_STATIC OFF)
else()
set(APU_DECLARE_EXPORT OFF)
set(APU_DECLARE_STATIC ON)
endif()
vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
-DAPU_DECLARE_EXPORT=${APU_DECLARE_EXPORT}
-DAPU_DECLARE_STATIC=${APU_DECLARE_STATIC}
OPTIONS_DEBUG
-DDISABLE_INSTALL_HEADERS=ON
)
@ -35,18 +23,35 @@ if(VCPKG_TARGET_IS_WINDOWS)
vcpkg_cmake_install()
vcpkg_copy_pdbs()
file(READ ${CURRENT_PACKAGES_DIR}/include/apu.h APU_H)
# Upstream include/apu.h.in has:
# ```
#elif defined(APU_DECLARE_STATIC)
#define APU_DECLARE(type) type __stdcall
#define APU_DECLARE_NONSTD(type) type __cdecl
#define APU_DECLARE_DATA
#elif defined(APU_DECLARE_EXPORT)
#define APU_DECLARE(type) __declspec(dllexport) type __stdcall
#define APU_DECLARE_NONSTD(type) __declspec(dllexport) type __cdecl
#define APU_DECLARE_DATA __declspec(dllexport)
#else
#define APU_DECLARE(type) __declspec(dllimport) type __stdcall
#define APU_DECLARE_NONSTD(type) __declspec(dllimport) type __cdecl
#define APU_DECLARE_DATA __declspec(dllimport)
#endif
# ```
# When building, BUILD_SHARED_LIBS sets APU_DECLARE_STATIC to 0 and APU_DECLARE_EXPORT to 1
# Not BUILD_SHARED_LIBS sets APU_DECLARE_STATIC to 1 and APU_DECLARE_EXPORT to 0
# When consuming APU_DECLARE_EXPORT is always 0 (assumed), so we need only embed the static or not setting
# into the resulting headers:
if(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic)
string(REPLACE "defined(APU_DECLARE_EXPORT)" "1" APU_H "${APU_H}")
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/apu.h" "defined(APU_DECLARE_STATIC)" "0")
else()
string(REPLACE "defined(APU_DECLARE_STATIC)" "1" APU_H "${APU_H}")
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/apu.h" "defined(APU_DECLARE_STATIC)" "1")
endif()
file(WRITE ${CURRENT_PACKAGES_DIR}/include/apu.h "${APU_H}")
else()
vcpkg_extract_source_archive_ex(
OUT_SOURCE_PATH SOURCE_PATH
ARCHIVE ${ARCHIVE}
vcpkg_extract_source_archive(
SOURCE_PATH
ARCHIVE "${ARCHIVE}"
)
# To cross-compile you will need a triplet file that locates the tool chain and sets --host and --cache parameters of "./configure".
@ -64,7 +69,7 @@ else()
vcpkg_configure_make(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
OPTIONS
"--prefix=${CURRENT_INSTALLED_DIR}"
"--with-apr=${CURRENT_INSTALLED_DIR}/tools/apr"
"--with-openssl=${CURRENT_INSTALLED_DIR}"
@ -75,7 +80,6 @@ else()
)
vcpkg_install_make()
vcpkg_fixup_pkgconfig()
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/tools/apr-util/bin/apu-1-config" "${CURRENT_INSTALLED_DIR}" "`dirname $0`/../../..")
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/tools/apr-util/bin/apu-1-config" "${CURRENT_BUILDTREES_DIR}" "not/existing")
@ -83,8 +87,6 @@ else()
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/tools/apr-util/debug/bin/apu-1-config" "${CURRENT_INSTALLED_DIR}" "`dirname $0`/../../../..")
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/tools/apr-util/debug/bin/apu-1-config" "${CURRENT_BUILDTREES_DIR}" "not/existing")
endif()
endif()
# Handle copyright
file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)

View File

@ -1,7 +1,7 @@
{
"name": "apr-util",
"version": "1.6.1",
"port-version": 8,
"port-version": 9,
"description": "Apache Portable Runtime (APR) project mission is to create and maintain software libraries that provide a predictable and consistent interface to underlying platform-specific implementation",
"homepage": "https://apr.apache.org/",
"license": "Apache-2.0",

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "b6d7bb58f16bd75a40a434742d0c0a12b89645d4",
"version": "1.6.1",
"port-version": 9
},
{
"git-tree": "e11acd0b01edac0a064893b89bd9eb2d976f4371",
"version": "1.6.1",

View File

@ -130,7 +130,7 @@
},
"apr-util": {
"baseline": "1.6.1",
"port-version": 8
"port-version": 9
},
"apsi": {
"baseline": "0.8.2",