Skip to content

Commit

Permalink
Add rpathing and libusb updates for macOS CI
Browse files Browse the repository at this point in the history
Signed-off-by: Travis F. Collins <travis.collins@analog.com>
  • Loading branch information
tfcollins committed Jun 28, 2023
1 parent 351da8d commit 2a7761f
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 0 deletions.
71 changes: 71 additions & 0 deletions CI/azure/macos_tar_fixup.sh
Original file line number Diff line number Diff line change
@@ -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
Empty file modified CI/azure/prepare_assets.sh
100755 → 100644
Empty file.
3 changes: 3 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down

0 comments on commit 2a7761f

Please sign in to comment.