-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathmod.rs
More file actions
75 lines (62 loc) · 1.73 KB
/
Copy pathmod.rs
File metadata and controls
75 lines (62 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
use crate::build::run_command;
use color_eyre::eyre::{eyre, Result};
use fs_err as fs;
use std::path::Path;
use std::process::Command;
use tracing::{info, instrument};
#[instrument(level = "trace", skip_all)]
pub fn execute(
package_dir: &Path,
release: bool,
profile: Option<&str>,
targets: Vec<String>,
packages: Vec<String>,
features: Vec<String>,
all_features: bool,
no_default_features: bool,
verbose: bool,
) -> Result<()> {
let package_dir = fs::canonicalize(package_dir)?;
if !package_dir.exists() {
let error = format!("Directory {:?} doesnt exists.", package_dir);
return Err(eyre!(error));
}
info!("Checking package in {:?}...", package_dir);
let mut args: Vec<String> = vec!["check", "--target-dir", "target"]
.iter()
.map(|v| v.to_string())
.collect();
if release {
args.push("--release".to_string());
}
if let Some(prof) = profile {
args.push("--profile".to_string());
args.push(prof.to_string());
}
for target in targets {
args.push("--target".to_string());
args.push(target);
}
for package in packages {
args.push("--package".to_string());
args.push(package);
}
if all_features {
args.push("--all-features".to_string());
}
if no_default_features {
args.push("--no-default-features".to_string());
}
if !features.is_empty() {
args.push("--features".to_string());
args.push(features.join(","));
}
run_command(
Command::new("cargo")
.args(&args[..])
.current_dir(&package_dir),
verbose,
)?;
info!("Done checking package in {:?}.", package_dir);
Ok(())
}