nixpkgs/pkgs/development/tools/rust/bindgen/default.nix

67 lines
1.9 KiB
Nix
Raw Normal View History

{ stdenv, fetchFromGitHub, fetchpatch, rustPlatform, clang, llvmPackages, rustfmt, writeScriptBin }:
2016-11-23 17:09:29 +00:00
2017-03-22 02:00:11 +00:00
rustPlatform.buildRustPackage rec {
2016-11-23 17:09:29 +00:00
name = "rust-bindgen-${version}";
version = "0.37.0";
2016-11-23 17:09:29 +00:00
src = fetchFromGitHub {
2017-07-28 10:33:03 +00:00
owner = "rust-lang-nursery";
2016-11-23 17:09:29 +00:00
repo = "rust-bindgen";
2018-03-25 23:08:04 +00:00
rev = "v${version}";
sha256 = "0cqjr7qspjrfgqcp4nqxljmhhbqyijb2jpw3lajgjj48y6wrnw93";
2016-11-23 17:09:29 +00:00
};
cargoSha256 = "0b8v6c7q1abibzygrigldpd31lyd5ngmj4vq5d7zni96m20mm85w";
libclang = llvmPackages.libclang.lib; #for substituteAll
buildInputs = [ libclang ];
propagatedBuildInputs = [ clang ]; # to populate NIX_CXXSTDLIB_COMPILE
patches = [
# https://github.com/rust-lang-nursery/rust-bindgen/pull/1376
(fetchpatch {
url = https://github.com/rust-lang-nursery/rust-bindgen/commit/c8b5406f08af82a92bf8faf852c21ba941d9c176.patch;
sha256 = "16ibr2rplh0qz8rsq6gir45xlz5nasad4y8fprwhrb7ssv8wfkss";
})
];
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 = false; # half the tests fail because our rustfmt is not nightly enough
checkInputs =
let fakeRustup = writeScriptBin "rustup" ''
#!${stdenv.shell}
shift
shift
exec "$@"
'';
in [
rustfmt
fakeRustup # the test suite insists in calling `rustup run nightly rustfmt`
clang
];
2016-11-23 17:09:29 +00:00
meta = with stdenv.lib; {
2017-07-28 10:33:03 +00:00
description = "C and C++ binding generator";
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.
'';
2017-07-28 10:33:03 +00:00
homepage = https://github.com/rust-lang-nursery/rust-bindgen;
2016-11-23 17:09:29 +00:00
license = with licenses; [ bsd3 ];
maintainers = [ maintainers.ralith ];
};
}