b9ea8c2256
clangd can take arguments also via environment variable CLANGD_FLAGS. This has to be respected in the wrapper, which checks whether a --query-driver was provided.
59 lines
1.5 KiB
Bash
Executable File
59 lines
1.5 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
buildcpath() {
|
|
local path after
|
|
while (( $# )); do
|
|
case $1 in
|
|
-isystem)
|
|
shift
|
|
path=$path${path:+':'}$1
|
|
;;
|
|
-idirafter)
|
|
shift
|
|
after=$after${after:+':'}$1
|
|
;;
|
|
esac
|
|
shift
|
|
done
|
|
echo $path${after:+':'}$after
|
|
}
|
|
|
|
buildcpluspath() {
|
|
local path after
|
|
while (( $# )); do
|
|
case $1 in
|
|
-isystem|-cxx-isystem)
|
|
shift
|
|
path=$path${path:+':'}$1
|
|
;;
|
|
-idirafter)
|
|
shift
|
|
after=$after${after:+':'}$1
|
|
;;
|
|
esac
|
|
shift
|
|
done
|
|
echo $path${after:+':'}$after
|
|
}
|
|
|
|
# When user passes `--query-driver`, avoid extending `CPATH` et al, since we
|
|
# don't want to infect user-specified toolchain and headers with our stuff.
|
|
extendcpath=true
|
|
|
|
for arg in "$@" $CLANGD_FLAGS; do
|
|
if [[ "${arg}" == \-\-query\-driver* ]]; then
|
|
extendcpath=false
|
|
fi
|
|
done
|
|
|
|
if [ "$extendcpath" = true ]; then
|
|
export C_INCLUDE_PATH=${CPATH}${CPATH:+':'}$(buildcpath ${NIX_CFLAGS_COMPILE} \
|
|
$(<@clang@/nix-support/libc-cflags))
|
|
|
|
export CPLUS_INCLUDE_PATH=${CPLUS_INCLUDE_PATH}${CPLUS_INCLUDE_PATH:+':'}$(buildcpluspath ${NIX_CFLAGS_COMPILE} \
|
|
$(<@clang@/nix-support/libcxx-cxxflags) \
|
|
$(<@clang@/nix-support/libc-cflags))
|
|
fi
|
|
|
|
@out@/bin/$(basename $0)-unwrapped "$@"
|