Skip to content

Commit 1e8306b

Browse files
committed
Remove unused config.manifest_path field
1 parent 48d7b80 commit 1e8306b

File tree

5 files changed

+10
-20
lines changed

5 files changed

+10
-20
lines changed

src/config.rs

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,26 @@
11
use crate::ErrorMessage;
2-
use std::path::PathBuf;
2+
use std::path::Path;
33
use toml::Value;
44

55
#[derive(Debug, Clone)]
66
pub struct Config {
7-
pub manifest_path: PathBuf,
87
pub default_target: Option<String>,
98
pub run_command: Vec<String>,
109
pub run_args: Option<Vec<String>>,
1110
pub test_timeout: u32,
1211
}
1312

14-
pub(crate) fn read_config(manifest_path: PathBuf) -> Result<Config, ErrorMessage> {
13+
pub(crate) fn read_config(manifest_path: &Path) -> Result<Config, ErrorMessage> {
1514
let config = read_config_inner(manifest_path)
1615
.map_err(|err| format!("Failed to read bootimage configuration: {:?}", err))?;
1716
Ok(config)
1817
}
1918

20-
pub(crate) fn read_config_inner(manifest_path: PathBuf) -> Result<Config, ErrorMessage> {
19+
pub(crate) fn read_config_inner(manifest_path: &Path) -> Result<Config, ErrorMessage> {
2120
use std::{fs::File, io::Read};
2221
let cargo_toml: Value = {
2322
let mut content = String::new();
24-
File::open(&manifest_path)
23+
File::open(manifest_path)
2524
.map_err(|e| format!("Failed to open Cargo.toml: {}", e))?
2625
.read_to_string(&mut content)
2726
.map_err(|e| format!("Failed to read Cargo.toml: {}", e))?;
@@ -36,21 +35,14 @@ pub(crate) fn read_config_inner(manifest_path: PathBuf) -> Result<Config, ErrorM
3635
.and_then(|table| table.get("bootimage"));
3736
let metadata = match metadata {
3837
None => {
39-
return Ok(ConfigBuilder {
40-
manifest_path: Some(manifest_path),
41-
..Default::default()
42-
}
43-
.into());
38+
return Ok(ConfigBuilder::default().into());
4439
}
4540
Some(metadata) => metadata
4641
.as_table()
4742
.ok_or(format!("Bootimage configuration invalid: {:?}", metadata))?,
4843
};
4944

50-
let mut config = ConfigBuilder {
51-
manifest_path: Some(manifest_path),
52-
..Default::default()
53-
};
45+
let mut config = ConfigBuilder::default();
5446

5547
for (key, value) in metadata {
5648
match (key.as_str(), value.clone()) {
@@ -93,7 +85,6 @@ pub(crate) fn read_config_inner(manifest_path: PathBuf) -> Result<Config, ErrorM
9385

9486
#[derive(Default)]
9587
struct ConfigBuilder {
96-
manifest_path: Option<PathBuf>,
9788
default_target: Option<String>,
9889
run_command: Option<Vec<String>>,
9990
run_args: Option<Vec<String>>,
@@ -103,7 +94,6 @@ struct ConfigBuilder {
10394
impl Into<Config> for ConfigBuilder {
10495
fn into(self) -> Config {
10596
Config {
106-
manifest_path: self.manifest_path.expect("manifest path must be set"),
10797
default_target: self.default_target,
10898
run_command: self.run_command.unwrap_or(vec![
10999
"qemu-system-x86_64".into(),

src/subcommand/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::{path::PathBuf, process};
33

44
pub(crate) fn build(mut args: Args) -> Result<(), ErrorMessage> {
55
let builder = Builder::new(args.manifest_path().clone())?;
6-
let config = config::read_config(builder.kernel_manifest_path().to_owned())?;
6+
let config = config::read_config(builder.kernel_manifest_path())?;
77
args.apply_default_target(&config, builder.kernel_root());
88

99
let quiet = args.quiet;

src/subcommand/run.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ pub(crate) fn run(mut args: Args) -> Result<i32, ErrorMessage> {
55
use crate::subcommand::build;
66

77
let builder = Builder::new(args.manifest_path().clone())?;
8-
let config = config::read_config(builder.kernel_manifest_path().to_owned())?;
8+
let config = config::read_config(builder.kernel_manifest_path())?;
99
args.apply_default_target(&config, builder.kernel_root());
1010

1111
let quiet = args.quiet;

src/subcommand/runner.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::process;
33

44
pub(crate) fn runner(args: RunnerArgs) -> Result<i32, ErrorMessage> {
55
let builder = Builder::new(None)?;
6-
let config = config::read_config(builder.kernel_manifest_path().to_owned())?;
6+
let config = config::read_config(builder.kernel_manifest_path())?;
77

88
let bootimage_bin = {
99
let parent = args

src/subcommand/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use wait_timeout::ChildExt;
55

66
pub(crate) fn test(mut args: Args) -> Result<(), ErrorMessage> {
77
let builder = Builder::new(args.manifest_path().clone())?;
8-
let config = config::read_config(builder.kernel_manifest_path().to_owned())?;
8+
let config = config::read_config(builder.kernel_manifest_path())?;
99
args.apply_default_target(&config, builder.kernel_root());
1010

1111
let test_args = args.clone();

0 commit comments

Comments
 (0)