Skip to content

Commit 2e0c7c5

Browse files
committed
1.75.1
1 parent 508b0da commit 2e0c7c5

File tree

9 files changed

+98
-22
lines changed

9 files changed

+98
-22
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changelog
22

3+
## 1.75.1 - Pending
4+
5+
### Enhancements
6+
7+
- parser: parse `required-features` from Cargo Metadata
8+
- command: compile Rust target with `required-features`
9+
- command: selectively list binary, example, integration test and unit test targets
10+
311
## 1.75.0 - 2023-12-28
412

513
### New Features

Cargo.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

command/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "firedbg-cli"
3-
version = "1.75.0"
3+
version = "1.75.1"
44
edition = "2021"
55
license = "MIT OR Apache-2.0"
66
authors = [

command/src/main.rs

Lines changed: 66 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use std::{
1717
process::exit,
1818
time::SystemTime,
1919
};
20-
use structopt::StructOpt;
20+
use structopt::{clap::arg_enum, StructOpt};
2121
use tokio::fs::{create_dir_all, remove_dir_all, remove_file};
2222

2323
const TEMPLATE: &str = concat!(
@@ -111,6 +111,14 @@ enum SubCommand {
111111
ListTarget {
112112
#[structopt(long)]
113113
json_format: bool,
114+
#[structopt(
115+
long,
116+
case_insensitive = true,
117+
possible_values = &ListTarget::variants(),
118+
default_value = "Bin Example Test UnitTest",
119+
value_delimiter = " ",
120+
)]
121+
targets: Vec<ListTarget>,
114122
},
115123
/// Open debugger view in VS Code
116124
Open {
@@ -129,6 +137,16 @@ enum SubCommand {
129137
},
130138
}
131139

140+
arg_enum! {
141+
#[derive(Debug, PartialEq)]
142+
enum ListTarget {
143+
Bin,
144+
Example,
145+
Test,
146+
UnitTest,
147+
}
148+
}
149+
132150
#[tokio::main]
133151
async fn main() -> Result<()> {
134152
env_logger::init();
@@ -347,7 +365,10 @@ async fn main() -> Result<()> {
347365
println!("{}", serde_json::json!(arr));
348366
}
349367
}
350-
SubCommand::ListTarget { json_format } => list_target(workspace, json_format)
368+
SubCommand::ListTarget {
369+
json_format,
370+
targets,
371+
} => list_target(workspace, json_format, targets)
351372
.await
352373
.context("Fail to list target")?,
353374
SubCommand::Open { idx } => {
@@ -858,7 +879,11 @@ fn list_firedbg_runs(firedbg_runs: Vec<PathBuf>) {
858879
}
859880
}
860881

861-
async fn list_target(workspace: &Workspace, json_format: bool) -> Result<()> {
882+
async fn list_target(
883+
workspace: &Workspace,
884+
json_format: bool,
885+
targets: Vec<ListTarget>,
886+
) -> Result<()> {
862887
#[derive(Debug, Serialize)]
863888
struct Target<'a> {
864889
binaries: Vec<&'a Binary>,
@@ -880,17 +905,37 @@ async fn list_target(workspace: &Workspace, json_format: bool) -> Result<()> {
880905
test_cases: Vec<String>,
881906
}
882907

883-
let binaries: Vec<_> = workspace
884-
.packages
885-
.iter()
886-
.flat_map(|package| &package.binaries)
887-
.collect();
908+
let list_all = targets.contains(&ListTarget::Bin)
909+
&& targets.contains(&ListTarget::Example)
910+
&& targets.contains(&ListTarget::Test)
911+
&& targets.contains(&ListTarget::UnitTest);
912+
let list_partial = !list_all
913+
&& targets.iter().any(|t| {
914+
matches!(
915+
t,
916+
ListTarget::Bin | ListTarget::Example | ListTarget::Test | ListTarget::UnitTest
917+
)
918+
});
888919

889-
let examples: Vec<_> = workspace
890-
.packages
891-
.iter()
892-
.flat_map(|package| &package.examples)
893-
.collect();
920+
let binaries: Vec<_> = if list_all || (list_partial && targets.contains(&ListTarget::Bin)) {
921+
workspace
922+
.packages
923+
.iter()
924+
.flat_map(|package| &package.binaries)
925+
.collect()
926+
} else {
927+
Vec::new()
928+
};
929+
930+
let examples: Vec<_> = if list_all || (list_partial && targets.contains(&ListTarget::Example)) {
931+
workspace
932+
.packages
933+
.iter()
934+
.flat_map(|package| &package.examples)
935+
.collect()
936+
} else {
937+
Vec::new()
938+
};
894939

895940
fn handle_tests<'a>((package, test): &'a (&'a Package, Option<&'a Test>)) -> TestType {
896941
if let Some(test) = test {
@@ -926,13 +971,15 @@ async fn list_target(workspace: &Workspace, json_format: bool) -> Result<()> {
926971
package
927972
.tests
928973
.iter()
974+
.filter(|_| list_all || (list_partial && targets.contains(&ListTarget::Test)))
929975
.map(|test| (package, Some(test)))
930976
.collect::<Vec<_>>()
931977
})
932978
.chain(
933979
workspace
934980
.packages
935981
.iter()
982+
.filter(|_| list_all || (list_partial && targets.contains(&ListTarget::UnitTest)))
936983
.filter(|package| package.has_lib)
937984
.map(|package| (package, None)),
938985
)
@@ -999,8 +1046,12 @@ async fn list_target(workspace: &Workspace, json_format: bool) -> Result<()> {
9991046
create_dir_all(firedbg_dir)
10001047
.await
10011048
.with_context(|| format!("Fail to create directory: `{firedbg_dir}`"))?;
1002-
let path = &format!("{firedbg_dir}/target.json");
1003-
to_json_file(path, &target)
1049+
let path = if !list_all && list_partial && targets.contains(&ListTarget::UnitTest) {
1050+
format!("{firedbg_dir}/target-unit-test.json")
1051+
} else {
1052+
format!("{firedbg_dir}/target.json")
1053+
};
1054+
to_json_file(&path, &target)
10041055
.await
10051056
.with_context(|| format!("Fail to create JSON file: `{path}`"))?;
10061057
Ok(())

debugger/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "firedbg-rust-debugger"
3-
version = "1.75.0"
3+
version = "1.75.1"
44
edition = "2021"
55
license = "MIT OR Apache-2.0"
66
build = "build.rs"

indexer/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "firedbg-stream-indexer"
3-
version = "1.75.0"
3+
version = "1.75.1"
44
edition = "2021"
55
license = "MIT OR Apache-2.0"
66
authors = [
@@ -28,7 +28,7 @@ tokio = { version = "1", optional = true }
2828
pretty_assertions = { version = "1", optional = true }
2929
async-trait = { version = "0.1", optional = true }
3030
# workspace
31-
firedbg-rust-debugger = { path = "../debugger", version = "1.75.0", default-features = false }
31+
firedbg-rust-debugger = { path = "../debugger", version = "1.75.1", default-features = false }
3232

3333
[features]
3434
# The base feature only exports the sea-orm entities

parser/src/def/workspace.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,21 @@ pub struct Dependency {
3535
pub struct Binary {
3636
pub name: String,
3737
pub src_path: String,
38+
pub required_features: Vec<String>,
3839
}
3940

4041
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
4142
pub struct Test {
4243
pub name: String,
4344
pub src_path: String,
45+
pub required_features: Vec<String>,
4446
}
4547

4648
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
4749
pub struct Example {
4850
pub name: String,
4951
pub src_path: String,
52+
pub required_features: Vec<String>,
5053
}
5154

5255
impl Workspace {
@@ -255,6 +258,9 @@ impl Binary {
255258
.arg(format!("{root_dir}/Cargo.toml"))
256259
.arg("--bin")
257260
.arg(binary_name);
261+
if !self.required_features.is_empty() {
262+
cmd.arg("--features").arg(self.required_features.join(","));
263+
}
258264
cmd
259265
}
260266

@@ -318,6 +324,9 @@ impl Test {
318324
.arg(format!("{root_dir}/Cargo.toml"))
319325
.arg("--test")
320326
.arg(test_name);
327+
if !self.required_features.is_empty() {
328+
cmd.arg("--features").arg(self.required_features.join(","));
329+
}
321330
cmd
322331
}
323332

@@ -356,6 +365,9 @@ impl Example {
356365
.arg(format!("{root_dir}/Cargo.toml"))
357366
.arg("--example")
358367
.arg(example_name);
368+
if !self.required_features.is_empty() {
369+
cmd.arg("--features").arg(self.required_features.join(","));
370+
}
359371
cmd
360372
}
361373

parser/src/def/workspace/raw.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,6 @@ pub struct Target {
2929
pub kind: Vec<String>,
3030
pub name: String,
3131
pub src_path: String,
32+
#[serde(default, rename(deserialize = "required-features"))]
33+
pub required_features: Vec<String>,
3234
}

parser/src/parsing/workspace.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ fn parse_binaries(raw_target: Vec<raw::Target>) -> Vec<Binary> {
7171
.map(|raw_target| Binary {
7272
name: raw_target.name,
7373
src_path: raw_target.src_path,
74+
required_features: raw_target.required_features,
7475
})
7576
.collect()
7677
}
@@ -82,6 +83,7 @@ fn parse_tests(raw_target: Vec<raw::Target>) -> Vec<Test> {
8283
.map(|raw_target| Test {
8384
name: raw_target.name,
8485
src_path: raw_target.src_path,
86+
required_features: raw_target.required_features,
8587
})
8688
.collect()
8789
}
@@ -93,6 +95,7 @@ fn parse_examples(raw_target: Vec<raw::Target>) -> Vec<Example> {
9395
.map(|raw_target| Example {
9496
name: raw_target.name,
9597
src_path: raw_target.src_path,
98+
required_features: raw_target.required_features,
9699
})
97100
.collect()
98101
}

0 commit comments

Comments
 (0)