2018-09-28 22:54:43 +02:00
|
|
|
{ stdenv, fetchFromGitHub, rustPlatform, clang, llvmPackages, rustfmt, writeScriptBin }:
|
2016-11-23 18:09:29 +01:00
|
|
|
|
2017-03-22 03:00:11 +01:00
|
|
|
rustPlatform.buildRustPackage rec {
|
2016-11-23 18:09:29 +01:00
|
|
|
name = "rust-bindgen-${version}";
|
2018-10-11 22:57:02 +02:00
|
|
|
version = "0.42.2";
|
2016-11-23 18:09:29 +01:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
2017-07-28 12:33:03 +02:00
|
|
|
owner = "rust-lang-nursery";
|
2016-11-23 18:09:29 +01:00
|
|
|
repo = "rust-bindgen";
|
2018-03-26 01:08:04 +02:00
|
|
|
rev = "v${version}";
|
2018-10-11 22:57:02 +02:00
|
|
|
sha256 = "10h0h7x8yf4dsyw2p2nas2jg5p3i29np0y3rfzrdq898d70gvq4j";
|
2016-11-23 18:09:29 +01:00
|
|
|
};
|
|
|
|
|
2018-10-11 22:57:02 +02:00
|
|
|
cargoSha256 = "01jvi86xgz0r7ia9agnfpms6b6x68lzwj6f085m0w659i94acgpi";
|
2018-08-19 14:26:20 +02:00
|
|
|
|
|
|
|
libclang = llvmPackages.libclang.lib; #for substituteAll
|
|
|
|
|
|
|
|
buildInputs = [ libclang ];
|
|
|
|
|
|
|
|
propagatedBuildInputs = [ clang ]; # to populate NIX_CXXSTDLIB_COMPILE
|
|
|
|
|
2016-11-23 18:09:29 +01:00
|
|
|
configurePhase = ''
|
2018-08-19 14:26:20 +02:00
|
|
|
export LIBCLANG_PATH="${libclang}/lib"
|
2016-11-23 18:09:29 +01:00
|
|
|
'';
|
|
|
|
|
2017-05-05 07:17:56 +02:00
|
|
|
postInstall = ''
|
2018-08-19 14:26:20 +02:00
|
|
|
mv $out/bin/{bindgen,.bindgen-wrapped};
|
|
|
|
substituteAll ${./wrapper.sh} $out/bin/bindgen
|
|
|
|
chmod +x $out/bin/bindgen
|
2017-05-05 07:17:56 +02:00
|
|
|
'';
|
|
|
|
|
2018-08-19 14:26:20 +02:00
|
|
|
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 18:09:29 +01:00
|
|
|
|
|
|
|
meta = with stdenv.lib; {
|
2017-07-28 12:33:03 +02:00
|
|
|
description = "C and C++ binding generator";
|
2018-08-19 14:26:20 +02: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.
|
|
|
|
'';
|
2017-07-28 12:33:03 +02:00
|
|
|
homepage = https://github.com/rust-lang-nursery/rust-bindgen;
|
2016-11-23 18:09:29 +01:00
|
|
|
license = with licenses; [ bsd3 ];
|
|
|
|
maintainers = [ maintainers.ralith ];
|
|
|
|
};
|
|
|
|
}
|