nixpkgs/pkgs/development/tools/analysis/sparse/default.nix
Emil Karlson 883874f513 sparse: 0.5.0 -> 0.6.3 and fixes
Added sqlite and gtk+3 that are now wanted by sparse.

Sparse expects to find system includes at /usr/include redirect this
to glibc.dev.

Sparse uses gcc -print-file-name= extensively to find gcc includes, due
to split in nixos this direct to gcc-lib, which does not include the headers
so redirect to GCC_BASE as defined in derivation. There might be a better way
to do this, but I did not immediately find one.

Define PREFIX as Make parameter, as old sed expression was broken.

Add a trivial test for cgcc.

Slightly irrelevant ref.
https://bugzilla.redhat.com/show_bug.cgi?id=1114755
2021-09-22 20:35:11 +03:00

37 lines
1.1 KiB
Nix

{ callPackage, fetchurl, lib, stdenv, gtk3, pkg-config, libxml2, llvm, perl, sqlite }:
let
GCC_BASE = "${stdenv.cc.cc}/lib/gcc/${stdenv.hostPlatform.uname.processor}-unknown-linux-gnu/${stdenv.cc.cc.version}";
in stdenv.mkDerivation rec {
pname = "sparse";
version = "0.6.3";
src = fetchurl {
url = "mirror://kernel/software/devel/sparse/dist/${pname}-${version}.tar.xz";
sha256 = "16d8c4dhipjzjf8z4z7pix1pdpqydz0v4r7i345f5s09hjnxpxnl";
};
preConfigure = ''
sed -i 's|"/usr/include"|"${stdenv.cc.libc.dev}/include"|' pre-process.c
sed -i 's|qx(\$ccom -print-file-name=)|"${GCC_BASE}"|' cgcc
makeFlags+=" PREFIX=$out"
'';
nativeBuildInputs = [ pkg-config ];
buildInputs = [ gtk3 libxml2 llvm perl sqlite ];
doCheck = true;
buildFlags = "GCC_BASE:=${GCC_BASE}";
passthru.tests = {
simple-execution = callPackage ./tests.nix { };
};
meta = with lib; {
description = "Semantic parser for C";
homepage = "https://git.kernel.org/cgit/devel/sparse/sparse.git/";
license = licenses.mit;
platforms = platforms.linux;
maintainers = with maintainers; [ thoughtpolice jkarlson ];
};
}