3
0
Fork 0
forked from mirrors/nixpkgs

Merge pull request #78188 from andir/buildRustCrate-support-rlib

buildRustCrate: support `rlib` dependency type
This commit is contained in:
Andreas Rammhold 2020-01-28 13:47:57 +01:00 committed by GitHub
commit cd27940df0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 12 deletions

View file

@ -23,7 +23,7 @@ let
lib.strings.replaceStrings ["-"] ["_"] crateRenames.${dep.crateName}
else
extern;
in (if lib.any (x: x == "lib") dep.crateType then
in (if lib.any (x: x == "lib" || x == "rlib") dep.crateType then
" --extern ${name}=${dep.lib}/lib/lib${extern}-${dep.metadata}.rlib"
else
" --extern ${name}=${dep.lib}/lib/lib${extern}-${dep.metadata}${stdenv.hostPlatform.extensions.sharedLibrary}")

View file

@ -1,17 +1,17 @@
{ lib, buildRustCrate, runCommand, writeTextFile, symlinkJoin, callPackage, releaseTools }:
let
mkCrate = args: let
p = {
crateName = "nixtestcrate";
version = "0.1.0";
authors = [ "Test <test@example.com>" ];
} // args;
in buildRustCrate p;
p = {
crateName = "nixtestcrate";
version = "0.1.0";
authors = [ "Test <test@example.com>" ];
} // args;
in buildRustCrate p;
mkFile = destination: text: writeTextFile {
name = "src";
destination = "/${destination}";
inherit text;
mkFile = destination: text: writeTextFile {
name = "src";
destination = "/${destination}";
inherit text;
};
mkBin = name: mkFile name ''
@ -185,7 +185,20 @@ let
"test tests_bar ... ok"
];
};
linkAgainstRlibCrate = {
crateName = "foo";
src = mkFile "src/main.rs" ''
extern crate somerlib;
fn main() {}
'';
dependencies = [
(mkCrate {
crateName = "somerlib";
type = [ "rlib" ];
src = mkLib "src/lib.rs";
})
];
};
};
brotliCrates = (callPackage ./brotli-crates.nix {});
in lib.mapAttrs (key: value: mkTest (value // lib.optionalAttrs (!value?crateName) { crateName = key; })) cases // {