mirror of
https://github.com/ipetkov/crane.git
synced 2024-11-22 23:17:15 +03:00
mkDummySrc: fix handling of bin targets
* First, bin targets go into `src/bin` not `bin` * Second, the path fallback name needs a `rs` suffix
This commit is contained in:
parent
b4a1445590
commit
55ba19ec1c
@ -53,7 +53,7 @@ let
|
||||
safeStubList = attr: defaultPath:
|
||||
let
|
||||
targetList = trimmedCargoToml.${attr} or [ ];
|
||||
paths = map (t: t.path or "${defaultPath}/${t.name}") targetList;
|
||||
paths = map (t: t.path or "${defaultPath}/${t.name}.rs") targetList;
|
||||
commands = map cpDummy paths;
|
||||
in
|
||||
concatStringsSep "\n" commands;
|
||||
@ -73,7 +73,7 @@ runCommand name { } ''
|
||||
# Stub all other targets in case they have particular feature combinations
|
||||
${safeStubLib}
|
||||
${safeStubList "bench" "benches"}
|
||||
${safeStubList "bin" "bin"}
|
||||
${safeStubList "bin" "src/bin"}
|
||||
${safeStubList "example" "examples"}
|
||||
${safeStubList "test" "tests"}
|
||||
''
|
||||
|
@ -41,6 +41,10 @@ pkgs.lib.makeScope myLib.newScope (self:
|
||||
touch $out
|
||||
'';
|
||||
|
||||
depsOnlyVariousTargets = myLib.buildDepsOnly {
|
||||
src = ./various-targets;
|
||||
};
|
||||
|
||||
simple = myLib.buildWithCargo {
|
||||
doCopyTargetToOutput = false;
|
||||
src = ./simple;
|
||||
|
7
tests/various-targets/Cargo.lock
generated
Normal file
7
tests/various-targets/Cargo.lock
generated
Normal file
@ -0,0 +1,7 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "various-targets"
|
||||
version = "0.1.0"
|
28
tests/various-targets/Cargo.toml
Normal file
28
tests/various-targets/Cargo.toml
Normal file
@ -0,0 +1,28 @@
|
||||
[package]
|
||||
name = "various-targets"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[[bench]]
|
||||
name = "foo"
|
||||
|
||||
[[bench]]
|
||||
name = "bar"
|
||||
|
||||
[[bin]]
|
||||
name = "baz"
|
||||
|
||||
[[bin]]
|
||||
name = "qux"
|
||||
|
||||
[[example]]
|
||||
name = "zuul"
|
||||
|
||||
[[example]]
|
||||
name = "corge"
|
||||
|
||||
[[test]]
|
||||
name = "grault"
|
||||
|
||||
[[test]]
|
||||
name = "garply"
|
4
tests/various-targets/benches/bar.rs
Normal file
4
tests/various-targets/benches/bar.rs
Normal file
@ -0,0 +1,4 @@
|
||||
#[test]
|
||||
fn foo() {
|
||||
}
|
||||
|
4
tests/various-targets/benches/foo.rs
Normal file
4
tests/various-targets/benches/foo.rs
Normal file
@ -0,0 +1,4 @@
|
||||
#[test]
|
||||
fn foo() {
|
||||
}
|
||||
|
4
tests/various-targets/examples/corge.rs
Normal file
4
tests/various-targets/examples/corge.rs
Normal file
@ -0,0 +1,4 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
||||
|
4
tests/various-targets/examples/zuul.rs
Normal file
4
tests/various-targets/examples/zuul.rs
Normal file
@ -0,0 +1,4 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
||||
|
2
tests/various-targets/src/bin/baz.rs
Normal file
2
tests/various-targets/src/bin/baz.rs
Normal file
@ -0,0 +1,2 @@
|
||||
pub fn main() {
|
||||
}
|
3
tests/various-targets/src/bin/qux.rs
Normal file
3
tests/various-targets/src/bin/qux.rs
Normal file
@ -0,0 +1,3 @@
|
||||
pub fn main() {
|
||||
println!("hello world");
|
||||
}
|
0
tests/various-targets/tests/garply.rs
Normal file
0
tests/various-targets/tests/garply.rs
Normal file
0
tests/various-targets/tests/grault.rs
Normal file
0
tests/various-targets/tests/grault.rs
Normal file
Loading…
Reference in New Issue
Block a user