Skip to content

Commit

Permalink
[apr-util] Fix incorrect codes in apu.h (#27456)
Browse files Browse the repository at this point in the history
* [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 <[email protected]>
  • Loading branch information
LilyWangLL and BillyONeal authored Oct 26, 2022
1 parent fc66853 commit 1be5a98
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 28 deletions.
54 changes: 28 additions & 26 deletions ports/apr-util/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,51 +2,56 @@ 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
apr.patch
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
)

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".
Expand All @@ -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}"
Expand All @@ -75,16 +80,13 @@ 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")
if(NOT VCPKG_BUILD_TYPE)
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)
2 changes: 1 addition & 1 deletion ports/apr-util/vcpkg.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
5 changes: 5 additions & 0 deletions versions/a-/apr-util.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "b6d7bb58f16bd75a40a434742d0c0a12b89645d4",
"version": "1.6.1",
"port-version": 9
},
{
"git-tree": "e11acd0b01edac0a064893b89bd9eb2d976f4371",
"version": "1.6.1",
Expand Down
2 changes: 1 addition & 1 deletion versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
},
"apr-util": {
"baseline": "1.6.1",
"port-version": 8
"port-version": 9
},
"apsi": {
"baseline": "0.8.2",
Expand Down

0 comments on commit 1be5a98

Please sign in to comment.