From 4930caae80618ff9f7e752d40efb4acc809eb463 Mon Sep 17 00:00:00 2001 From: Tobias Mayer Date: Mon, 26 Mar 2018 00:02:06 +0200 Subject: [PATCH 1/2] cquery: init at 2018-03-25 --- maintainers/maintainer-list.nix | 5 ++ .../development/tools/misc/cquery/default.nix | 54 +++++++++++++++++++ pkgs/top-level/all-packages.nix | 4 ++ 3 files changed, 63 insertions(+) create mode 100644 pkgs/development/tools/misc/cquery/default.nix diff --git a/maintainers/maintainer-list.nix b/maintainers/maintainer-list.nix index 0524b26b8315..c6bc8dd023f9 100644 --- a/maintainers/maintainer-list.nix +++ b/maintainers/maintainer-list.nix @@ -3581,6 +3581,11 @@ github = "tnias"; name = "Philipp Bartsch"; }; + tobim = { + email = "nix@tobim.fastmail.fm"; + github = "tobimpub"; + name = "Tobias Mayer"; + }; tohl = { email = "tom@logand.com"; github = "tohl"; diff --git a/pkgs/development/tools/misc/cquery/default.nix b/pkgs/development/tools/misc/cquery/default.nix new file mode 100644 index 000000000000..31f6cbd8093b --- /dev/null +++ b/pkgs/development/tools/misc/cquery/default.nix @@ -0,0 +1,54 @@ +{ 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" + ]; + + postFixup = '' + # We need to tell cquery where to find the standard library headers. + + args="\"-isystem\", \"${if (stdenv.hostPlatform.libc == "glibc") then stdenv.cc.libc.dev else stdenv.cc.libc}/include\"" + args+=", \"-isystem\", \"${llvmPackages.libcxx}/include/c++/v1\"" + + wrapProgram $out/bin/cquery \ + --add-flags "'"'--init={"extraClangArguments": ['"''${args}"']}'"'" + ''; + + 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 ]; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index a4726f59b893..fe13fbf4053a 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -7655,6 +7655,10 @@ with pkgs; cppcheck = callPackage ../development/tools/analysis/cppcheck { }; + cquery = callPackage ../development/tools/misc/cquery { + llvmPackages = llvmPackages_6; + }; + creduce = callPackage ../development/tools/misc/creduce { inherit (perlPackages) perl ExporterLite FileWhich GetoptTabular RegexpCommon TermReadKey; From 04f3b76dcec21f2fcba6b1b0afbb3ed224165050 Mon Sep 17 00:00:00 2001 From: Tobias Mayer Date: Wed, 28 Mar 2018 12:13:04 +0200 Subject: [PATCH 2/2] cquery: extended wrapper Use NIX_CFLAGS_COMPILE to find additional include paths. --- pkgs/development/tools/misc/cquery/default.nix | 15 +++++++++++---- pkgs/development/tools/misc/cquery/wrapper | 12 ++++++++++++ 2 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 pkgs/development/tools/misc/cquery/wrapper diff --git a/pkgs/development/tools/misc/cquery/default.nix b/pkgs/development/tools/misc/cquery/default.nix index 31f6cbd8093b..09220b2dc651 100644 --- a/pkgs/development/tools/misc/cquery/default.nix +++ b/pkgs/development/tools/misc/cquery/default.nix @@ -27,14 +27,20 @@ stdenv.mkDerivation rec { "-DCLANG_CXX=ON" ]; + shell = stdenv.shell; postFixup = '' # We need to tell cquery where to find the standard library headers. - args="\"-isystem\", \"${if (stdenv.hostPlatform.libc == "glibc") then stdenv.cc.libc.dev else stdenv.cc.libc}/include\"" - args+=", \"-isystem\", \"${llvmPackages.libcxx}/include/c++/v1\"" + 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 - wrapProgram $out/bin/cquery \ - --add-flags "'"'--init={"extraClangArguments": ['"''${args}"']}'"'" + 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; @@ -50,5 +56,6 @@ stdenv.mkDerivation rec { 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[@]}" "$@"