2020-04-24 23:36:52 +00:00
|
|
|
{ stdenv, fetchFromGitHub, rustPlatform, clang, llvmPackages, rustfmt, writeScriptBin,
|
|
|
|
runtimeShell }:
|
|
|
|
|
|
|
|
rustPlatform.buildRustPackage rec {
|
|
|
|
pname = "rust-bindgen";
|
2020-08-20 17:08:02 +00:00
|
|
|
version = "0.54.1";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
RUSTFLAGS = "--cap-lints warn"; # probably OK to remove after update
|
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "rust-lang";
|
|
|
|
repo = pname;
|
|
|
|
rev = "v${version}";
|
2020-08-20 17:08:02 +00:00
|
|
|
sha256 = "116np72w6agsi94xa1bdn6h7sa9gd522h358zlixk9xrhrx7yfn3";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2020-08-20 17:08:02 +00:00
|
|
|
cargoSha256 = "12a7bd2579jcnkss073v5w5w68fxwvhq6c6ndjy8vp78wg83qich";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
libclang = llvmPackages.libclang.lib; #for substituteAll
|
|
|
|
|
|
|
|
buildInputs = [ libclang ];
|
|
|
|
|
|
|
|
propagatedBuildInputs = [ clang ]; # to populate NIX_CXXSTDLIB_COMPILE
|
|
|
|
|
|
|
|
configurePhase = ''
|
|
|
|
export LIBCLANG_PATH="${libclang}/lib"
|
|
|
|
'';
|
|
|
|
|
|
|
|
postInstall = ''
|
|
|
|
mv $out/bin/{bindgen,.bindgen-wrapped};
|
|
|
|
substituteAll ${./wrapper.sh} $out/bin/bindgen
|
|
|
|
chmod +x $out/bin/bindgen
|
|
|
|
'';
|
|
|
|
|
|
|
|
doCheck = true;
|
|
|
|
checkInputs =
|
|
|
|
let fakeRustup = writeScriptBin "rustup" ''
|
|
|
|
#!${runtimeShell}
|
|
|
|
shift
|
|
|
|
shift
|
|
|
|
exec "$@"
|
|
|
|
'';
|
|
|
|
in [
|
|
|
|
rustfmt
|
|
|
|
fakeRustup # the test suite insists in calling `rustup run nightly rustfmt`
|
|
|
|
clang
|
|
|
|
];
|
|
|
|
preCheck = ''
|
|
|
|
# for the ci folder, notably
|
|
|
|
patchShebangs .
|
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with stdenv.lib; {
|
2020-08-20 17:08:02 +00:00
|
|
|
description = "Automatically generates Rust FFI bindings to C (and some C++) libraries.";
|
2020-04-24 23:36:52 +00:00
|
|
|
longDescription = ''
|
|
|
|
Bindgen takes a c or c++ header file and turns them into
|
|
|
|
rust ffi declarations.
|
|
|
|
As with most compiler related software, this will only work
|
|
|
|
inside a nix-shell with the required libraries as buildInputs.
|
|
|
|
'';
|
|
|
|
homepage = "https://github.com/rust-lang/rust-bindgen";
|
|
|
|
license = with licenses; [ bsd3 ];
|
|
|
|
platforms = platforms.unix;
|
2020-08-20 17:08:02 +00:00
|
|
|
maintainers = with maintainers; [ johntitor ralith ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|