mirror of
https://github.com/clangd/clangd.git
synced 2025-02-23 17:09:52 +00:00
There's pthread_cond_clockwait@GLIBC_2.30 introduced with new glibc, which isn't available in older versions. To prevent such breakages we are sticking to ubuntu-18 rather than moving to ubuntu-20. For a sample error see https://github.com/kadircet/clangd/runs/2011039246?check_suite_focus=true. Version label grabbed from https://github.com/actions/virtual-environments.
201 lines
7.7 KiB
YAML
201 lines
7.7 KiB
YAML
# Workflow to build binaries for a release.
|
|
# Triggered by release creation, which should include `llvm-project@<full-sha>`.
|
|
#
|
|
# Because the build takes more than an hour, our GITHUB_TOKEN credentials may
|
|
# expire. A token `secrets.RELEASE_TOKEN` must exist with public_repo scope.
|
|
name: Build release binaries
|
|
on:
|
|
release:
|
|
types: created
|
|
jobs:
|
|
prepare:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Find LLVM commit
|
|
run: |
|
|
grep -m 1 -o "llvm-project@[[:xdigit:]]\{40,\}" << EOF | cut -f 2 -d@ > commit
|
|
${{ github.event.release.body }}
|
|
EOF
|
|
- name: Mark as draft
|
|
run: >
|
|
curl --fail --show-error -XPATCH
|
|
"-HAuthorization: Bearer ${{ secrets.RELEASE_TOKEN }}"
|
|
"https://api.github.com/repos/${{ github.repository }}/releases/${{ github.event.release.id }}"
|
|
"-d" '{"draft": true}'
|
|
- name: Persist release info
|
|
uses: actions/upload-artifact@v1
|
|
with:
|
|
name: release
|
|
path: commit
|
|
# Build clangd using CMake/Ninja.
|
|
#
|
|
# This step is a template that runs on each OS, build config varies slightly.
|
|
# Uploading releases needs a per-job token that expires after an hour.
|
|
build:
|
|
name: Build ${{ matrix.config.name }}
|
|
needs: prepare
|
|
runs-on: ${{ matrix.config.os }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
config:
|
|
- name: windows
|
|
os: windows-latest
|
|
preinstall: choco install ninja nasm
|
|
vcvars: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat
|
|
cflags: /O2 /DNDEBUG
|
|
cmake: >-
|
|
"-DCMAKE_C_COMPILER=cl"
|
|
"-DCMAKE_CXX_COMPILER=cl"
|
|
"-DLLVM_ENABLE_ZLIB=OFF"
|
|
"-DLLVM_USE_CRT_RELEASE=MT"
|
|
grpc_cmake: >-
|
|
"-DgRPC_MSVC_STATIC_RUNTIME=ON"
|
|
binary_extension: ".exe"
|
|
- name: mac
|
|
os: macos-latest
|
|
preinstall: brew install ninja zlib p7zip
|
|
cflags: -O3 -gline-tables-only -DNDEBUG
|
|
env: MACOSX_DEPLOYMENT_TARGET=10.9
|
|
cmake: >-
|
|
"-DCMAKE_C_COMPILER=clang"
|
|
"-DCMAKE_CXX_COMPILER=clang++"
|
|
"-DLLVM_ENABLE_ZLIB=FORCE_ON"
|
|
- name: linux
|
|
os: ubuntu-18.04
|
|
preinstall: sudo apt-get install ninja-build libz-dev libc-ares-dev
|
|
cflags: -O3 -gline-tables-only -DNDEBUG -include $GITHUB_WORKSPACE/.github/workflows/lib_compat.h
|
|
cmake: >-
|
|
"-DCMAKE_C_COMPILER=clang"
|
|
"-DCMAKE_CXX_COMPILER=clang++"
|
|
"-DCMAKE_EXE_LINKER_FLAGS_RELEASE=-static-libgcc -Wl,--compress-debug-sections=zlib"
|
|
"-DLLVM_STATIC_LINK_CXX_STDLIB=ON"
|
|
"-DLLVM_ENABLE_ZLIB=FORCE_ON"
|
|
"-DCMAKE_PROJECT_INCLUDE=$GITHUB_WORKSPACE/.github/workflows/linux-static-deps.cmake"
|
|
# Using c-ares as a module prevents dynamic linking of unneeded
|
|
# libraries. All other gRPC dependencies can be built from sources.
|
|
grpc_cmake: >-
|
|
"-DgRPC_CARES_PROVIDER=package"
|
|
steps:
|
|
- name: Clone scripts
|
|
uses: actions/checkout@v2
|
|
with: { ref: master }
|
|
- name: Install tools
|
|
run: ${{ matrix.config.preinstall }}
|
|
# Visual Studio tools require a bunch of environment variables to be set.
|
|
# Run vcvars64.bat and re-export the current environment to the workflow.
|
|
# (It'd be nice to only export the variables that *changed*, oh well).
|
|
- name: Visual Studio environment
|
|
if: matrix.config.name == 'windows'
|
|
shell: powershell
|
|
run: |
|
|
cmd /c "`"${{ matrix.config.vcvars }}`">NUL && set" | Foreach-Object {
|
|
$name, $value = $_ -split '=', 2
|
|
if ($value) {
|
|
echo "$($name)=$($value)" >> $env:GITHUB_ENV
|
|
}
|
|
}
|
|
- name: Clone gRPC
|
|
uses: actions/checkout@v2
|
|
with:
|
|
repository: grpc/grpc
|
|
path: grpc
|
|
# We use the same version of gRPC for LLVM's clangd-ubuntu-tsan
|
|
# buildbot.
|
|
# https://github.com/llvm/llvm-zorg/blob/master/buildbot/google/docker/buildbot-clangd-ubuntu-clang/Dockerfile
|
|
ref: v1.33.2
|
|
submodules: recursive
|
|
- name: Build gRPC
|
|
run: >
|
|
mkdir $HOME/grpc-installation
|
|
|
|
mkdir grpc-build
|
|
|
|
cmake -G Ninja -S grpc -B grpc-build
|
|
"-DgRPC_INSTALL=ON"
|
|
"-DCMAKE_INSTALL_PREFIX=$HOME/grpc-installation"
|
|
"-DCMAKE_BUILD_TYPE=Release"
|
|
"-DCMAKE_C_FLAGS_RELEASE=${{ matrix.config.cflags }}"
|
|
"-DCMAKE_CXX_FLAGS_RELEASE=${{ matrix.config.cflags }}"
|
|
${{ matrix.config.grpc_cmake }} ${{ matrix.config.cmake }}
|
|
|
|
ninja -C grpc-build install
|
|
- name: Fetch target commit
|
|
uses: actions/download-artifact@v1
|
|
with: { name: release }
|
|
- name: Set target commit
|
|
run: |
|
|
echo "LLVM_COMMIT=$(cat release/commit)" >> $GITHUB_ENV
|
|
echo "CLANGD_DIR=clangd_${{ github.event.release.tag_name }}" >> $GITHUB_ENV
|
|
shell: bash
|
|
- name: Clone LLVM
|
|
uses: actions/checkout@v2
|
|
with:
|
|
repository: llvm/llvm-project
|
|
path: llvm-project
|
|
ref: ${{ env.LLVM_COMMIT }}
|
|
- name: CMake
|
|
run: >
|
|
mkdir ${{ env.CLANGD_DIR }}
|
|
|
|
cp llvm-project/llvm/LICENSE.TXT ${{ env.CLANGD_DIR }}
|
|
|
|
cmake -G Ninja -S llvm-project/llvm -B ${{ env.CLANGD_DIR }}
|
|
"-DLLVM_ENABLE_PROJECTS=clang;clang-tools-extra"
|
|
"-DLLVM_ENABLE_ASSERTIONS=OFF"
|
|
"-DLLVM_ENABLE_BACKTRACES=ON"
|
|
"-DLLVM_ENABLE_TERMINFO=OFF"
|
|
"-DCMAKE_BUILD_TYPE=Release"
|
|
"-DCLANG_PLUGIN_SUPPORT=OFF"
|
|
"-DLLVM_ENABLE_PLUGINS=OFF"
|
|
"-DCMAKE_C_FLAGS_RELEASE=${{ matrix.config.cflags }}"
|
|
"-DCMAKE_CXX_FLAGS_RELEASE=${{ matrix.config.cflags }}"
|
|
"-DCLANGD_ENABLE_REMOTE=ON"
|
|
"-DGRPC_INSTALL_PATH=$HOME/grpc-installation"
|
|
${{ matrix.config.cmake }}
|
|
- name: Ninja
|
|
run: ninja -C ${{ env.CLANGD_DIR }} clangd clangd-indexer clangd-index-server
|
|
- name: Archive clangd
|
|
run: >
|
|
7z a clangd.zip
|
|
${{ env.CLANGD_DIR }}/LICENSE.TXT
|
|
${{ env.CLANGD_DIR }}/bin/clangd${{ matrix.config.binary_extension }}
|
|
${{ env.CLANGD_DIR }}/lib/clang
|
|
- name: Archive indexing-tools
|
|
run: >
|
|
7z a indexing-tools.zip
|
|
${{ env.CLANGD_DIR }}/LICENSE.TXT
|
|
${{ env.CLANGD_DIR }}/bin/clangd-indexer${{ matrix.config.binary_extension }}
|
|
${{ env.CLANGD_DIR }}/bin/clangd-index-server${{ matrix.config.binary_extension }}
|
|
${{ env.CLANGD_DIR }}/lib/clang
|
|
- name: Upload clangd asset
|
|
uses: actions/upload-release-asset@v1.0.1
|
|
env: { GITHUB_TOKEN: "${{ secrets.RELEASE_TOKEN }}" }
|
|
with:
|
|
upload_url: ${{ github.event.release.upload_url }}
|
|
asset_name: clangd-${{ matrix.config.name }}-${{ github.event.release.tag_name }}.zip
|
|
asset_path: clangd.zip
|
|
asset_content_type: application/zip
|
|
- name: Upload indexing-tools asset
|
|
uses: actions/upload-release-asset@v1.0.1
|
|
env: { GITHUB_TOKEN: "${{ secrets.RELEASE_TOKEN }}" }
|
|
with:
|
|
upload_url: ${{ github.event.release.upload_url }}
|
|
asset_name: clangd-indexing-tools-${{ matrix.config.name }}-${{ github.event.release.tag_name }}.zip
|
|
asset_path: indexing-tools.zip
|
|
asset_content_type: application/zip
|
|
- name: Check binary compatibility
|
|
if: matrix.config.name == 'linux'
|
|
run: .github/workflows/lib_compat_test.py --lib=GLIBC_2.18 "$CLANGD_DIR/bin/clangd"
|
|
# Create the release, and upload the artifacts to it.
|
|
finalize:
|
|
runs-on: ubuntu-latest
|
|
needs: build
|
|
steps:
|
|
- name: Publish release
|
|
run: >
|
|
curl -XPATCH
|
|
"-HAuthorization: Bearer ${{ secrets.RELEASE_TOKEN }}"
|
|
"https://api.github.com/repos/${{ github.repository }}/releases/${{ github.event.release.id }}"
|
|
"-d" '{"draft": false}'
|