2022-02-10 20:34:41 +00:00
|
|
|
{ rust-bindgen-unwrapped, zlib, bash, runCommand, runCommandCC }:
|
|
|
|
let
|
|
|
|
clang = rust-bindgen-unwrapped.clang;
|
|
|
|
self = runCommand "rust-bindgen-${rust-bindgen-unwrapped.version}"
|
|
|
|
{
|
|
|
|
#for substituteAll
|
|
|
|
inherit bash;
|
|
|
|
unwrapped = rust-bindgen-unwrapped;
|
|
|
|
libclang = clang.cc.lib;
|
|
|
|
meta = rust-bindgen-unwrapped.meta // {
|
|
|
|
longDescription = rust-bindgen-unwrapped.meta.longDescription + ''
|
|
|
|
This version of bindgen is wrapped with the required compiler flags
|
|
|
|
required to find the c and c++ standard libary, as well as the libraries
|
|
|
|
specified in the buildInputs of your derivation.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
passthru.tests = {
|
|
|
|
simple-c = runCommandCC "simple-c-bindgen-tests" { } ''
|
|
|
|
echo '#include <stdlib.h>' > a.c
|
2023-02-02 18:25:31 +00:00
|
|
|
${self}/bin/bindgen a.c --allowlist-function atoi | tee output
|
2022-02-10 20:34:41 +00:00
|
|
|
grep atoi output
|
|
|
|
touch $out
|
|
|
|
'';
|
|
|
|
simple-cpp = runCommandCC "simple-cpp-bindgen-tests" { } ''
|
|
|
|
echo '#include <cmath>' > a.cpp
|
2023-02-02 18:25:31 +00:00
|
|
|
${self}/bin/bindgen a.cpp --allowlist-function erf -- -xc++ | tee output
|
2022-02-10 20:34:41 +00:00
|
|
|
grep erf output
|
|
|
|
touch $out
|
|
|
|
'';
|
|
|
|
with-lib = runCommandCC "zlib-bindgen-tests" { buildInputs = [ zlib ]; } ''
|
|
|
|
echo '#include <zlib.h>' > a.c
|
2023-02-02 18:25:31 +00:00
|
|
|
${self}/bin/bindgen a.c --allowlist-function compress | tee output
|
2022-02-10 20:34:41 +00:00
|
|
|
grep compress output
|
|
|
|
touch $out
|
|
|
|
'';
|
|
|
|
};
|
2022-03-05 16:20:37 +00:00
|
|
|
}
|
|
|
|
# if you modify the logic to find the right clang flags, also modify rustPlatform.bindgenHook
|
|
|
|
''
|
2022-02-10 20:34:41 +00:00
|
|
|
mkdir -p $out/bin
|
|
|
|
export cincludes="$(< ${clang}/nix-support/cc-cflags) $(< ${clang}/nix-support/libc-cflags)"
|
|
|
|
export cxxincludes="$(< ${clang}/nix-support/libcxx-cxxflags)"
|
2020-04-24 23:36:52 +00:00
|
|
|
substituteAll ${./wrapper.sh} $out/bin/bindgen
|
|
|
|
chmod +x $out/bin/bindgen
|
|
|
|
'';
|
2022-02-10 20:34:41 +00:00
|
|
|
in
|
|
|
|
self
|