7869d16545
Also begin to start work on cross compilation, though that will have to
be finished later.
The patches are based on the first version of
https://reviews.llvm.org/D99484. It's very annoying to do the
back-porting but the review has uncovered nothing super major so I'm
fine sticking with what I've got.
Beyond making the outputs work, I also strove to re-sync the packages,
as they have been drifting pointlessly apart for some time.
----
Other misc notes, highly incomplete
- lvm-config-native and llvm-config are put in `dev` because they are
tools just for build time.
- Clang no longer has an lld dep. That was introduced in
db29857eb3
, but if clang needs help
finding lld when it is used we should just pass it flags / put in the
resource dir. Providing it at build time increases critical path
length for no good reason.
----
A note on `nativeCC`:
`stdenv` takes tools from the previous stage, so:
1. `pkgsBuildBuild`: `(?1, x, x)`
2. `pkgsBuildBuild.stdenv.cc`: `(?0, ?1, x)`
while:
1. `pkgsBuildBuild`: `(?1, x, x)`
2. `pkgsBuildBuild.targetPackages`: `(x, x, ?2)`
3. `pkgsBuildBuild.targetPackages.stdenv.cc`: `(?1, x, x)`
71 lines
1.8 KiB
Nix
71 lines
1.8 KiB
Nix
{ lib, fetchFromGitHub, rustPlatform, clang, llvmPackages, rustfmt, writeScriptBin
|
|
, runtimeShell
|
|
, bash
|
|
}:
|
|
|
|
rustPlatform.buildRustPackage rec {
|
|
pname = "rust-bindgen";
|
|
version = "0.57.0";
|
|
|
|
RUSTFLAGS = "--cap-lints warn"; # probably OK to remove after update
|
|
|
|
src = fetchFromGitHub {
|
|
owner = "rust-lang";
|
|
repo = pname;
|
|
rev = "v${version}";
|
|
sha256 = "sha256-0d8+Rkb4h1DoFUQ7u2/kPR/fUUz0YvI+hNT4iXL3mxY=";
|
|
};
|
|
|
|
cargoSha256 = "sha256-cUDOi3QwjEJaBXGSQZQ76gZ702QLNok8fr6U2q+tVao=";
|
|
|
|
#for substituteAll
|
|
libclang = llvmPackages.libclang.lib;
|
|
inherit bash;
|
|
|
|
buildInputs = [ libclang ];
|
|
|
|
propagatedBuildInputs = [ clang ]; # to populate NIX_CXXSTDLIB_COMPILE
|
|
|
|
configurePhase = ''
|
|
export LIBCLANG_PATH="${libclang.lib}/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" ''
|
|
#!${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 .
|
|
'';
|
|
|
|
meta = with lib; {
|
|
description = "Automatically generates Rust FFI bindings to C (and some C++) libraries";
|
|
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;
|
|
maintainers = with maintainers; [ johntitor ralith ];
|
|
};
|
|
}
|