Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ use crate::{Action, Target, TargetKind};
fn convert(metadata: CargoMetadata, current_dir: &Path) -> Vec<Target> {
let mut targets = Vec::new();
for p in &metadata.packages {
let package_name = p.name.as_str();
for t in &p.targets {
if is_select_target(t) {
targets.push(build_target(t, current_dir));
targets.push(build_target(t, package_name, current_dir));
}
}
}
Expand All @@ -24,8 +25,9 @@ fn is_select_target(t: &CargoTarget) -> bool {
t.is_bin() || t.is_example()
}

fn build_target(t: &CargoTarget, current_dir: &Path) -> Target {
fn build_target(t: &CargoTarget, package_name: &str, current_dir: &Path) -> Target {
let name = t.name.to_owned();
let package = package_name.to_owned();
let kind = if t.is_bin() {
TargetKind::Bin
} else {
Expand All @@ -40,6 +42,7 @@ fn build_target(t: &CargoTarget, current_dir: &Path) -> Target {

Target {
name,
package,
kind,
path,
required_features,
Expand Down Expand Up @@ -77,6 +80,8 @@ pub fn exec_cargo_run(
let mut cmd = Command::new("cargo");
cmd.arg(action).arg(kind).arg(name);

cmd.arg("--package").arg(&target.package);

let require_features = !target.required_features.is_empty();

if require_features {
Expand Down
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ struct SelectorArgs {
#[derive(Debug, Clone)]
pub struct Target {
name: String,
package: String,
kind: TargetKind,
path: String,
required_features: Vec<String>,
Expand Down