Skip to content

Commit b2266f7

Browse files
authored
Refactor build and run modules for improved structure and clarity (drivercraft#21)
* Refactor build and run modules for improved structure and clarity - Renamed methods for consistency and clarity (e.g., `build_custrom` to `build_custom`, `perpare_build_config` to `prepare_build_config`). - Introduced `CargoRunnerKind` enum to encapsulate QEMU and U-Boot configurations. - Moved cargo-related functionality from `cargo.rs` to `cargo_builder.rs` for better separation of concerns. - Consolidated path management into `PathConfig` struct, simplifying path handling throughout the application. - Updated `AppContext` to use the new `PathConfig` structure, removing direct references to paths. - Enhanced error handling and path normalization in build and run processes. - Removed deprecated `cargo.rs` file and adjusted references accordingly. - Updated TFTP and U-Boot implementations to utilize the new path management structure. * chore: update dependencies and improve code structure * fix: update qemu installation step to include package list update * fix: format qemu installation step for improved readability * style: streamline code formatting
1 parent ffa4447 commit b2266f7

File tree

15 files changed

+602
-613
lines changed

15 files changed

+602
-613
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ jobs:
2424
targets: ${{ matrix.targets }}
2525
- uses: Swatinem/rust-cache@v2
2626
- name: Install qemu
27-
run: sudo apt install qemu-system-aarch64 -y
28-
- run: sudo apt install u-boot-tools -y
27+
run: |
28+
sudo apt-get update
29+
sudo apt install qemu-system-aarch64 -y
30+
sudo apt install u-boot-tools -y
2931
- name: Install lib libudev-dev
3032
run: sudo apt install libudev-dev -y
3133
- name: Check rust version

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jkconfig/tests/schema.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ fn test_object() {
6363

6464
#[test]
6565
fn test_value() {
66-
env_logger::builder().is_test(true).init();
66+
let _ = env_logger::builder().is_test(true).try_init();
6767

6868
let schema = schema_for!(AnimalObject);
6969

ostool/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ license = "MIT OR Apache-2.0"
77
name = "ostool"
88
readme = "../README.md"
99
repository = "https://github.com/ZR233/ostool"
10-
version = "0.8.3"
10+
version = "0.8.4"
1111

1212
[[bin]]
1313
name = "ostool"

ostool/src/bin/cargo-osrun.rs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::{env, path::PathBuf, process::exit};
33
use clap::{Parser, Subcommand};
44
use log::{LevelFilter, debug};
55
use ostool::{
6-
ctx::AppContext,
6+
ctx::{AppContext, OutputConfig, PathConfig},
77
run::{
88
qemu,
99
uboot::{self, RunUbootArgs},
@@ -53,6 +53,12 @@ struct RunnerArgs {
5353
#[arg(allow_hyphen_values = true)]
5454
/// Arguments to be run
5555
runner_args: Vec<String>,
56+
57+
#[arg(long)]
58+
build_dir: Option<String>,
59+
60+
#[arg(long)]
61+
bin_dir: Option<String>,
5662
}
5763

5864
#[derive(Debug, Subcommand, Clone)]
@@ -90,9 +96,18 @@ async fn main() -> anyhow::Result<()> {
9096
Err(_) => manifest_dir.clone(),
9197
};
9298

99+
let bin_dir: Option<PathBuf> = args.bin_dir.map(PathBuf::from);
100+
let build_dir: Option<PathBuf> = args.build_dir.map(PathBuf::from);
101+
102+
let output_config = OutputConfig { build_dir, bin_dir };
103+
93104
let mut app = AppContext {
94-
workspace_folder,
95-
manifest_dir,
105+
paths: PathConfig {
106+
workspace: workspace_folder,
107+
manifest: manifest_dir,
108+
config: output_config,
109+
..Default::default()
110+
},
96111
..Default::default()
97112
};
98113

0 commit comments

Comments
 (0)