cquery: extended wrapper

Use NIX_CFLAGS_COMPILE to find additional include paths.
This commit is contained in:
Tobias Mayer 2018-03-28 12:13:04 +02:00
parent 4930caae80
commit 04f3b76dce
2 changed files with 23 additions and 4 deletions

View File

@ -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;
};
}

View File

@ -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[@]}" "$@"