2021-08-18 13:19:15 +00:00
|
|
|
{ lib, fetchFromGitHub, rustPlatform, clang, llvmPackages_latest, rustfmt, writeTextFile
|
2021-02-05 17:12:51 +00:00
|
|
|
, runtimeShell
|
|
|
|
, bash
|
|
|
|
}:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
rustPlatform.buildRustPackage rec {
|
|
|
|
pname = "rust-bindgen";
|
2021-09-18 10:52:07 +00:00
|
|
|
version = "0.59.1";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
RUSTFLAGS = "--cap-lints warn"; # probably OK to remove after update
|
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "rust-lang";
|
|
|
|
repo = pname;
|
|
|
|
rev = "v${version}";
|
2021-09-18 10:52:07 +00:00
|
|
|
sha256 = "sha256-nCww9sr6kF7nCQeIGtOXddxD3dR/SJ0rqAc+RlZnUkQ=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2021-09-18 10:52:07 +00:00
|
|
|
cargoSha256 = "sha256-3EXYC/mwzVxo/ginvF1WFtS7ABE/ybyuKb58uMqfTDs=";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
#for substituteAll
|
2021-06-28 23:13:55 +00:00
|
|
|
libclang = llvmPackages_latest.libclang.lib;
|
2021-02-05 17:12:51 +00:00
|
|
|
inherit bash;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
buildInputs = [ libclang ];
|
|
|
|
|
|
|
|
propagatedBuildInputs = [ clang ]; # to populate NIX_CXXSTDLIB_COMPILE
|
|
|
|
|
|
|
|
configurePhase = ''
|
2021-05-20 23:08:51 +00:00
|
|
|
export LIBCLANG_PATH="${libclang.lib}/lib"
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
postInstall = ''
|
|
|
|
mv $out/bin/{bindgen,.bindgen-wrapped};
|
|
|
|
substituteAll ${./wrapper.sh} $out/bin/bindgen
|
|
|
|
chmod +x $out/bin/bindgen
|
|
|
|
'';
|
|
|
|
|
|
|
|
doCheck = true;
|
|
|
|
checkInputs =
|
2021-08-18 13:19:15 +00:00
|
|
|
let fakeRustup = writeTextFile {
|
|
|
|
name = "fake-rustup";
|
|
|
|
executable = true;
|
|
|
|
destination = "/bin/rustup";
|
|
|
|
text = ''
|
|
|
|
#!${runtimeShell}
|
|
|
|
shift
|
|
|
|
shift
|
|
|
|
exec "$@"
|
|
|
|
'';
|
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
in [
|
|
|
|
rustfmt
|
|
|
|
fakeRustup # the test suite insists in calling `rustup run nightly rustfmt`
|
|
|
|
clang
|
|
|
|
];
|
|
|
|
preCheck = ''
|
|
|
|
# for the ci folder, notably
|
|
|
|
patchShebangs .
|
|
|
|
'';
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2020-10-19 00:13:06 +00:00
|
|
|
description = "Automatically generates Rust FFI bindings to C (and some C++) libraries";
|
2020-04-24 23:36:52 +00: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.
|
|
|
|
'';
|
|
|
|
homepage = "https://github.com/rust-lang/rust-bindgen";
|
|
|
|
license = with licenses; [ bsd3 ];
|
|
|
|
platforms = platforms.unix;
|
2020-08-20 17:08:02 +00:00
|
|
|
maintainers = with maintainers; [ johntitor ralith ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|