summary refs log tree commit diff
path: root/pkgs/development/tools/misc/cquery
diff options
context:
space:
mode:
authorTobias Mayer <tobim@fastmail.fm>2018-03-28 12:13:04 +0200
committerTobias Mayer <tobim@fastmail.fm>2018-03-28 12:13:04 +0200
commit04f3b76dcec21f2fcba6b1b0afbb3ed224165050 (patch)
tree2617f1888616f118f7e94b67b669d3e0f6dc133e /pkgs/development/tools/misc/cquery
parent4930caae80618ff9f7e752d40efb4acc809eb463 (diff)
downloadnixpkgs-04f3b76dcec21f2fcba6b1b0afbb3ed224165050.tar
nixpkgs-04f3b76dcec21f2fcba6b1b0afbb3ed224165050.tar.gz
nixpkgs-04f3b76dcec21f2fcba6b1b0afbb3ed224165050.tar.bz2
nixpkgs-04f3b76dcec21f2fcba6b1b0afbb3ed224165050.tar.lz
nixpkgs-04f3b76dcec21f2fcba6b1b0afbb3ed224165050.tar.xz
nixpkgs-04f3b76dcec21f2fcba6b1b0afbb3ed224165050.tar.zst
nixpkgs-04f3b76dcec21f2fcba6b1b0afbb3ed224165050.zip
cquery: extended wrapper
Use NIX_CFLAGS_COMPILE to find additional include paths.
Diffstat (limited to 'pkgs/development/tools/misc/cquery')
-rw-r--r--pkgs/development/tools/misc/cquery/default.nix15
-rw-r--r--pkgs/development/tools/misc/cquery/wrapper12
2 files changed, 23 insertions, 4 deletions
diff --git a/pkgs/development/tools/misc/cquery/default.nix b/pkgs/development/tools/misc/cquery/default.nix
index 31f6cbd8093..09220b2dc65 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 00000000000..f0bea41536d
--- /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[@]}" "$@"