-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix osx-dynamic install names for updated dependent shared library ids (
- Loading branch information
1 parent
0857cef
commit afc0741
Showing
9 changed files
with
246 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
scripts/test_ports/rpath-macho-test-binaries/portfile.cmake
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
set(VCPKG_POLICY_EMPTY_INCLUDE_FOLDER enabled) | ||
vcpkg_check_linkage(ONLY_DYNAMIC_LIBRARY) | ||
|
||
vcpkg_cmake_configure( | ||
SOURCE_PATH "${CURRENT_PORT_DIR}/project" | ||
OPTIONS_RELEASE | ||
-DTEST_STRING=release | ||
OPTIONS_DEBUG | ||
-DTEST_STRING=debug | ||
) | ||
vcpkg_cmake_install() | ||
|
||
function(make_rpath_absolute lib_dir) | ||
string(REPLACE "/" "_" logname "make_rpath_absolute-${lib_dir}") | ||
vcpkg_execute_required_process( | ||
COMMAND "install_name_tool" -id ${CURRENT_INSTALLED_DIR}/${lib_dir}/librpath-macho-backend-lib++.dylib ${CURRENT_PACKAGES_DIR}/${lib_dir}/librpath-macho-backend-lib++.dylib | ||
WORKING_DIRECTORY "${CURRENT_PACKAGES_DIR}" | ||
LOGNAME "${logname}-id" | ||
) | ||
|
||
vcpkg_execute_required_process( | ||
COMMAND "install_name_tool" -change @rpath/librpath-macho-backend-lib++.dylib ${CURRENT_INSTALLED_DIR}/${lib_dir}/librpath-macho-backend-lib++.dylib ${CURRENT_PACKAGES_DIR}/${lib_dir}/librpath-macho-test-lib.dylib | ||
WORKING_DIRECTORY "${CURRENT_PACKAGES_DIR}" | ||
LOGNAME "${logname}-change" | ||
) | ||
endfunction() | ||
|
||
if(NOT VCPKG_BUILD_TYPE) | ||
vcpkg_copy_tools(TOOL_NAMES rpath-macho-test-tool | ||
SEARCH_DIR "${CURRENT_PACKAGES_DIR}/debug/bin" | ||
DESTINATION "${CURRENT_PACKAGES_DIR}/debug/tools/${PORT}" | ||
) | ||
vcpkg_copy_tools(TOOL_NAMES rpath-macho-test-tool | ||
SEARCH_DIR "${CURRENT_PACKAGES_DIR}/debug/bin" | ||
DESTINATION "${CURRENT_PACKAGES_DIR}/manual-tools/${PORT}/debug" | ||
) | ||
vcpkg_copy_tools(TOOL_NAMES rpath-macho-test-tool | ||
SEARCH_DIR "${CURRENT_PACKAGES_DIR}/debug/bin" | ||
DESTINATION "${CURRENT_PACKAGES_DIR}/tools/${PORT}/debug" | ||
) | ||
make_rpath_absolute("debug/lib") | ||
endif() | ||
make_rpath_absolute("lib") | ||
vcpkg_copy_tools(TOOL_NAMES rpath-macho-test-tool DESTINATION "${CURRENT_PACKAGES_DIR}/manual-tools/${PORT}") | ||
vcpkg_copy_tools(TOOL_NAMES rpath-macho-test-tool AUTO_CLEAN) | ||
file(WRITE "${CURRENT_PACKAGES_DIR}/share/${PORT}/copyright" "This test port is part of vcpkg.") |
17 changes: 17 additions & 0 deletions
17
scripts/test_ports/rpath-macho-test-binaries/project/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
cmake_minimum_required(VERSION 3.7) | ||
project(rpath-macho-test CXX) | ||
|
||
set(TEST_STRING "" CACHE STRING "") | ||
|
||
set(CMAKE_SKIP_INSTALL_RPATH TRUE) | ||
|
||
add_library(rpath-macho-backend-lib++ transitive.cpp) | ||
target_compile_definitions(rpath-macho-backend-lib++ PRIVATE "TEST_STRING=\"${TEST_STRING}\"") | ||
|
||
add_library(rpath-macho-test-lib lib.cpp) | ||
target_link_libraries(rpath-macho-test-lib PRIVATE rpath-macho-backend-lib++) | ||
|
||
add_executable(rpath-macho-test-tool main.cpp) | ||
target_link_libraries(rpath-macho-test-tool PRIVATE rpath-macho-test-lib) | ||
|
||
install(TARGETS rpath-macho-backend-lib++ rpath-macho-test-lib rpath-macho-test-tool) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
extern const char* getTestStringBackend(); | ||
|
||
const char* getTestString() | ||
{ | ||
return getTestStringBackend(); | ||
} |
8 changes: 8 additions & 0 deletions
8
scripts/test_ports/rpath-macho-test-binaries/project/main.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#include <stdio.h> | ||
|
||
extern const char* getTestString(); | ||
|
||
int main() | ||
{ | ||
puts(getTestString()); | ||
} |
4 changes: 4 additions & 0 deletions
4
scripts/test_ports/rpath-macho-test-binaries/project/transitive.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
const char* getTestStringBackend() | ||
{ | ||
return TEST_STRING; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"name": "rpath-macho-test-binaries", | ||
"version-string": "ci", | ||
"description": "Provides installed binaries for rpath macho fixup test", | ||
"supports": "native & osx", | ||
"dependencies": [ | ||
{ | ||
"name": "vcpkg-cmake", | ||
"host": true | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
set(VCPKG_POLICY_EMPTY_PACKAGE enabled) | ||
|
||
foreach(dir IN ITEMS tools/rpath-macho-test-binaries manual-tools/rpath-macho-test-binaries) | ||
string(REPLACE "/" "_" logname "execute-rel-${dir}") | ||
vcpkg_execute_required_process( | ||
COMMAND "${CURRENT_INSTALLED_DIR}/${dir}/rpath-macho-test-tool" | ||
WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}" | ||
OUTPUT_VARIABLE output | ||
OUTPUT_STRIP_TRAILING_WHITESPACE | ||
LOGNAME "${logname}" | ||
) | ||
if(NOT output STREQUAL "release") | ||
message(SEND_ERROR "${dir}: $Actual: '${output}', expected: 'release'") | ||
endif() | ||
endforeach() | ||
|
||
if(NOT VCPKG_BUILD_TYPE) | ||
foreach(dir IN ITEMS tools/rpath-macho-test-binaries/debug manual-tools/rpath-macho-test-binaries/debug debug/tools/rpath-macho-test-binaries) | ||
string(REPLACE "/" "_" logname "execute-dbg-${dir}") | ||
vcpkg_execute_required_process( | ||
COMMAND "${CURRENT_INSTALLED_DIR}/${dir}/rpath-macho-test-tool" | ||
WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}" | ||
OUTPUT_VARIABLE output | ||
OUTPUT_STRIP_TRAILING_WHITESPACE | ||
LOGNAME "${logname}" | ||
) | ||
if(NOT output STREQUAL "debug") | ||
message(SEND_ERROR "${dir}: Actual: '${output}', expected: 'debug'") | ||
endif() | ||
endforeach() | ||
endif() | ||
|
||
function(check_proper_rpath macho_lib) | ||
vcpkg_execute_required_process( | ||
COMMAND "otool" "-L" "${macho_lib}" | ||
WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}" | ||
OUTPUT_VARIABLE output | ||
OUTPUT_STRIP_TRAILING_WHITESPACE | ||
LOGNAME "${logname}" | ||
) | ||
|
||
set(found_rpath_backend_lib OFF) | ||
|
||
string(REPLACE "\n" ";" output_lines "${output}") | ||
# Ignore first line, it contains the path to the lib which we are checking | ||
list(REMOVE_AT output_lines 0) | ||
foreach(line IN LISTS output_lines) | ||
if("${line}" MATCHES "\\s+/.*librpath-macho-backend-lib\\+\\+\\.dylib") | ||
message(SEND_ERROR "${line} contains an absolute path") | ||
endif() | ||
if("${line}" MATCHES "@rpath/librpath-macho-backend-lib\\+\\+.dylib") | ||
set(found_rpath_backend_lib ON) | ||
endif() | ||
endforeach() | ||
|
||
if(NOT found_rpath_backend_lib) | ||
message(SEND_ERROR "@rpath/librpath-macho-backend-lib++.dylib not found in ${output}") | ||
endif() | ||
endfunction() | ||
|
||
check_proper_rpath("${CURRENT_INSTALLED_DIR}/lib/librpath-macho-test-lib.dylib") | ||
check_proper_rpath("${CURRENT_INSTALLED_DIR}/debug/lib/librpath-macho-test-lib.dylib") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name": "rpath-macho-test", | ||
"version-string": "ci", | ||
"description": "Test rpath macho fixup", | ||
"dependencies": [ | ||
"rpath-macho-test-binaries" | ||
] | ||
} |