1{ fetchFromGitHub, makeWrapper
2, cmake, llvmPackages, ncurses
3, runtimeShell }:
4
5let
6 src = fetchFromGitHub {
7 owner = "cquery-project";
8 repo = "cquery";
9 rev = "a95a6503d68a85baa25465ce147b7fc20f4a552e";
10 sha256 = "0rxbdln7dqkdw4q8rhclssgwypq16g9flkwmaabsr8knckbszxrx";
11 fetchSubmodules = true;
12 };
13
14 stdenv = llvmPackages.stdenv;
15
16in
17stdenv.mkDerivation rec {
18 name = "cquery-${version}";
19 version = "2018-10-14";
20
21 inherit src;
22
23 nativeBuildInputs = [ cmake makeWrapper ];
24 buildInputs = with llvmPackages; [ clang clang-unwrapped llvm ncurses ];
25
26 cmakeFlags = [
27 "-DSYSTEM_CLANG=ON"
28 "-DCLANG_CXX=ON"
29 "-DCMAKE_OSX_DEPLOYMENT_TARGET=10.12"
30 ];
31
32 shell = runtimeShell;
33 postFixup = ''
34 # We need to tell cquery where to find the standard library headers.
35
36 standard_library_includes="\\\"-isystem\\\", \\\"${stdenv.lib.getDev stdenv.cc.libc}/include\\\""
37 standard_library_includes+=", \\\"-isystem\\\", \\\"${llvmPackages.libcxx}/include/c++/v1\\\""
38 export standard_library_includes
39
40 wrapped=".cquery-wrapped"
41 export wrapped
42
43 mv $out/bin/cquery $out/bin/$wrapped
44 substituteAll ${./wrapper} $out/bin/cquery
45 chmod --reference=$out/bin/$wrapped $out/bin/cquery
46 '';
47
48 doInstallCheck = true;
49 installCheckPhase = ''
50 pushd ${src}
51 $out/bin/cquery --ci --test-unit
52
53 # The integration tests have to be disabled because cquery ignores `--init`
54 # if they are invoked, which means it won't find the system includes.
55 #$out/bin/cquery --ci --test-index
56 '';
57
58 meta = with stdenv.lib; {
59 description = "A c/c++ language server powered by libclang";
60 homepage = https://github.com/cquery-project/cquery;
61 license = licenses.mit;
62 platforms = platforms.linux ++ platforms.darwin;
63 maintainers = [ maintainers.tobim ];
64 };
65}