Skip to content

Commit

Permalink
feat: fix [libb2] uses wrong install name in arm64-osx-dynamic triplet
Browse files Browse the repository at this point in the history
  • Loading branch information
liviaerxin committed May 30, 2023
1 parent afbb37c commit 382bd38
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 3 deletions.
52 changes: 51 additions & 1 deletion ports/libb2/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ vcpkg_from_github(
HEAD_REF master
)

# The `libb2` true version is from `B2_LIBRARY_VERSION` defined in `configure.ac`, which `libtool` use `-version-info $(B2_LIBRARY_VERSION)` to set libb2's version(It generated [libb2.1.dylib, libb2.dylib])
set(B2_LIBRARY_VERSION 1:4:0)
string(REGEX MATCH "^[0-9]*" B2_LIBRARY_VERSION_MAJOR "${B2_LIBRARY_VERSION}")

set(OPTIONS)
if(CMAKE_HOST_WIN32)
set(OPTIONS --disable-native) # requires cpuid
Expand All @@ -18,9 +22,55 @@ vcpkg_configure_make(
ax_cv_check_cflags___O3=no # see https://github.com/microsoft/vcpkg/pull/17912#issuecomment-840514179
${OPTIONS}
)

vcpkg_install_make()
vcpkg_fixup_pkgconfig()

# Fix #31719: change rpath setting after install
if(VCPKG_TARGET_IS_OSX AND VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")
set(INSTALL_NAME_DIR "@rpath")

find_program(
INSTALL_NAME_TOOL
install_name_tool
DOC "Absolute path of install_name_tool"
REQUIRED
)

foreach(LIB_NAME IN ITEMS libb2)
# debug
vcpkg_execute_build_process(
COMMAND "${INSTALL_NAME_TOOL}" -id "${INSTALL_NAME_DIR}/${LIB_NAME}.${B2_LIBRARY_VERSION_MAJOR}.dylib"
"${LIB_NAME}.${B2_LIBRARY_VERSION_MAJOR}.dylib"
WORKING_DIRECTORY "${CURRENT_PACKAGES_DIR}/debug/lib"
LOGNAME "make-install-fix-rpath-dbg"
)

vcpkg_execute_build_process(
COMMAND "${INSTALL_NAME_TOOL}" -add_rpath "@loader_path"
"${LIB_NAME}.${B2_LIBRARY_VERSION_MAJOR}.dylib"
WORKING_DIRECTORY "${CURRENT_PACKAGES_DIR}/debug/lib"
LOGNAME "make-install-fix-rpath-dbg"
)

# release
vcpkg_execute_build_process(
COMMAND "${INSTALL_NAME_TOOL}" -id "${INSTALL_NAME_DIR}/${LIB_NAME}.${B2_LIBRARY_VERSION_MAJOR}.dylib"
"${LIB_NAME}.${B2_LIBRARY_VERSION_MAJOR}.dylib"
WORKING_DIRECTORY "${CURRENT_PACKAGES_DIR}/lib"
LOGNAME "make-install-fix-rpath-rel"
)

vcpkg_execute_build_process(
COMMAND "${INSTALL_NAME_TOOL}" -add_rpath "@loader_path"
"${LIB_NAME}.${B2_LIBRARY_VERSION_MAJOR}.dylib"
WORKING_DIRECTORY "${CURRENT_PACKAGES_DIR}/lib"
LOGNAME "make-install-fix-rpath-rel"
)
endforeach()

endif()

vcpkg_fixup_pkgconfig()

file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)

Expand Down
2 changes: 1 addition & 1 deletion ports/libb2/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "libb2",
"version": "0.98.1",
"port-version": 6,
"port-version": 7,
"description": "C library providing BLAKE2b, BLAKE2s, BLAKE2bp, BLAKE2sp",
"homepage": "https://github.com/BLAKE2/libb2",
"supports": "!windows"
Expand Down
2 changes: 1 addition & 1 deletion versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -3854,7 +3854,7 @@
},
"libb2": {
"baseline": "0.98.1",
"port-version": 6
"port-version": 7
},
"libbacktrace": {
"baseline": "2021-03-14",
Expand Down
5 changes: 5 additions & 0 deletions versions/l-/libb2.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "44f6dc3f78e49afde1d14b56295ebbadf8f0d01e",
"version": "0.98.1",
"port-version": 7
},
{
"git-tree": "7c113e12089453e4e2cf2bbf67ad1f0b80a133a8",
"version": "0.98.1",
Expand Down

0 comments on commit 382bd38

Please sign in to comment.