#!/bin/bash set -eux test -e .git || { echo >&2 "Re-run from the repository root directory." exit 1 } SRCDIR=${PWD} CLANGDIR=${PWD}.clangd declare -a CFGFLAGS=( CC='ccache clang' CXX='ccache clang++' --enable-targets=all --with-python=python3 --disable-{binutils,gas,gprof,gprofng,ld,libctf,nls,plugins,sim} --disable-werror ) mkdir -p "${CLANGDIR}" ( cd "${CLANGDIR}" "${SRCDIR}"/configure "${CFGFLAGS[@]}" bear -- make -j$(nproc --all) ) ln -fsv "${CLANGDIR}"/compile_commands.json "${SRCDIR}"