@@ -10,7 +10,12 @@ NO_REBASE=$4 # Specify this to skip the rebase over the edge branch. Used for lo
1010CROSS=$5 # '' for native, aarch64 for ARM cross
1111
1212prefix=/tmp/ADALIB_DIR
13- TARGET=${CROSS: +$CROSS -linux} # '' or aarch64-linux
13+ if [ $RUNNER_OS = Linux ] ; then
14+ TARGET=${CROSS: +$CROSS -linux} # '' or aarch64-linux
15+ else
16+ TARGET=${CROSS: +$CROSS -darwin} # '' or aarch64-darwin
17+ fi
18+
1419TARGET_OPTION=${TARGET: +--target=$TARGET } # '' or --target=aarch64-linux
1520
1621export CPATH=/usr/local/include
@@ -103,20 +108,37 @@ make LIBRARY_TYPE=static VERSION=$TAG all GPRBUILD_EXTRA=$TARGET_OPTION NODE_ARC
103108[ -z " $CROSS " ] && make LIBRARY_TYPE=static check
104109
105110
106- function fix_rpath ()
107- {
108- for R in ` otool -l $1 | grep -A2 LC_RPATH | awk ' / path /{ print $2 }' ` ; do
109- 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 "
110120 done
111- install_name_tool -change /usr/local/opt/gmp/lib/libgmp.10.dylib @rpath/libgmp.10.dylib $1
112- 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 "
113129}
114130
115131ALS_EXEC_DIR=integration/vscode/ada/$NODE_ARCH /$NODE_PLATFORM
116132
117133if [ $RUNNER_OS = macOS ]; then
118- cp -v -f /usr/local/opt/gmp/lib/libgmp.10.dylib $ALS_EXEC_DIR
119- fix_rpath $ALS_EXEC_DIR /ada_language_server
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"
120142fi
121143
122144if [ " $DEBUG " != " debug" ]; then
0 commit comments