diff options
Diffstat (limited to 'nixpkgs/pkgs/build-support/rust/build-rust-crate/install-crate.nix')
-rw-r--r-- | nixpkgs/pkgs/build-support/rust/build-rust-crate/install-crate.nix | 45 |
1 files changed, 33 insertions, 12 deletions
diff --git a/nixpkgs/pkgs/build-support/rust/build-rust-crate/install-crate.nix b/nixpkgs/pkgs/build-support/rust/build-rust-crate/install-crate.nix index 3b0282621ea1..5ba7b69bedc5 100644 --- a/nixpkgs/pkgs/build-support/rust/build-rust-crate/install-crate.nix +++ b/nixpkgs/pkgs/build-support/rust/build-rust-crate/install-crate.nix @@ -1,24 +1,27 @@ -crateName: metadata: -'' +{ stdenv }: +crateName: metadata: buildTests: +if !buildTests then '' runHook preInstall - mkdir -p $out + # always create $out even if we do not have binaries. We are detecting binary targets during compilation, if those are missing there is no way to only have $lib + mkdir $out if [[ -s target/env ]]; then - cp target/env $out/env + mkdir -p $lib + cp target/env $lib/env fi if [[ -s target/link.final ]]; then - mkdir -p $out/lib - cp target/link.final $out/lib/link + mkdir -p $lib/lib + cp target/link.final $lib/lib/link fi if [[ "$(ls -A target/lib)" ]]; then - mkdir -p $out/lib - cp target/lib/* $out/lib #*/ - for lib in $out/lib/*.so $out/lib/*.dylib; do #*/ - ln -s $lib $(echo $lib | sed -e "s/-${metadata}//") + mkdir -p $lib/lib + cp target/lib/* $lib/lib #*/ + for library in $lib/lib/*.so $lib/lib/*.dylib; do #*/ + ln -s $library $(echo $library | sed -e "s/-${metadata}//") done fi if [[ "$(ls -A target/build)" ]]; then # */ - mkdir -p $out/lib - cp -r target/build/* $out/lib # */ + mkdir -p $lib/lib + cp -r target/build/* $lib/lib # */ fi if [[ -d target/bin ]]; then if [[ "$(ls -A target/bin)" ]]; then @@ -27,4 +30,22 @@ crateName: metadata: fi fi runHook postInstall +'' else +# for tests we just put them all in the output. No execution. +'' + runHook preInstall + + mkdir -p $out/tests + if [ -e target/bin ]; then + find target/bin/ -type f -executable -exec cp {} $out/tests \; + fi + if [ -e target/lib ]; then + find target/lib/ -type f \! -name '*.rlib' \ + -a \! -name '*${stdenv.hostPlatform.extensions.sharedLibrary}' \ + -a \! -name '*.d' \ + -executable \ + -print0 | xargs --no-run-if-empty --null install --target $out/tests; + fi + + runHook postInstall '' |