include-what-you-use: 0.19 -> 0.21

also add a compiler-wrapper similar to clang-tools so it can find dependencies in nix-shell environments.
This commit is contained in:
Jörg Thalheim 2023-12-11 21:05:46 +01:00 committed by Jörg Thalheim
parent 6f6435de1c
commit f37be82593
3 changed files with 39 additions and 3 deletions

View file

@ -3,11 +3,11 @@
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
pname = "include-what-you-use"; pname = "include-what-you-use";
# Also bump llvmPackages in all-packages.nix to the supported version! # Also bump llvmPackages in all-packages.nix to the supported version!
version = "0.19"; version = "0.21";
src = fetchurl { src = fetchurl {
url = "${meta.homepage}/downloads/${pname}-${version}.src.tar.gz"; url = "${meta.homepage}/downloads/${pname}-${version}.src.tar.gz";
hash = "sha256-KxAVe2DqCK3AjjiWtJIcc/yt1exOtlKymjQSnVAeXuA="; hash = "sha256-ajUZGf+JvafJXIlUcmAYaNs9qrlqlYs44DYokNWHYLY=";
}; };
postPatch = '' postPatch = ''
@ -17,11 +17,21 @@ stdenv.mkDerivation rec {
nativeBuildInputs = with llvmPackages; [ cmake llvm.dev llvm python3 ]; nativeBuildInputs = with llvmPackages; [ cmake llvm.dev llvm python3 ];
buildInputs = with llvmPackages; [ libclang clang-unwrapped python3 ]; buildInputs = with llvmPackages; [ libclang clang-unwrapped python3 ];
clang = llvmPackages.clang;
cmakeFlags = [ "-DCMAKE_PREFIX_PATH=${llvmPackages.llvm.dev}" ]; cmakeFlags = [ "-DCMAKE_PREFIX_PATH=${llvmPackages.llvm.dev}" ];
postInstall = '' postInstall = ''
substituteInPlace $out/bin/iwyu_tool.py \ substituteInPlace $out/bin/iwyu_tool.py \
--replace "'include-what-you-use'" "'$out/bin/include-what-you-use'" --replace "'include-what-you-use'" "'$out/bin/include-what-you-use'"
mv $out/bin/include-what-you-use $out/bin/.include-what-you-use-unwrapped
mv $out/bin/iwyu_tool.py $out/bin/.iwyu_tool.py-unwrapped
substituteAll ${./wrapper} $out/bin/include-what-you-use
ln -s $out/bin/include-what-you-use $out/bin/iwyu_tool.py
chmod +x $out/bin/include-what-you-use
patchShebangs $out/bin/include-what-you-use
''; '';
meta = with lib; { meta = with lib; {

View file

@ -0,0 +1,26 @@
#!/bin/sh
buildcpath() {
local path after
while (( $# )); do
case $1 in
-isystem)
shift
path=$path${path:+':'}$1
;;
-idirafter)
shift
after=$after${after:+':'}$1
;;
esac
shift
done
echo $path${after:+':'}$after
}
export CPATH=${CPATH}${CPATH:+':'}$(buildcpath ${NIX_CFLAGS_COMPILE} \
$(<@clang@/nix-support/libc-cflags)):@clang@/resource-root/include
export CPLUS_INCLUDE_PATH=${CPLUS_INCLUDE_PATH}${CPLUS_INCLUDE_PATH:+':'}$(buildcpath ${NIX_CFLAGS_COMPILE} \
$(<@clang@/nix-support/libcxx-cxxflags) \
$(<@clang@/nix-support/libc-cflags)):@clang@/resource-root/include
exec -a "$0" @out@/bin/.$(basename $0)-unwrapped "$@"

View file

@ -19390,7 +19390,7 @@ with pkgs;
img = callPackage ../development/tools/img { }; img = callPackage ../development/tools/img { };
include-what-you-use = callPackage ../development/tools/analysis/include-what-you-use { include-what-you-use = callPackage ../development/tools/analysis/include-what-you-use {
llvmPackages = llvmPackages_15; llvmPackages = llvmPackages_17;
}; };
indent = callPackage ../development/tools/misc/indent { }; indent = callPackage ../development/tools/misc/indent { };