Skip to content

Commit

Permalink
Merge remote branch 'origin/master' into edge
Browse files Browse the repository at this point in the history
  • Loading branch information
automatic-merge committed Dec 7, 2023
2 parents 2cd8443 + e3f696e commit 1b83ca3
Show file tree
Hide file tree
Showing 14 changed files with 1,176 additions and 474 deletions.
40 changes: 31 additions & 9 deletions .github/workflows/build-binaries.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ NO_REBASE=$4 # Specify this to skip the rebase over the edge branch. Used for lo
CROSS=$5 # '' for native, aarch64 for ARM cross

prefix=/tmp/ADALIB_DIR
TARGET=${CROSS:+$CROSS-linux} # '' or aarch64-linux
if [ $RUNNER_OS = Linux ] ; then
TARGET=${CROSS:+$CROSS-linux} # '' or aarch64-linux
else
TARGET=${CROSS:+$CROSS-darwin} # '' or aarch64-darwin
fi

TARGET_OPTION=${TARGET:+--target=$TARGET} # '' or --target=aarch64-linux

export CPATH=/usr/local/include
Expand Down Expand Up @@ -103,20 +108,37 @@ make LIBRARY_TYPE=static VERSION=$TAG all GPRBUILD_EXTRA=$TARGET_OPTION NODE_ARC
[ -z "$CROSS" ] && make LIBRARY_TYPE=static check


function fix_rpath ()
{
for R in `otool -l $1 |grep -A2 LC_RPATH |awk '/ path /{ print $2 }'`; do
install_name_tool -delete_rpath $R $1
# Find the path to libgmp as linked in the given executable
function get_gmp_full_path() {
otool -l "$1" | grep '^\s*name.*libgmp.10.dylib' | awk '/ name /{print $2 }'
}

function fix_rpath() {
# Remove all rpath entries
for R in $(otool -l "$1" | grep -A2 LC_RPATH | awk '/ path /{ print $2 }'); do
install_name_tool -delete_rpath "$R" "$1"
done
install_name_tool -change /usr/local/opt/gmp/lib/libgmp.10.dylib @rpath/libgmp.10.dylib $1
install_name_tool -add_rpath @executable_path $1
# Change reference to full path of libgmp into a reference to the rpath.
gmp_full_path=$(get_gmp_full_path "$1")
if [ -n "$gmp_full_path" ]; then
install_name_tool -change "$gmp_full_path" @rpath/libgmp.10.dylib "$1"
fi
# Add the executable directory to rpath so it can find shared libraries
# packaged alongside the executable.
install_name_tool -add_rpath @executable_path "$1"
}

ALS_EXEC_DIR=integration/vscode/ada/$NODE_ARCH/$NODE_PLATFORM

if [ $RUNNER_OS = macOS ]; then
cp -v -f /usr/local/opt/gmp/lib/libgmp.10.dylib $ALS_EXEC_DIR
fix_rpath $ALS_EXEC_DIR/ada_language_server
# Get full path of libgmp as linked in the ALS exec
gmp_full_path=$(get_gmp_full_path $ALS_EXEC_DIR/ada_language_server)
if [ -f "$gmp_full_path" ]; then
# Copy libgmp alongside the ALS exec
cp -v -f "$gmp_full_path" "$ALS_EXEC_DIR"
fi
# Fix rpath entries of the ALS exec so it can find libgmp alongside it
fix_rpath "$ALS_EXEC_DIR/ada_language_server"
fi

if [ "$DEBUG" != "debug" ]; then
Expand Down
25 changes: 17 additions & 8 deletions .github/workflows/build-binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ jobs:
exclude:
- os: windows-latest
cross: aarch64
- os: macos-11
cross: aarch64
runs-on: ${{ matrix.os }}
steps:
- name: Setup Python
Expand All @@ -37,18 +35,29 @@ jobs:
else
echo "TAG=$DEFAULT_TAG" >> $GITHUB_ENV
fi
- name: Unpack cross toolchain from AWS S3
if: ${{ matrix.cross != '' }}
- name: Install cross toolchain (Linux)
if: ${{ matrix.cross != '' && runner.os == 'Linux' }}
env:
AWS_ACCESS_KEY_ID: ${{secrets.GHA_CACHE_ACCESS_KEY_ID}}
AWS_SECRET_ACCESS_KEY: ${{secrets.GHA_CACHE_SECRET}}
AWS_DEFAULT_REGION: eu-west-1
run: |
aws s3 cp s3://adacore-gha-tray-eu-west-1/libadalang/${{ matrix.cross }}-${{ runner.os }}-gcc-13.2.tar.bz2 . --sse=AES256
aws s3 cp s3://adacore-gha-tray-eu-west-1/libadalang/${{ matrix.cross }}-${{ runner.os }}-gmp-6.2.1.tar.bz2 . --sse=AES256
sudo apt install -y libc6-dev-arm64-cross linux-libc-dev-arm64-cross binutils-aarch64-linux-gnu
sudo tar xavf ${{ matrix.cross }}-${{ runner.os }}-gcc-13.2.tar.bz2 -C /
sudo tar xavf ${{ matrix.cross }}-${{ runner.os }}-gmp-6.2.1.tar.bz2 -C /
aws s3 cp s3://adacore-gha-tray-eu-west-1/toolchain/${{ matrix.cross }}-${{ runner.os }}-gcc-13.2.tar.bz2 . --sse=AES256
aws s3 cp s3://adacore-gha-tray-eu-west-1/toolchain/${{ matrix.cross }}-${{ runner.os }}-gmp-6.2.1.tar.bz2 . --sse=AES256
sudo tar xjf ${{ matrix.cross }}-${{ runner.os }}-gcc-13.2.tar.bz2 -C /
sudo tar xjf ${{ matrix.cross }}-${{ runner.os }}-gmp-6.2.1.tar.bz2 -C /
- name: Install cross toolchain (MacOS)
if: ${{ matrix.cross != '' && runner.os != 'Linux' }}
env:
AWS_ACCESS_KEY_ID: ${{secrets.GHA_CACHE_ACCESS_KEY_ID}}
AWS_SECRET_ACCESS_KEY: ${{secrets.GHA_CACHE_SECRET}}
AWS_DEFAULT_REGION: eu-west-1
run: |
aws s3 cp s3://adacore-gha-tray-eu-west-1/toolchain/${{ matrix.cross }}-${{ runner.os }}-gcc-13.2.tar.bz2 . --sse=AES256
aws s3 cp s3://adacore-gha-tray-eu-west-1/toolchain/${{ matrix.cross }}-${{ runner.os }}-gmp-6.2.1.tar.bz2 . --sse=AES256
sudo tar xjf ${{ matrix.cross }}-${{ runner.os }}-gcc-13.2.tar.bz2 --strip-components=3 -C /usr/local
sudo tar xjf ${{ matrix.cross }}-${{ runner.os }}-gmp-6.2.1.tar.bz2 --strip-components=3 -C /usr/local
- name: Force Alire use preinstalled MSYS2
shell: bash
if: ${{ runner.os == 'Windows' }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pack-binaries.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ function make_change_log()
done
}

chmod -R -v +x als-*-$DEBUG als-Linux-${DEBUG}aarch64
chmod -R -v +x als-*-$DEBUG als-{Linux,macOS}-${DEBUG}aarch64

for X in Linux macOS Windows ; do
rsync -rva als-$X-$DEBUG/ integration/vscode/ada/
done

rsync -rva als-Linux-${DEBUG}aarch64/ integration/vscode/ada/
rsync -rva als-{Linux,macOS}-${DEBUG}aarch64/ integration/vscode/ada/

# VS Code is supported on arm, arm64 and x64 so we only consider those
# architectures
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ echo "upload_url=$upload_url"

chmod -R -v +x als-*-$DEBUG

for CROSS in "" "aarch64" ; do
for X in Linux macOS Windows ; do
FILE=als-$TAG-$X${DEBUG:+-debug}_amd64.zip
cd als-$X-$DEBUG
FILE=als-$TAG-$X${DEBUG:+-debug}_${CROSS:-amd64}.zip
cd als-$X-$DEBUG$CROSS
zip -9 -r ../$FILE .
cd ..

Expand All @@ -54,3 +55,4 @@ for X in Linux macOS Windows ; do
$upload_url?name=$FILE
rm -v -f $FILE
done
done
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,10 @@ It provides a full set of features including syntax highlighting, navigation, bu

### Getting Started

[Tutorial: Using Ada in VS Code](https://github.com/AdaCore/ada_language_server/wiki/Getting-Started).
Here are some links that will help you get familiar with the VS Code extension for Ada & SPARK:

* [Ada & SPARK for VS Code](integration/vscode/ada/README.md).
* [Tutorial: Using Ada in VS Code](https://github.com/AdaCore/ada_language_server/wiki/Getting-Started).

### Configuration

Expand Down
36 changes: 22 additions & 14 deletions integration/vscode/ada/src/clients.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,6 @@ export function createClient(
) {
let serverExecPath: string;

if (process.arch == 'arm64' && process.platform == 'darwin') {
// On arm64 darwin use the x64 darwin executable thanks to Apple Rosetta.
serverExecPath = context.asAbsolutePath(`x64/darwin/ada_language_server`);
} else {
serverExecPath = context.asAbsolutePath(
`${process.arch}/${process.platform}/ada_language_server`
);
}

if (process.platform == 'win32') {
// Add the extension for the file lookup further below
serverExecPath = `${serverExecPath}.exe`;
}

// If the ALS environment variable is specified, use it as the path of the
// server executable.
if (process.env.ALS) {
Expand All @@ -39,6 +25,28 @@ export function createClient(
);
}
} else {
serverExecPath = context.asAbsolutePath(
`${process.arch}/${process.platform}/ada_language_server`
);

if (process.arch == 'arm64' && process.platform == 'darwin') {
// On arm64 darwin check if the executable exists, and if not, try to
// fallback to the x64 darwin executable thanks to Apple Rosetta.
if (!existsSync(serverExecPath)) {
// The arm64 executable doesn't exist. Try x86.
const alternateExecPath = context.asAbsolutePath(
`x64/${process.platform}/ada_language_server`
);
if (existsSync(alternateExecPath)) {
// The x86 executable exists, use that instead.
serverExecPath = alternateExecPath;
}
}
} else if (process.platform == 'win32') {
// Add the extension for the file lookup further below
serverExecPath = `${serverExecPath}.exe`;
}

if (!existsSync(serverExecPath)) {
logErrorAndThrow(
`This installation of the Ada extension does not have the Ada ` +
Expand Down
Loading

0 comments on commit 1b83ca3

Please sign in to comment.