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 27, 2023
1 parent 351da8d commit e4bcb70
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 0 deletions.
56 changes: 56 additions & 0 deletions CI/azure/macos_tar_fixup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/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}" | sed 's/.\{7\}$//')
echo "subfoldername: ${subfoldername}"

mkdir -p temp_tar
tar -xzf ${tarname} -C temp_tar
mv temp_tar/${subfoldername} temp
cd temp
ls -la *

# Update rpath of library and tools
libusb_loc=$(find `brew --cellar` -name libusb-1.0.dylib)
libusbdir_loc=$(dirname `find $(brew --cellar) -name libusb-1.0.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

# 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 libusb to local libs
cp "${libusb_loc}" usr/local/lib/
chmod +w usr/local/lib/libusb-1.0.dylib
install_name_tool -id @rpath/libusb-1.0.dylib usr/local/lib/libusb-1.0.dylib

# Update rpath of library
install_name_tool -change "${libusb_loc}" "@rpath/libusb-1.0.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 e4bcb70

Please sign in to comment.