clang-tools, perhaps
This commit is contained in:
parent
da6724c979
commit
db371a5a61
3 changed files with 59 additions and 0 deletions
15
pkgs/clang-tools.nix
Normal file
15
pkgs/clang-tools.nix
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
with import <nixpkgs> {};
|
||||||
|
runCommand "clang-tools" {} ''
|
||||||
|
mkdir -p $out/bin
|
||||||
|
for file in ${clang-tools}/bin/*; do
|
||||||
|
if [ $(basename "$file") != "clangd" ]; then
|
||||||
|
ln -s "$file" $out/bin
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
sed \
|
||||||
|
-e "18iexport CPLUS_INCLUDE_PATH=${llvmPackages.libcxx}/include/c++/v1\\''${CPATH:+':'}\\''${CPATH}" \
|
||||||
|
-e '/CPLUS_INCLUDE_PATH/d' \
|
||||||
|
< ${clang-tools}/bin/clangd \
|
||||||
|
> $out/bin/clangd
|
||||||
|
''
|
24
pkgs/clang-tools/default.nix
Normal file
24
pkgs/clang-tools/default.nix
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
{ pkgs }:
|
||||||
|
with pkgs;
|
||||||
|
|
||||||
|
runCommand "clang-tools" {} ''
|
||||||
|
mkdir -p $out/bin
|
||||||
|
export libc_includes="${stdenv.lib.getDev stdenv.cc.libc}/include"
|
||||||
|
export libcpp_includes="${llvmPackages.libcxx}/include/c++/v1"
|
||||||
|
|
||||||
|
export clang=${llvmPackages.clang-unwrapped}
|
||||||
|
|
||||||
|
echo $clang
|
||||||
|
|
||||||
|
substituteAll ${./wrapper} $out/bin/clangd
|
||||||
|
chmod +x $out/bin/clangd
|
||||||
|
for tool in \
|
||||||
|
clang-apply-replacements \
|
||||||
|
clang-check \
|
||||||
|
clang-format \
|
||||||
|
clang-rename \
|
||||||
|
clang-tidy
|
||||||
|
do
|
||||||
|
ln -s $out/bin/clangd $out/bin/$tool
|
||||||
|
done
|
||||||
|
''
|
20
pkgs/clang-tools/wrapper
Normal file
20
pkgs/clang-tools/wrapper
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
buildcpath() {
|
||||||
|
local path
|
||||||
|
while (( $# )); do
|
||||||
|
case $1 in
|
||||||
|
-isystem)
|
||||||
|
shift
|
||||||
|
path=$path${path:+':'}$1
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
echo $path
|
||||||
|
}
|
||||||
|
|
||||||
|
export CPATH=${CPATH}${CPATH:+':'}$(buildcpath ${NIX_CFLAGS_COMPILE})
|
||||||
|
export CPATH=${CPATH}${CPATH:+':'}@libc_includes@
|
||||||
|
export CPLUS_INCLUDE_PATH=@libcpp_includes@${CPATH:+':'}${CPATH}
|
||||||
|
|
||||||
|
exec -a "$0" @clang@/bin/$(basename $0) "$@"
|
Loading…
Reference in a new issue