From 596c582deed419b0cf1f80b9be77ff705df20e01 Mon Sep 17 00:00:00 2001 From: Luca Barbato Date: Mon, 23 Nov 2020 13:27:36 +0100 Subject: [PATCH] Explicitly build the rlib Fixes #138. --- example-project/tests/rust.rs | 7 +++++++ src/build.rs | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 example-project/tests/rust.rs diff --git a/example-project/tests/rust.rs b/example-project/tests/rust.rs new file mode 100644 index 00000000..067cc77a --- /dev/null +++ b/example-project/tests/rust.rs @@ -0,0 +1,7 @@ +use example_project::OddCounter; + +#[test] +#[should_panic] +fn test() { + OddCounter::new(40).unwrap(); +} diff --git a/src/build.rs b/src/build.rs index 7f82b415..743ea552 100644 --- a/src/build.rs +++ b/src/build.rs @@ -101,7 +101,7 @@ fn patch_lib_kind_in_target(ws: &mut Workspace, libkinds: &[&str]) -> anyhow::Re let manifest = pkg.manifest_mut(); let targets = manifest.targets_mut(); - let kinds: Vec<_> = libkinds + let mut kinds: Vec<_> = libkinds .iter() .map(|&kind| match kind { "staticlib" => CrateType::Staticlib, @@ -110,6 +110,8 @@ fn patch_lib_kind_in_target(ws: &mut Workspace, libkinds: &[&str]) -> anyhow::Re }) .collect(); + kinds.push(CrateType::Lib); + for target in targets.iter_mut() { if target.is_lib() { target.set_kind(TargetKind::Lib(kinds.clone()));