Skip to content

Fix 1#39

Merged
ZR233 merged 6 commits intomainfrom
fix-1
Mar 16, 2026
Merged

Fix 1#39
ZR233 merged 6 commits intomainfrom
fix-1

Conversation

@ZR233
Copy link
Member

@ZR233 ZR233 commented Mar 16, 2026

No description provided.

Copilot AI review requested due to automatic review settings March 16, 2026 02:39
@ZR233 ZR233 merged commit a0a0e17 into main Mar 16, 2026
3 checks passed
@ZR233 ZR233 deleted the fix-1 branch March 16, 2026 02:46
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves error reporting across ostool by adding path-aware context helpers and migrating multiple fallible operations to richer anyhow/thiserror-based errors, while also extending the Cargo build/run flow with “someboot” auto-configuration and more robust artifact resolution from Cargo JSON output.

Changes:

  • Added PathResultExt to consistently attach {action}: {path} context to filesystem failures and applied it in QEMU/U-Boot/menuconfig/build flows.
  • Reworked Cargo run/build execution to (optionally) resolve the built executable path from Cargo JSON messages and added someboot build-info.toml auto-arg detection.
  • Improved CLI error handling by returning ExitCode and printing full error chains/traces; refactored OVMF prebuilt error types to thiserror.

Reviewed changes

Copilot reviewed 12 out of 14 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
ostool/src/utils.rs Adds PathResultExt helper for path-aware error context.
ostool/src/run/uboot.rs Replaces ad-hoc error mapping with with_path/with_context for clearer diagnostics.
ostool/src/run/qemu.rs Improves config read/write errors and makes DTB dump cleanup non-fatal for missing files.
ostool/src/run/ovmf_prebuilt/fetch.rs Refines cache update error handling (NotFound handling + richer error variants).
ostool/src/run/ovmf_prebuilt/error.rs Migrates error enum to thiserror with structured variants and sources.
ostool/src/menuconfig.rs Adds contextful errors and path-aware save failures for edited configs.
ostool/src/main.rs Switches to try_main + ExitCode and prints full error chain/trace.
ostool/src/ctx.rs Improves metadata/ELF-path error reporting; integrates someboot args into loaded build config.
ostool/src/build/someboot.rs New module to detect someboot build-info.toml and convert it into Cargo CLI args.
ostool/src/build/mod.rs Refactors cargo_run to build first, then invoke QEMU/U-Boot runners directly.
ostool/src/build/cargo_builder.rs Adds optional Cargo JSON artifact resolution and someboot arg auto-detection.
ostool/src/bin/cargo-osrun.rs Switches to try_main + ExitCode; updates for fallible set_elf_path.
ostool/Cargo.toml Bumps version and adds thiserror workspace dependency.
Cargo.lock Updates lockfile for version bump and thiserror dependency.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +347 to +350
if let BuildSystem::Cargo(cargo) = &mut c.system {
let iter = self.someboot_cargo_args(cargo)?.into_iter();
cargo.args.extend(iter);
}
Comment on lines +14 to +15
pub fn detect_build_config(manifest_path: &PathBuf, target: &str) -> anyhow::Result<Vec<String>> {
let mut cargo_args = Vec::new();
Comment on lines +150 to +168
use super::detect_build_config;
use std::path::PathBuf;

#[test]
fn test_local() {
detect_build_config_works_for_sparreal_manifest(
"/home/ubuntu/workspace/sparreal-os/Cargo.toml",
);
}

#[test]
fn test_crateio() {
detect_build_config_works_for_sparreal_manifest(
"/home/ubuntu/workspace/tgoskits/Cargo.toml",
);
}

fn detect_build_config_works_for_sparreal_manifest(p: &str) {
let manifest_path = PathBuf::from(p);
Comment on lines +302 to +315
// Auto-detected args from someboot/build-info.toml
let workspace_manifest = self.ctx.paths.workspace.join("Cargo.toml");
if workspace_manifest.exists() {
let detected_args =
someboot::detect_build_config(&workspace_manifest, &self.config.target)
.with_context(|| {
format!(
"failed to detect someboot build config from {}",
workspace_manifest.display()
)
})?;
for arg in detected_args {
cmd.arg(arg);
}
Comment on lines 73 to 79
let config_path = ctx.paths.workspace.join(".qemu.toml");
if config_path.exists() {
println!("\n当前 U-Boot 配置文件: {}", config_path.display());
// 这里可以读取并显示当前的 U-Boot 配置
} else {
println!("\n未找到 U-Boot 配置文件,将使用默认配置");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants