c73f75dc5e
now that we have a recent enough rustfmt
62 lines
1.6 KiB
Nix
62 lines
1.6 KiB
Nix
{ stdenv, fetchFromGitHub, rustPlatform, clang, llvmPackages, rustfmt, writeScriptBin }:
|
|
|
|
rustPlatform.buildRustPackage rec {
|
|
name = "rust-bindgen-${version}";
|
|
version = "0.42.2";
|
|
|
|
src = fetchFromGitHub {
|
|
owner = "rust-lang-nursery";
|
|
repo = "rust-bindgen";
|
|
rev = "v${version}";
|
|
sha256 = "10h0h7x8yf4dsyw2p2nas2jg5p3i29np0y3rfzrdq898d70gvq4j";
|
|
};
|
|
|
|
cargoSha256 = "01jvi86xgz0r7ia9agnfpms6b6x68lzwj6f085m0w659i94acgpi";
|
|
|
|
libclang = llvmPackages.libclang.lib; #for substituteAll
|
|
|
|
buildInputs = [ libclang ];
|
|
|
|
propagatedBuildInputs = [ clang ]; # to populate NIX_CXXSTDLIB_COMPILE
|
|
|
|
configurePhase = ''
|
|
export LIBCLANG_PATH="${libclang}/lib"
|
|
'';
|
|
|
|
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" ''
|
|
#!${stdenv.shell}
|
|
shift
|
|
shift
|
|
exec "$@"
|
|
'';
|
|
in [
|
|
rustfmt
|
|
fakeRustup # the test suite insists in calling `rustup run nightly rustfmt`
|
|
clang
|
|
];
|
|
preCheck = ''
|
|
# for the ci folder, notably
|
|
patchShebangs .
|
|
'';
|
|
|
|
meta = with stdenv.lib; {
|
|
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-nursery/rust-bindgen;
|
|
license = with licenses; [ bsd3 ];
|
|
maintainers = [ maintainers.ralith ];
|
|
};
|
|
}
|