1 { rust-bindgen-unwrapped, zlib, bash, runCommand, runCommandCC }:
3 clang = rust-bindgen-unwrapped.clang;
4 self = runCommand "rust-bindgen-${rust-bindgen-unwrapped.version}"
8 unwrapped = rust-bindgen-unwrapped;
9 libclang = clang.cc.lib;
10 meta = rust-bindgen-unwrapped.meta // {
11 longDescription = rust-bindgen-unwrapped.meta.longDescription + ''
12 This version of bindgen is wrapped with the required compiler flags
13 required to find the c and c++ standard library, as well as the libraries
14 specified in the buildInputs of your derivation.
18 simple-c = runCommandCC "simple-c-bindgen-tests" { } ''
19 echo '#include <stdlib.h>' > a.c
20 ${self}/bin/bindgen a.c --allowlist-function atoi | tee output
24 simple-cpp = runCommandCC "simple-cpp-bindgen-tests" { } ''
25 echo '#include <cmath>' > a.cpp
26 ${self}/bin/bindgen a.cpp --allowlist-function erf -- -xc++ | tee output
30 with-lib = runCommandCC "zlib-bindgen-tests" { buildInputs = [ zlib ]; } ''
31 echo '#include <zlib.h>' > a.c
32 ${self}/bin/bindgen a.c --allowlist-function compress | tee output
38 # if you modify the logic to find the right clang flags, also modify rustPlatform.bindgenHook
41 export cincludes="$(< ${clang}/nix-support/cc-cflags) $(< ${clang}/nix-support/libc-cflags)"
42 export cxxincludes="$(< ${clang}/nix-support/libcxx-cxxflags)"
43 substituteAll ${./wrapper.sh} $out/bin/bindgen
44 chmod +x $out/bin/bindgen