mirror of
https://github.com/ipetkov/crane.git
synced 2024-11-26 09:08:57 +03:00
mkDummySrc: drop dummy lib.rs by default, not main.rs
* There are some edge cases where cargo will allow a lib.rs file to be present but not a main.rs (e.g. a binary cannot be called "examples", which will happen if the crate is called that and a main.rs file is present)
This commit is contained in:
parent
bcec95e215
commit
abc2c8c418
@ -47,6 +47,12 @@ onlyDrvs (lib.makeScope myLib.newScope (self:
|
||||
|
||||
features = callPackage ./features { };
|
||||
|
||||
illegalBin = myLib.buildPackage {
|
||||
pname = "illegalBin";
|
||||
version = "0.0.1";
|
||||
src = ./illegal-bin;
|
||||
};
|
||||
|
||||
manyLibs = myLib.buildPackage {
|
||||
src = ./with-libs;
|
||||
pname = "my-libs";
|
||||
@ -72,6 +78,11 @@ onlyDrvs (lib.makeScope myLib.newScope (self:
|
||||
src = ./simple;
|
||||
};
|
||||
|
||||
# Test building a real world example
|
||||
ripgrep = myLib.buildPackage {
|
||||
inherit (pkgs.ripgrep) pname src version;
|
||||
};
|
||||
|
||||
smoke = callPackage ./smoke.nix { };
|
||||
smokeSimple = self.smoke [ "simple" ] self.simple;
|
||||
|
||||
|
7
checks/illegal-bin/Cargo.lock
generated
Normal file
7
checks/illegal-bin/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 = "examples"
|
||||
version = "0.0.0"
|
15
checks/illegal-bin/Cargo.toml
Normal file
15
checks/illegal-bin/Cargo.toml
Normal file
@ -0,0 +1,15 @@
|
||||
# This cargo workspace contains a member called "examples"
|
||||
# If we drop a dummy file in `src/main.rs` cargo will complain with:
|
||||
#
|
||||
# error: failed to load manifest for workspace member `/build/dummy-src/examples`
|
||||
# Caused by:
|
||||
# failed to parse manifest at `/build/dummy-src/examples/Cargo.toml`
|
||||
# Caused by:
|
||||
# the binary target name `examples` is forbidden, it conflicts with with cargo's build directory names
|
||||
#
|
||||
# Instead we need to drop a dummy file at `src/lib.rs`, and this is a
|
||||
# regression test for that case.
|
||||
[workspace]
|
||||
members = [
|
||||
"examples",
|
||||
]
|
9
checks/illegal-bin/examples/Cargo.toml
Normal file
9
checks/illegal-bin/examples/Cargo.toml
Normal file
@ -0,0 +1,9 @@
|
||||
[package]
|
||||
name = "examples"
|
||||
version = "0.0.0"
|
||||
publish = false
|
||||
edition = "2021"
|
||||
|
||||
[[example]]
|
||||
name = "foo"
|
||||
path = "foo.rs"
|
2
checks/illegal-bin/examples/foo.rs
Normal file
2
checks/illegal-bin/examples/foo.rs
Normal file
@ -0,0 +1,2 @@
|
||||
fn main() {
|
||||
}
|
@ -1,2 +0,0 @@
|
||||
#![allow(dead_code)]
|
||||
pub fn main() {}
|
@ -1,2 +0,0 @@
|
||||
#![allow(dead_code)]
|
||||
pub fn main() {}
|
@ -1,2 +0,0 @@
|
||||
#![allow(dead_code)]
|
||||
pub fn main() {}
|
@ -96,7 +96,7 @@ let
|
||||
# To build build-dependencies
|
||||
${cpDummy parentDir "build.rs"}
|
||||
# To build regular and dev dependencies (cargo build + cargo test)
|
||||
${cpDummy parentDir "src/main.rs"}
|
||||
${cpDummy parentDir "src/lib.rs"}
|
||||
|
||||
# Stub all other targets in case they have particular feature combinations
|
||||
${safeStubLib}
|
||||
|
Loading…
Reference in New Issue
Block a user