Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 68 lines 2.0 kB view raw
1{ 2 lib, 3 stdenv, 4 fetchurl, 5 cmake, 6 llvmPackages, 7 python3, 8}: 9 10stdenv.mkDerivation rec { 11 pname = "include-what-you-use"; 12 # Make sure to bump `llvmPackages` in "pkgs/top-level/all-packages.nix" to the supported version: 13 # https://github.com/include-what-you-use/include-what-you-use?tab=readme-ov-file#clang-compatibility 14 version = "0.24"; 15 16 src = fetchurl { 17 url = "${meta.homepage}/downloads/${pname}-${version}.src.tar.gz"; 18 hash = "sha256-ojQhzv9gHT6iFej6kpK/qMo56xrCCY277fxs/mVUHBA="; 19 }; 20 21 postPatch = '' 22 patchShebangs . 23 ''; 24 25 nativeBuildInputs = with llvmPackages; [ 26 cmake 27 llvm.dev 28 llvm 29 python3 30 ]; 31 buildInputs = with llvmPackages; [ 32 libclang 33 clang-unwrapped 34 python3 35 ]; 36 37 clang = llvmPackages.clang; 38 39 cmakeFlags = [ "-DCMAKE_PREFIX_PATH=${llvmPackages.llvm.dev}" ]; 40 41 postInstall = '' 42 substituteInPlace $out/bin/iwyu_tool.py \ 43 --replace-fail "'include-what-you-use'" "'$out/bin/include-what-you-use'" 44 45 46 mv $out/bin/include-what-you-use $out/bin/.include-what-you-use-unwrapped 47 mv $out/bin/iwyu_tool.py $out/bin/.iwyu_tool.py-unwrapped 48 substituteAll ${./wrapper} $out/bin/include-what-you-use 49 ln -s $out/bin/include-what-you-use $out/bin/iwyu_tool.py 50 chmod +x $out/bin/include-what-you-use 51 patchShebangs $out/bin/include-what-you-use 52 ''; 53 54 meta = with lib; { 55 description = "Analyze #includes in C/C++ source files with clang"; 56 longDescription = '' 57 For every symbol (type, function variable, or macro) that you use in 58 foo.cc, either foo.cc or foo.h should #include a .h file that exports the 59 declaration of that symbol. The main goal of include-what-you-use is to 60 remove superfluous #includes, both by figuring out what #includes are not 61 actually needed for this file (for both .cc and .h files), and by 62 replacing #includes with forward-declares when possible. 63 ''; 64 homepage = "https://include-what-you-use.org"; 65 license = licenses.bsd3; 66 platforms = platforms.unix; 67 }; 68}