From 2a7761f333604210cb40b83c206356fee175af64 Mon Sep 17 00:00:00 2001 From: "Travis F. Collins" Date: Tue, 27 Jun 2023 12:05:26 -0600 Subject: [PATCH] Add rpathing and libusb updates for macOS CI Signed-off-by: Travis F. Collins --- CI/azure/macos_tar_fixup.sh | 71 +++++++++++++++++++++++++++++++++++++ CI/azure/prepare_assets.sh | 0 azure-pipelines.yml | 3 ++ 3 files changed, 74 insertions(+) create mode 100644 CI/azure/macos_tar_fixup.sh mode change 100755 => 100644 CI/azure/prepare_assets.sh diff --git a/CI/azure/macos_tar_fixup.sh b/CI/azure/macos_tar_fixup.sh new file mode 100644 index 000000000..92c4bd685 --- /dev/null +++ b/CI/azure/macos_tar_fixup.sh @@ -0,0 +1,71 @@ +#!/bin/bash -xe + +# Extract tar.gz to temp folder +tarname=$(find . -maxdepth 1 -name '*.tar.gz') +if [ -z "${tarname}" ]; then + echo "tar.gz not found" + exit 1 +fi +# Remove .tar.gz from filename +subfoldername=$(echo "${tarname}" | rev | cut -b 8- | rev) + +mkdir -p temp_tar +tar -xzf "${tarname}" -C temp_tar +mv "temp_tar/${subfoldername}" temp +cd temp + +# Update rpath of library and tools +libusb_loc=$(find $(brew --cellar) -name libusb-1.0.dylib) +libxml_loc=$(find $(brew --cellar) -name libxml2.dylib) +libserialport_loc=$(find $(brew --cellar) -name libserialport.dylib) +libiio_loc=$(find . -name iio | grep Versions) +libiioheader_loc=$(find . -name iio.h) + +if [ ! -f "${libusb_loc}" ]; then + echo "libusb library not found" + exit 1 +fi +if [ ! -f "${libxml_loc}" ]; then + echo "libxml library not found" + exit 1 +fi +if [ ! -f "${libserialport_loc}" ]; then + echo "libserialport library not found" + exit 1 +fi + +# Create links to framework files +mkdir -p usr/local/{lib,include} +ln -fs "${libiio_loc}" usr/local/lib/libiio.dylib +ln -fs "${libiioheader_loc}" usr/local/include/iio.h + +# Copy dependent libs to local libs +cp "${libusb_loc}" usr/local/lib/ +cp "${libxml_loc}" usr/local/lib/ +cp "${libserialport_loc}" usr/local/lib/ +chmod +w usr/local/lib/libusb-1.0.dylib +chmod +w usr/local/lib/libxml2.dylib +chmod +w usr/local/lib/libserialport.dylib +install_name_tool -id @rpath/libusb-1.0.dylib usr/local/lib/libusb-1.0.dylib +install_name_tool -id @rpath/libxml2.dylib usr/local/lib/libxml2.dylib +install_name_tool -id @rpath/libserialport.dylib usr/local/lib/libserialport.dylib + +# Update rpath of library +install_name_tool -change "${libusb_loc}" "@rpath/libusb-1.0.dylib" "${libiio_loc}" +install_name_tool -change "${libxml_loc}" "@rpath/libxml2.dylib" "${libiio_loc}" +install_name_tool -change "${libserialport_loc}" "@rpath/libserialport.dylib" "${libiio_loc}" +install_name_tool -add_rpath @loader_path/. "${libiio_loc}" + +# Update tools +cd Library/Frameworks/iio.framework/Tools +for tool in *; +do + install_name_tool -add_rpath @loader_path/../.. "${tool}" +done +cd ../../../../ + +# Remove old tar and create new one +rm "../${tarname}" +tar -czf "../${tarname}" . +cd .. +rm -rf temp \ No newline at end of file diff --git a/CI/azure/prepare_assets.sh b/CI/azure/prepare_assets.sh old mode 100755 new mode 100644 diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 5a2aa4bdb..525024805 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -320,6 +320,9 @@ stages: cmake .. -Werror=dev -DCOMPILE_WARNING_AS_ERROR=ON -DOSX_PACKAGE=OFF -DENABLE_PACKAGING=ON -DCPP_BINDINGS=ON -DPYTHON_BINDINGS=ON -DWITH_SERIAL_BACKEND=OFF -DWITH_ZSTD=OFF -DCPACK_SYSTEM_NAME=${ARTIFACTNAME} -DCMAKE_SYSTEM_NAME="Darwin" make make package + mv ../CI/azure/macos_tar_fixup.sh . + chmod +x macos_tar_fixup.sh + ./macos_tar_fixup.sh cd .. displayName: 'Build tar' - script: |