Conversation
There was a problem hiding this comment.
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
PathResultExtto 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.tomlauto-arg detection. - Improved CLI error handling by returning
ExitCodeand printing full error chains/traces; refactored OVMF prebuilt error types tothiserror.
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 配置文件,将使用默认配置"); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.