summaryrefslogtreecommitdiffstats
path: root/mkosi.clangd
blob: 7cd447c4ee923de1b96844e6beab3b38ae9ccfe0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/bash
# SPDX-License-Identifier: LGPL-2.1-or-later

if command -v flatpak-spawn >/dev/null; then
    SPAWN=(flatpak-spawn --host)
else
    SPAWN=()
fi

MKOSI_CONFIG="$("${SPAWN[@]}" --host mkosi --json summary | jq -r .Images[-1])"
DISTRIBUTION="$(jq -r .Distribution <<< "$MKOSI_CONFIG")"
RELEASE="$(jq -r .Release <<< "$MKOSI_CONFIG")"
ARCH="$(jq -r .Architecture <<< "$MKOSI_CONFIG")"

exec "${SPAWN[@]}" mkosi \
    --incremental=strict \
    --build-sources-ephemeral=no \
    --format=none \
    build \
    clangd \
    --compile-commands-dir=/work/build \
    --path-mappings="\
$(pwd)=/work/src,\
$(pwd)/build/mkosi.builddir/$DISTRIBUTION~$RELEASE~$ARCH/=/work/build,\
$(pwd)/build/mkosi.cache/$DISTRIBUTION~$RELEASE~$ARCH~build.cache/usr/include/=/usr/include" \
    "$@"