-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/bin/bash | ||
# SPDX-License-Identifier: LGPL-2.1-or-later | ||
# Verbatim copy of mkosi.clangd from systemd repo tag v257-rc2 | ||
|
||
set -eu | ||
|
||
if [ -z "${MKOSI_CONFIG-}" ]; then | ||
exec mkosi \ | ||
--incremental=strict \ | ||
--build-sources-ephemeral=no \ | ||
--format=none \ | ||
--build-script= \ | ||
--build-script="$(realpath "$0")" \ | ||
build | ||
fi | ||
|
||
DISTRIBUTION="$(jq -r .Distribution "$MKOSI_CONFIG")" | ||
RELEASE="$(jq -r .Release "$MKOSI_CONFIG")" | ||
ARCH="$(jq -r .Architecture "$MKOSI_CONFIG")" | ||
|
||
BUILD_DIRECTORY="$(jq -r .BuildDirectory "$MKOSI_CONFIG")" | ||
CACHE_DIRECTORY="$(jq -r .CacheDirectory "$MKOSI_CONFIG")" | ||
# This neglects build sources which have an absolute path as a target | ||
# but that would make the jq filter more complex | ||
# and can still added later if someone has a need for this. | ||
BUILD_SOURCE_MAPPINGS="$(jq -r '[ | ||
.BuildSources[] | ||
| .Source + "/='"$SRCDIR"'/" + .Target | ||
] | join(",")' "$MKOSI_CONFIG")" | ||
|
||
exec clangd \ | ||
--compile-commands-dir="$BUILDDIR" \ | ||
--path-mappings="\ | ||
$BUILD_SOURCE_MAPPINGS,\ | ||
$BUILD_DIRECTORY/=$BUILDDIR/,\ | ||
$CACHE_DIRECTORY/$DISTRIBUTION~$RELEASE~$ARCH~build.cache/usr/include/=$BUILDROOT/usr/include/" \ | ||
"$@" |