clang-tools: Respect $CLANGD_FLAGS in wrapper

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.
This commit is contained in:
Eike Foede
2026-03-12 11:53:22 +01:00
parent aca4d95fce
commit b9ea8c2256
2 changed files with 17 additions and 21 deletions
@@ -50,7 +50,7 @@ stdenv.mkDerivation (finalAttrs: {
runHook postInstall
'';
passthru.tests.smokeOk =
passthru.tests =
let
src = writeText "main.cpp" ''
#include <iostream>
@@ -61,28 +61,24 @@ stdenv.mkDerivation (finalAttrs: {
'';
in
runCommand "clang-tools-test-smoke-ok" { } ''
${finalAttrs.finalPackage}/bin/clangd --check=${src}
touch $out
'';
passthru.tests.smokeErr =
let
src = writeText "main.cpp" ''
#include <iostream>
int main() {
std::cout << "Hi!";
}
{
smokeOk = runCommand "clang-tools-test-smoke-ok" { } ''
${finalAttrs.finalPackage}/bin/clangd --check=${src}
touch $out
'';
smokeErr = runCommand "clang-tools-test-smoke-err" { } ''
(${finalAttrs.finalPackage}/bin/clangd --query-driver='**' --check=${src} 2>&1 || true) \
| grep 'use of undeclared identifier'
in
runCommand "clang-tools-test-smoke-err" { } ''
(${finalAttrs.finalPackage}/bin/clangd --query-driver='**' --check=${src} 2>&1 || true) \
| grep 'use of undeclared identifier'
touch $out
'';
environmentErr = runCommand "clang-tools-test-environment-err" { } ''
(CLANGD_FLAGS="--query-driver='**'" ${finalAttrs.finalPackage}/bin/clangd --check=${src} 2>&1 || true) \
| grep 'use of undeclared identifier'
touch $out
'';
touch $out
'';
};
meta = llvm_meta // {
description = "Standalone command line tools for C++ development";
@@ -40,7 +40,7 @@ buildcpluspath() {
# don't want to infect user-specified toolchain and headers with our stuff.
extendcpath=true
for arg in "$@"; do
for arg in "$@" $CLANGD_FLAGS; do
if [[ "${arg}" == \-\-query\-driver* ]]; then
extendcpath=false
fi