Skip to content

Commit cd06126

Browse files
committed
feat: 更新 someboot 模块的导入方式并改进构建配置检测
1 parent b3724ba commit cd06126

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

ostool/src/build/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pub mod cargo_builder;
3737
/// Build configuration types and structures.
3838
pub mod config;
3939

40-
mod someboot;
40+
pub mod someboot;
4141

4242
/// Specifies the type of runner to use after building.
4343
///

ostool/src/ctx.rs

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,13 @@ use jkconfig::{
1919
use object::{Architecture, Object};
2020
use tokio::fs;
2121

22-
use crate::{build::config::BuildConfig, utils::PathResultExt};
22+
use crate::{
23+
build::{
24+
config::{BuildConfig, BuildSystem, Cargo},
25+
someboot,
26+
},
27+
utils::PathResultExt,
28+
};
2329

2430
/// Configuration for output directories.
2531
///
@@ -241,9 +247,9 @@ impl AppContext {
241247
///
242248
/// Returns an error if no ELF file is set or `rust-objcopy` fails.
243249
pub fn objcopy_output_bin(&mut self) -> anyhow::Result<PathBuf> {
244-
if self.paths.artifacts.bin.is_some() {
245-
debug!("BIN file already exists: {:?}", self.paths.artifacts.bin);
246-
return Ok(self.paths.artifacts.bin.as_ref().unwrap().clone());
250+
if let Some(bin) = &self.paths.artifacts.bin {
251+
debug!("BIN file already exists: {:?}", bin);
252+
return Ok(bin.clone());
247253
}
248254

249255
let elf_path = self
@@ -327,7 +333,7 @@ impl AppContext {
327333
};
328334
self.build_config_path = Some(config_path.clone());
329335

330-
let Some(c): Option<BuildConfig> = jkconfig::run(
336+
let Some(mut c): Option<BuildConfig> = jkconfig::run(
331337
config_path.clone(),
332338
menu,
333339
&[self.ui_hock_feature_select(), self.ui_hock_pacage_select()],
@@ -338,10 +344,21 @@ impl AppContext {
338344
anyhow::bail!("No build configuration obtained");
339345
};
340346

347+
if let BuildSystem::Cargo(cargo) = &mut c.system {
348+
let iter = self.someboot_cargo_args(cargo)?.into_iter();
349+
cargo.args.extend(iter);
350+
}
351+
341352
self.build_config = Some(c.clone());
342353
Ok(c)
343354
}
344355

356+
fn someboot_cargo_args(&self, cargo: &Cargo) -> anyhow::Result<Vec<String>> {
357+
let manifest_path = self.paths.manifest.join("Cargo.toml");
358+
let target = &cargo.target;
359+
someboot::detect_build_config(&manifest_path, target)
360+
}
361+
345362
/// Replaces variable placeholders in a string.
346363
///
347364
/// Currently supports `${workspaceFolder}` which is replaced with the

0 commit comments

Comments
 (0)