clang-tools: teach about nix's include path (#73345)
clang-tools: teach about nix's include path
commitf3759a61cb2f41ac6bd0f43f7cf59806760f01d8
authorJörg Thalheim <Mic92@users.noreply.github.com>
dateSun 17 Nov 2019, 10:37 (7 years ago)
parent07f5d3ba10ef1a
pkgs/development/tools/clang-tools/default.nix+8−3
@@ -13,15 +13,20 @@ in stdenv.mkDerivation {
1313 runHook preInstall
1414
1515 mkdir -p $out/bin
16+ export libc_includes="${stdenv.lib.getDev stdenv.cc.libc}/include"
17+ export libcpp_includes="${llvmPackages.libcxx}/include/c++/v1"
18+
19+ export clang=${clang}
20+ substituteAll ${./wrapper} $out/bin/clangd
21+ chmod +x $out/bin/clangd
1622 for tool in \
1723 clang-apply-replacements \
1824 clang-check \
1925 clang-format \
2026 clang-rename \
21− clang-tidy \
22− clangd
27+ clang-tidy
2328 do
24− ln -s ${clang}/bin/$tool $out/bin/$tool
29+ ln -s $out/bin/clangd $out/bin/$tool
2530 done
2631
2732 runHook postInstall
pkgs/development/tools/clang-tools/wrappernew file+20
@@ -0,0 +1,20 @@
1+#!/bin/sh
2+
3+buildcpath() {
4+ local path
5+ while (( $# )); do
6+ case $1 in
7+ -isystem)
8+ shift
9+ path=$path${path':'}$1
10+ esac
11+ shift
12+ done
13+ echo $path
14+}
15+
16+export CPATH=${CPATH}${CPATH:+':'}$(buildcpath ${NIX_CFLAGS_COMPILE})
17+export CPATH=${CPATH}${CPATH:+':'}@libc_includes@
18+export CPLUS_INCLUDE_PATH=${CPATH}${CPATH:+':'}@libcpp_includes@
19+
20+exec -a "$0" @clang@/bin/$(basename $0) "$@"