3
0
Fork 0
forked from mirrors/nixpkgs
nixpkgs/pkgs/development/tools/rust/bindgen/default.nix

71 lines
1.8 KiB
Nix
Raw Normal View History

{ lib, fetchFromGitHub, rustPlatform, clang, llvmPackages, rustfmt, writeScriptBin
, runtimeShell
, bash
}:
2016-11-23 17:09:29 +00:00
2017-03-22 02:00:11 +00:00
rustPlatform.buildRustPackage rec {
pname = "rust-bindgen";
2021-03-09 13:28:21 +00:00
version = "0.57.0";
2016-11-23 17:09:29 +00:00
RUSTFLAGS = "--cap-lints warn"; # probably OK to remove after update
2016-11-23 17:09:29 +00:00
src = fetchFromGitHub {
owner = "rust-lang";
repo = pname;
2018-03-26 00:08:04 +01:00
rev = "v${version}";
2021-03-09 13:28:21 +00:00
sha256 = "sha256-0d8+Rkb4h1DoFUQ7u2/kPR/fUUz0YvI+hNT4iXL3mxY=";
2016-11-23 17:09:29 +00:00
};
2021-03-09 13:28:21 +00:00
cargoSha256 = "sha256-cUDOi3QwjEJaBXGSQZQ76gZ702QLNok8fr6U2q+tVao=";
#for substituteAll
libclang = llvmPackages.libclang.lib;
inherit bash;
buildInputs = [ libclang ];
propagatedBuildInputs = [ clang ]; # to populate NIX_CXXSTDLIB_COMPILE
2016-11-23 17:09:29 +00:00
configurePhase = ''
export LIBCLANG_PATH="${libclang}/lib"
2016-11-23 17:09:29 +00:00
'';
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 .
'';
2016-11-23 17:09:29 +00:00
meta = with lib; {
description = "Automatically generates Rust FFI bindings to C (and some C++) libraries";
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.
'';
2020-03-12 06:10:16 +00:00
homepage = "https://github.com/rust-lang/rust-bindgen";
2016-11-23 17:09:29 +00:00
license = with licenses; [ bsd3 ];
platforms = platforms.unix;
2020-08-17 00:30:07 +01:00
maintainers = with maintainers; [ johntitor ralith ];
2016-11-23 17:09:29 +00:00
};
}