mirror of
https://github.com/nix-community/naersk
synced 2024-11-10 06:04:17 +00:00
Expand wildcard members in manifests
This commit is contained in:
parent
be6d7bfe61
commit
560601e3ab
9 changed files with 61 additions and 1 deletions
21
config.nix
21
config.nix
|
@ -176,10 +176,29 @@ let
|
|||
value = readTOML (root + "/${member}/Cargo.toml");
|
||||
}
|
||||
)
|
||||
(toplevelCargotoml.workspace.members or [])
|
||||
members
|
||||
)
|
||||
);
|
||||
|
||||
# The cargo members
|
||||
members =
|
||||
let
|
||||
# the members, as listed in the virtual manifest
|
||||
listedMembers = toplevelCargotoml.workspace.members or [];
|
||||
|
||||
# this turns members like "foo/*" into [ "foo/bar" "foo/baz" ]
|
||||
# as in https://github.com/rust-analyzer/rust-analyzer/blob/b2ed130ffd9c79de26249a1dfb2a8312d6af12b3/Cargo.toml#L2
|
||||
expandMember = member:
|
||||
if lib.hasSuffix "/*" member
|
||||
then
|
||||
let
|
||||
rootDir = lib.removeSuffix "/*" member;
|
||||
subdirs = builtins.attrNames (builtins.readDir (root + "/${rootDir}"));
|
||||
in map (subdir: "${rootDir}/${subdir}") subdirs
|
||||
else [ member ];
|
||||
|
||||
in lib.concatMap expandMember listedMembers;
|
||||
|
||||
patchedSources =
|
||||
let
|
||||
mkRelative = po:
|
||||
|
|
2
test.nix
2
test.nix
|
@ -128,6 +128,8 @@ rec
|
|||
cargoOptions = [ "--locked" ];
|
||||
};
|
||||
|
||||
cargo-wildcard = naersk.buildPackage ./test/cargo-wildcard;
|
||||
|
||||
workspace = naersk.buildPackage ./test/workspace;
|
||||
|
||||
workspace-patched = naersk.buildPackage ./test/workspace-patched;
|
||||
|
|
10
test/cargo-wildcard/Cargo.lock
generated
Normal file
10
test/cargo-wildcard/Cargo.lock
generated
Normal file
|
@ -0,0 +1,10 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
[[package]]
|
||||
name = "crate-a"
|
||||
version = "0.1.0"
|
||||
|
||||
[[package]]
|
||||
name = "crate-b"
|
||||
version = "0.1.0"
|
||||
|
2
test/cargo-wildcard/Cargo.toml
Normal file
2
test/cargo-wildcard/Cargo.toml
Normal file
|
@ -0,0 +1,2 @@
|
|||
[workspace]
|
||||
members = [ "crates/*" ]
|
9
test/cargo-wildcard/crates/crate-a/Cargo.toml
Normal file
9
test/cargo-wildcard/crates/crate-a/Cargo.toml
Normal file
|
@ -0,0 +1,9 @@
|
|||
[package]
|
||||
name = "crate-a"
|
||||
version = "0.1.0"
|
||||
authors = ["Nicolas Mattia <nicolas@nmattia.com>"]
|
||||
edition = "2018"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
3
test/cargo-wildcard/crates/crate-a/src/main.rs
Normal file
3
test/cargo-wildcard/crates/crate-a/src/main.rs
Normal file
|
@ -0,0 +1,3 @@
|
|||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
9
test/cargo-wildcard/crates/crate-b/Cargo.toml
Normal file
9
test/cargo-wildcard/crates/crate-b/Cargo.toml
Normal file
|
@ -0,0 +1,9 @@
|
|||
[package]
|
||||
name = "crate-b"
|
||||
version = "0.1.0"
|
||||
authors = ["Nicolas Mattia <nicolas@nmattia.com>"]
|
||||
edition = "2018"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
3
test/cargo-wildcard/crates/crate-b/src/main.rs
Normal file
3
test/cargo-wildcard/crates/crate-b/src/main.rs
Normal file
|
@ -0,0 +1,3 @@
|
|||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
3
test/cargo-wildcard/src/main.rs
Normal file
3
test/cargo-wildcard/src/main.rs
Normal file
|
@ -0,0 +1,3 @@
|
|||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
Loading…
Reference in a new issue