11#! /bin/bash
2+
3+ # -x causes commands to be logged before invocation
4+ # -e causes the execution to terminate as soon as any command fails
25set -x -e
36DEBUG=$1 # Value is '' or 'debug'
47RUNNER_OS=$2 # ${{ runner.os }} is Linux, Windiws, maxOS
4447# Get libadalang binaries
4548mkdir -p $prefix
4649FILE=libadalang-$RUNNER_OS -$BRANCH ${DEBUG: +-dbg} -static.tar.gz
47- aws s3 cp s3://adacore-gha-tray-eu-west-1/libadalang/$FILE . --sse=AES256
48- tar xzf $FILE -C $prefix
49- rm -f -v $FILE
50+ # If the script is run locally for debugging, it is not always possible
51+ # to download libadalang from AWS S3. Instead, allow for the file to
52+ # be obtained otherwise and placed in the current directory for the script
53+ # to use. Thus, if the file is already there, we don't download it again
54+ # and we don't delete it after use.
55+ if [ ! -f " $FILE " ]; then
56+ aws s3 cp s3://adacore-gha-tray-eu-west-1/libadalang/$FILE . --sse=AES256
57+ tar xzf $FILE -C $prefix
58+ rm -f -v $FILE
59+ else
60+ # Untar the existing file and don't delete it
61+ tar xzf $FILE -C $prefix
62+ fi
5063
51- which python
52- pip install --user e3-testsuite
53- python -c " import sys;print('e3' in sys.modules)"
64+ which python3
65+ which pip3
66+ pip3 install --user e3-testsuite
67+ python3 -c " import sys;print('e3' in sys.modules)"
5468
5569if [ " $DEBUG " = " debug" ]; then
5670 export BUILD_MODE=dev
5771else
5872 export BUILD_MODE=prod
5973fi
6074
75+ # Log info about the compiler and library paths
76+ gnatls -v
77+
6178make -C subprojects/templates-parser setup prefix=$prefix \
6279 ENABLE_SHARED=no \
6380 ${DEBUG: +BUILD=debug} build-static install-static
@@ -74,21 +91,27 @@ function fix_rpath ()
7491}
7592
7693if [ $RUNNER_OS = macOS ]; then
77- cp -v /usr/local/opt/gmp/lib/libgmp.10.dylib integration/vscode/ada/darwin/
94+ cp -v -f /usr/local/opt/gmp/lib/libgmp.10.dylib integration/vscode/ada/darwin/
7895 fix_rpath integration/vscode/ada/darwin/ada_language_server
7996fi
8097
8198if [ " $DEBUG " != " debug" ]; then
82- if [ $RUNNER_OS = macOS ]; then
83- # Install binutils to have objcopy on Mac OS X
84- brew install binutils
85- export PATH=" /usr/local/opt/binutils/bin:$PATH "
86- fi
8799 ALS=` ls integration/vscode/ada/* /ada_language_server* `
88- objcopy --only-keep-debug ${ALS} ${ALS} .debug
89- objcopy --strip-all ${ALS}
90100 cd ` dirname $ALS `
91101 ALS=` basename ${ALS} `
92- objcopy --add-gnu-debuglink=${ALS} .debug ${ALS}
102+ if [ $RUNNER_OS = macOS ]; then
103+ # On macOS using objcopy from binutils to strip debug symbols to a
104+ # separate file doesn't work. Namely, the last step `objcopy
105+ # --add-gnu-debuglink` yields an executable that crashes at startup.
106+ #
107+ # Instead we use dsymutil and strip which are commands provided by the
108+ # system (or by XCode).
109+ dsymutil " $ALS "
110+ strip " $ALS "
111+ else
112+ objcopy --only-keep-debug ${ALS} ${ALS} .debug
113+ objcopy --strip-all ${ALS}
114+ objcopy --add-gnu-debuglink=${ALS} .debug ${ALS}
115+ fi
93116 cd -
94117fi
0 commit comments