@@ -108,20 +108,37 @@ make LIBRARY_TYPE=static VERSION=$TAG all GPRBUILD_EXTRA=$TARGET_OPTION NODE_ARC
108108[ -z " $CROSS " ] && make LIBRARY_TYPE=static check
109109
110110
111- function fix_rpath ()
112- {
113- for R in ` otool -l $1 | grep -A2 LC_RPATH | awk ' / path /{ print $2 }' ` ; do
114- install_name_tool -delete_rpath $R $1
111+ # Find the path to libgmp as linked in the given executable
112+ function get_gmp_full_path() {
113+ otool -l " $1 " | grep ' ^\s*name.*libgmp.10.dylib' | awk ' / name /{print $2 }'
114+ }
115+
116+ function fix_rpath() {
117+ # Remove all rpath entries
118+ for R in $( otool -l " $1 " | grep -A2 LC_RPATH | awk ' / path /{ print $2 }' ) ; do
119+ install_name_tool -delete_rpath " $R " " $1 "
115120 done
116- install_name_tool -change /usr/local/opt/gmp/lib/libgmp.10.dylib @rpath/libgmp.10.dylib $1
117- install_name_tool -add_rpath @executable_path $1
121+ # Change reference to full path of libgmp into a reference to the rpath.
122+ gmp_full_path=$( get_gmp_full_path " $1 " )
123+ if [ -n " $gmp_full_path " ]; then
124+ install_name_tool -change " $gmp_full_path " @rpath/libgmp.10.dylib " $1 "
125+ fi
126+ # Add the executable directory to rpath so it can find shared libraries
127+ # packaged alongside the executable.
128+ install_name_tool -add_rpath @executable_path " $1 "
118129}
119130
120131ALS_EXEC_DIR=integration/vscode/ada/$NODE_ARCH /$NODE_PLATFORM
121132
122- if [ $RUNNER_OS = macOS -a -z " $CROSS " ]; then
123- cp -v -f /usr/local/opt/gmp/lib/libgmp.10.dylib $ALS_EXEC_DIR
124- fix_rpath $ALS_EXEC_DIR /ada_language_server
133+ if [ $RUNNER_OS = macOS ]; then
134+ # Get full path of libgmp as linked in the ALS exec
135+ gmp_full_path=$( get_gmp_full_path $ALS_EXEC_DIR /ada_language_server)
136+ if [ -f " $gmp_full_path " ]; then
137+ # Copy libgmp alongside the ALS exec
138+ cp -v -f " $gmp_full_path " " $ALS_EXEC_DIR "
139+ fi
140+ # Fix rpath entries of the ALS exec so it can find libgmp alongside it
141+ fix_rpath " $ALS_EXEC_DIR /ada_language_server"
125142fi
126143
127144if [ " $DEBUG " != " debug" ]; then
0 commit comments