nixpkgs/pkgs/build-support/rust
Andreas Rammhold 0c50140da5 buildRustCrate: add heuristic to picking the right source files
Cargo has a few odd (old) ways of picking source files if the `bin.path`
attribute isn't given in the Cargo.toml. This commit adds support for
some of those. The previous behaviour always defaulted to `src/main.rs`
which was not always the right choice.

Since there is  look-ahead into the unpacked sources before running the
actual builder the path selection logic has to be embedded within the
build script.

`buildRustCrate` currently supports two ways of running building
binaries when processing a crate:

- Explicit definition of all the binaries (& optionally the paths to
their respective `main.rs`) and,
- if not binary was explictly configured all files matching the patterns
  `src/main.rs`, `src/bin/*.rs`.

When the explicit list is given without path information paths are now
being picked from a list of candidates. The first match wins. The order
is the same as within the cargo compatibility code.

If the crate does not provide any libraries the path `src/{bin_name}.rs`
is also considered.

All underscores within the binary names are translated into dashes (`-`)
before the lookups are made. This seems to be a common convention.
2018-09-13 20:28:39 +02:00
..
build-rust-crate buildRustCrate: add heuristic to picking the right source files 2018-09-13 20:28:39 +02:00
cargo-vendor treewide: Remove usage of remaining redundant platform compatability stuff 2018-08-30 17:20:32 -04:00
patch-registry-deps buildRustPackage: don't hardcode /nix/store, use $NIX_STORE 2016-01-12 13:45:11 -05:00
build-rust-crate.nix buildRustCrate: add heuristic to picking the right source files 2018-09-13 20:28:39 +02:00
carnix.nix treewide: Remove usage of remaining redundant platform compatability stuff 2018-08-30 17:20:32 -04:00
default-crate-overrides.nix carnix overrides: add gmp to rink-rs buildInputs & correct crateBin 2018-08-15 13:20:04 +08:00
default.nix buildRustPackage: allow patches to fix Cargo.lock 2018-08-13 22:07:58 +09:00
fetchcargo.nix buildRustPackage: allow patches to fix Cargo.lock 2018-08-13 22:07:58 +09:00
fetchcrate.nix add fetchCrate function to fetch rust crates 2017-12-12 04:58:45 -06:00