summary refs log tree commit diff
path: root/pkgs/development
diff options
context:
space:
mode:
authorJörg Thalheim <Mic92@users.noreply.github.com>2018-03-29 20:50:35 +0100
committerGitHub <noreply@github.com>2018-03-29 20:50:35 +0100
commit683a73f093efe98daa58a3c7ac0ff3b9fd3166bc (patch)
treec59fc1cdcab80d6f7e85e3cf153473158ccd2da7 /pkgs/development
parent8dd73d8b7d0825292c5b93c0ef47e8eb0041b6a8 (diff)
parent04f3b76dcec21f2fcba6b1b0afbb3ed224165050 (diff)
downloadnixlib-683a73f093efe98daa58a3c7ac0ff3b9fd3166bc.tar
nixlib-683a73f093efe98daa58a3c7ac0ff3b9fd3166bc.tar.gz
nixlib-683a73f093efe98daa58a3c7ac0ff3b9fd3166bc.tar.bz2
nixlib-683a73f093efe98daa58a3c7ac0ff3b9fd3166bc.tar.lz
nixlib-683a73f093efe98daa58a3c7ac0ff3b9fd3166bc.tar.xz
nixlib-683a73f093efe98daa58a3c7ac0ff3b9fd3166bc.tar.zst
nixlib-683a73f093efe98daa58a3c7ac0ff3b9fd3166bc.zip
Merge pull request #37890 from tobimpub/cquery
cquery: init at 2018-03-25
Diffstat (limited to 'pkgs/development')
-rw-r--r--pkgs/development/tools/misc/cquery/default.nix61
-rw-r--r--pkgs/development/tools/misc/cquery/wrapper12
2 files changed, 73 insertions, 0 deletions
diff --git a/pkgs/development/tools/misc/cquery/default.nix b/pkgs/development/tools/misc/cquery/default.nix
new file mode 100644
index 000000000000..09220b2dc651
--- /dev/null
+++ b/pkgs/development/tools/misc/cquery/default.nix
@@ -0,0 +1,61 @@
+{ stdenv, fetchFromGitHub, makeWrapper
+, cmake, llvmPackages, ncurses }:
+
+let
+  src = fetchFromGitHub {
+    owner = "cquery-project";
+    repo = "cquery";
+    rev = "e45a9ebbb6d8bfaf8bf1a3135b6faa910afea37e";
+    sha256 = "049gkqbamq4r2nz9yjcwq369zrmwrikzbhfza2x2vndqzaavq5yg";
+    fetchSubmodules = true;
+  };
+
+  stdenv = llvmPackages.stdenv;
+
+in
+stdenv.mkDerivation rec {
+  name    = "cquery-${version}";
+  version = "2018-03-25";
+
+  inherit src;
+
+  nativeBuildInputs = [ cmake makeWrapper ];
+  buildInputs = with llvmPackages; [ clang clang-unwrapped llvm ncurses ];
+
+  cmakeFlags = [
+    "-DSYSTEM_CLANG=ON"
+    "-DCLANG_CXX=ON"
+  ];
+
+  shell = stdenv.shell;
+  postFixup = ''
+    # We need to tell cquery where to find the standard library headers.
+
+    standard_library_includes="\\\"-isystem\\\", \\\"${if (stdenv.hostPlatform.libc == "glibc") then stdenv.cc.libc.dev else stdenv.cc.libc}/include\\\""
+    standard_library_includes+=", \\\"-isystem\\\", \\\"${llvmPackages.libcxx}/include/c++/v1\\\""
+    export standard_library_includes
+
+    wrapped=".cquery-wrapped"
+    export wrapped
+
+    mv $out/bin/cquery $out/bin/$wrapped
+    substituteAll ${./wrapper} $out/bin/cquery
+    chmod --reference=$out/bin/$wrapped $out/bin/cquery
+  '';
+
+  doInstallCheck = true;
+  installCheckPhase = ''
+    pushd ${src}
+    $out/bin/cquery --ci --clang-sanity-check && \
+    $out/bin/cquery --ci --test-unit
+  '';
+
+  meta = with stdenv.lib; {
+    description = "A c/c++ language server powered by libclang";
+    homepage    = https://github.com/cquery-project/cquery;
+    license     = licenses.mit;
+    platforms   = platforms.linux ++ platforms.darwin;
+    maintainers = [ maintainers.tobim ];
+    priority    = 3;
+  };
+}
diff --git a/pkgs/development/tools/misc/cquery/wrapper b/pkgs/development/tools/misc/cquery/wrapper
new file mode 100644
index 000000000000..f0bea41536d0
--- /dev/null
+++ b/pkgs/development/tools/misc/cquery/wrapper
@@ -0,0 +1,12 @@
+#! @shell@ -e
+
+initString="--init={\"extraClangArguments\": [@standard_library_includes@"
+
+if [ "${NIX_CFLAGS_COMPILE}" != "" ]; then
+  read -a cflags_array <<< ${NIX_CFLAGS_COMPILE}
+  initString+=$(printf ', \"%s\"' "${cflags_array[@]}")
+fi
+
+initString+="]}"
+
+exec -a "$0" "@out@/bin/@wrapped@" "${initString}" "${extraFlagsArray[@]}" "$@"