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

64 lines
1.6 KiB
Nix
Raw Normal View History

{ 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 {
pname = "rust-bindgen";
version = "0.49.0";
2016-11-23 17:09:29 +00:00
src = fetchFromGitHub {
owner = "rust-lang";
repo = pname;
2018-03-25 23:08:04 +00:00
rev = "v${version}";
sha256 = "0i1lh8z0jpf8gcfqxig8kl6wzjrkwb3jkad5ghb6ppkdkpr94jq4";
2016-11-23 17:09:29 +00:00
};
cargoSha256 = "0v3slbah0s1w75s38x1akvshcxsi1s810yybd9faday7biwmdbmj";
libclang = llvmPackages.libclang.lib; #for substituteAll
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 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.
'';
homepage = https://github.com/rust-lang/rust-bindgen;
2016-11-23 17:09:29 +00:00
license = with licenses; [ bsd3 ];
maintainers = [ maintainers.ralith ];
};
}