2019-02-26 11:45:54 +00:00
|
|
|
{ stdenv, fetchFromGitHub, rustPlatform, clang, llvmPackages, rustfmt, writeScriptBin,
|
|
|
|
runtimeShell }:
|
2016-11-23 17:09:29 +00:00
|
|
|
|
2017-03-22 02:00:11 +00:00
|
|
|
rustPlatform.buildRustPackage rec {
|
2019-04-24 17:28:40 +01:00
|
|
|
pname = "rust-bindgen";
|
2019-11-08 08:04:36 +00:00
|
|
|
version = "0.51.1";
|
2016-11-23 17:09:29 +00:00
|
|
|
|
2019-08-25 13:23:01 +01:00
|
|
|
RUSTFLAGS = "--cap-lints warn"; # probably OK to remove after update
|
|
|
|
|
2016-11-23 17:09:29 +00:00
|
|
|
src = fetchFromGitHub {
|
2019-04-24 17:28:40 +01:00
|
|
|
owner = "rust-lang";
|
|
|
|
repo = pname;
|
2018-03-26 00:08:04 +01:00
|
|
|
rev = "v${version}";
|
2019-11-08 08:04:36 +00:00
|
|
|
sha256 = "1agqfwac2av1b1c2bfzn0hw3178s4l94fadfx8a25dy1k87wmhfm";
|
2016-11-23 17:09:29 +00:00
|
|
|
};
|
|
|
|
|
2019-11-08 08:04:36 +00:00
|
|
|
cargoSha256 = "09m0ki1ald1csfzfvlc63r6k8m9ndxy9js6mfwqyfm4lj8kpbr3f";
|
2018-08-19 13:26:20 +01:00
|
|
|
|
|
|
|
libclang = llvmPackages.libclang.lib; #for substituteAll
|
|
|
|
|
|
|
|
buildInputs = [ libclang ];
|
|
|
|
|
|
|
|
propagatedBuildInputs = [ clang ]; # to populate NIX_CXXSTDLIB_COMPILE
|
|
|
|
|
2016-11-23 17:09:29 +00:00
|
|
|
configurePhase = ''
|
2018-08-19 13:26:20 +01:00
|
|
|
export LIBCLANG_PATH="${libclang}/lib"
|
2016-11-23 17:09:29 +00:00
|
|
|
'';
|
|
|
|
|
2017-05-05 06:17:56 +01:00
|
|
|
postInstall = ''
|
2018-08-19 13:26:20 +01:00
|
|
|
mv $out/bin/{bindgen,.bindgen-wrapped};
|
|
|
|
substituteAll ${./wrapper.sh} $out/bin/bindgen
|
|
|
|
chmod +x $out/bin/bindgen
|
2017-05-05 06:17:56 +01:00
|
|
|
'';
|
|
|
|
|
2018-11-23 16:52:25 +00:00
|
|
|
doCheck = true;
|
2018-08-19 13:26:20 +01:00
|
|
|
checkInputs =
|
|
|
|
let fakeRustup = writeScriptBin "rustup" ''
|
2019-02-26 11:45:54 +00:00
|
|
|
#!${runtimeShell}
|
2018-08-19 13:26:20 +01:00
|
|
|
shift
|
|
|
|
shift
|
|
|
|
exec "$@"
|
|
|
|
'';
|
|
|
|
in [
|
|
|
|
rustfmt
|
|
|
|
fakeRustup # the test suite insists in calling `rustup run nightly rustfmt`
|
|
|
|
clang
|
|
|
|
];
|
2018-11-23 16:52:25 +00:00
|
|
|
preCheck = ''
|
|
|
|
# for the ci folder, notably
|
|
|
|
patchShebangs .
|
|
|
|
'';
|
2016-11-23 17:09:29 +00:00
|
|
|
|
|
|
|
meta = with stdenv.lib; {
|
2017-07-28 11:33:03 +01:00
|
|
|
description = "C and C++ binding generator";
|
2018-08-19 13:26:20 +01: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.
|
|
|
|
'';
|
2019-04-24 17:28:40 +01:00
|
|
|
homepage = https://github.com/rust-lang/rust-bindgen;
|
2016-11-23 17:09:29 +00:00
|
|
|
license = with licenses; [ bsd3 ];
|
2019-06-24 21:05:28 +01:00
|
|
|
platforms = platforms.unix;
|
2016-11-23 17:09:29 +00:00
|
|
|
maintainers = [ maintainers.ralith ];
|
|
|
|
};
|
|
|
|
}
|