clang-tools: don't hardcode list of tools
Currently clang-tools' derivation uses a hardcoded list of names to distinguish between what's a compiler-like binary and what's a tool-like binary (so that e.g. clang-tidy is included in the derivation, but clang-13 - not). Because Clang's tools follow a common naming convention (clang-somethingsomething), I think it's easier if we just used a simple regular expression in place of the hardcoded list.
This commit is contained in:
parent
6036dcbdb9
commit
247763256c
|
@ -4,31 +4,44 @@ let
|
||||||
unwrapped = llvmPackages.clang-unwrapped;
|
unwrapped = llvmPackages.clang-unwrapped;
|
||||||
|
|
||||||
in stdenv.mkDerivation {
|
in stdenv.mkDerivation {
|
||||||
|
inherit unwrapped;
|
||||||
|
|
||||||
pname = "clang-tools";
|
pname = "clang-tools";
|
||||||
version = lib.getVersion unwrapped;
|
version = lib.getVersion unwrapped;
|
||||||
|
|
||||||
dontUnpack = true;
|
dontUnpack = true;
|
||||||
|
|
||||||
clang = llvmPackages.clang;
|
clang = llvmPackages.clang;
|
||||||
inherit unwrapped;
|
|
||||||
|
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
runHook preInstall
|
runHook preInstall
|
||||||
|
|
||||||
mkdir -p $out/bin
|
mkdir -p $out/bin
|
||||||
|
|
||||||
substituteAll ${./wrapper} $out/bin/clangd
|
for tool in $unwrapped/bin/clang-*; do
|
||||||
chmod +x $out/bin/clangd
|
tool=$(basename "$tool")
|
||||||
for tool in \
|
|
||||||
clang-apply-replacements \
|
# Compilers have their own derivation, no need to include them here:
|
||||||
clang-check \
|
if [[ $tool == "clang-cl" || $tool == "clang-cpp" ]]; then
|
||||||
clang-format \
|
continue
|
||||||
clang-rename \
|
fi
|
||||||
clang-tidy
|
|
||||||
do
|
# Clang's derivation produces a lot of binaries, but the tools we are
|
||||||
|
# interested in follow the `clang-something` naming convention - except
|
||||||
|
# for clang-$version (e.g. clang-13), which is the compiler again:
|
||||||
|
if [[ ! $tool =~ ^clang\-[a-zA-Z_\-]+$ ]]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
ln -s $out/bin/clangd $out/bin/$tool
|
ln -s $out/bin/clangd $out/bin/$tool
|
||||||
done
|
done
|
||||||
|
|
||||||
|
if [[ -z "$(ls -A $out/bin)" ]]; then
|
||||||
|
echo "Found no binaries - maybe their location or naming convention changed?"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
substituteAll ${./wrapper} $out/bin/clangd
|
||||||
|
chmod +x $out/bin/clangd
|
||||||
|
|
||||||
runHook postInstall
|
runHook postInstall
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue