diff --git a/framework/aster-frame/src/boot/mod.rs b/framework/aster-frame/src/boot/mod.rs index 8ee4c17a9..353822117 100644 --- a/framework/aster-frame/src/boot/mod.rs +++ b/framework/aster-frame/src/boot/mod.rs @@ -130,10 +130,11 @@ pub fn call_aster_main() -> ! { } fn run_ktests(test_whitelist: Option<&[&str]>, crate_whitelist: Option<&[&str]>) -> ! { - use crate::arch::qemu::{exit_qemu, QemuExitCode}; use alloc::{boxed::Box, string::ToString}; use core::any::Any; + use crate::arch::qemu::{exit_qemu, QemuExitCode}; + let fn_catch_unwind = &(unwinding::panic::catch_unwind::<(), fn()> as fn(fn()) -> Result<(), Box<(dyn Any + Send + 'static)>>); diff --git a/framework/aster-frame/src/prelude.rs b/framework/aster-frame/src/prelude.rs index 42eacab20..501ea9a8a 100644 --- a/framework/aster-frame/src/prelude.rs +++ b/framework/aster-frame/src/prelude.rs @@ -7,8 +7,9 @@ pub type Result = core::result::Result; pub(crate) use alloc::{boxed::Box, sync::Arc, vec::Vec}; pub(crate) use core::any::Any; -pub use crate::vm::{Paddr, Vaddr}; - -pub use crate::early_print as print; -pub use crate::early_println as println; pub use aster_main::aster_main; + +pub use crate::{ + early_print as print, early_println as println, + vm::{Paddr, Vaddr}, +}; diff --git a/framework/libs/ktest/src/runner.rs b/framework/libs/ktest/src/runner.rs index 624ddfd5e..1fc16fd00 100644 --- a/framework/libs/ktest/src/runner.rs +++ b/framework/libs/ktest/src/runner.rs @@ -3,7 +3,7 @@ //! Test runner enabling control over the tests. //! -use alloc::{string::String, vec::Vec, collections::BTreeSet}; +use alloc::{collections::BTreeSet, string::String, vec::Vec}; use core::format_args; use owo_colors::OwoColorize; diff --git a/osdk/src/base_crate/mod.rs b/osdk/src/base_crate/mod.rs index 9558d43b5..51a8b7766 100644 --- a/osdk/src/base_crate/mod.rs +++ b/osdk/src/base_crate/mod.rs @@ -4,13 +4,9 @@ //! It will depend on the kernel crate. //! -use std::path::Path; -use std::process::Command; -use std::str::FromStr; -use std::{fs, process}; +use std::{fs, path::Path, process, process::Command, str::FromStr}; -use crate::error::Errno; -use crate::error_msg; +use crate::{error::Errno, error_msg}; pub fn new_base_crate( base_crate_path: impl AsRef, diff --git a/osdk/src/bundle.rs b/osdk/src/bundle.rs index 1a9f9e68d..b827e0ea0 100644 --- a/osdk/src/bundle.rs +++ b/osdk/src/bundle.rs @@ -1,17 +1,22 @@ // SPDX-License-Identifier: MPL-2.0 -use std::path::{Path, PathBuf}; -use std::process::Command; - -use crate::bin::AsterBin; -use crate::cli::CargoArgs; -use crate::config_manager::{ - boot::Boot, - qemu::{Qemu, QemuMachine}, - RunConfig, +use std::{ + path::{Path, PathBuf}, + process::Command, +}; + +use crate::{ + bin::AsterBin, + cli::CargoArgs, + config_manager::{ + boot::Boot, + qemu::{Qemu, QemuMachine}, + RunConfig, + }, + error::Errno, + error_msg, + vm_image::AsterVmImage, }; -use crate::vm_image::AsterVmImage; -use crate::{error::Errno, error_msg}; /// The osdk bundle artifact that stores as `bundle` directory. /// diff --git a/osdk/src/commands/build/bin.rs b/osdk/src/commands/build/bin.rs index 3f6bd6ca6..4618e3ad7 100644 --- a/osdk/src/commands/build/bin.rs +++ b/osdk/src/commands/build/bin.rs @@ -1,17 +1,19 @@ // SPDX-License-Identifier: MPL-2.0 -use linux_bzimage_builder::{make_bzimage, BzImageType, legacy32_rust_target_json}; - -use std::path::{Path, PathBuf}; -use std::process::Command; use std::{ fs::OpenOptions, io::{Seek, SeekFrom, Write}, + path::{Path, PathBuf}, + process::Command, }; -use crate::bin::{AsterBin, AsterBinType, AsterBzImageMeta, AsterElfMeta}; -use crate::config_manager::boot::BootProtocol; -use crate::utils::get_current_crate_info; +use linux_bzimage_builder::{legacy32_rust_target_json, make_bzimage, BzImageType}; + +use crate::{ + bin::{AsterBin, AsterBinType, AsterBzImageMeta, AsterElfMeta}, + config_manager::boot::BootProtocol, + utils::get_current_crate_info, +}; pub fn make_install_bzimage( install_dir: impl AsRef, diff --git a/osdk/src/commands/build/grub.rs b/osdk/src/commands/build/grub.rs index f8caeb5c0..8eafa28cb 100644 --- a/osdk/src/commands/build/grub.rs +++ b/osdk/src/commands/build/grub.rs @@ -1,14 +1,17 @@ // SPDX-License-Identifier: MPL-2.0 -use std::fs; -use std::path::{Path, PathBuf}; - -use crate::bin::AsterBin; -use crate::config_manager::{boot::BootProtocol, BuildConfig}; -use crate::utils::get_current_crate_info; -use crate::vm_image::{AsterGrubIsoImageMeta, AsterVmImage, AsterVmImageType}; +use std::{ + fs, + path::{Path, PathBuf}, +}; use super::bin::make_install_bzimage; +use crate::{ + bin::AsterBin, + config_manager::{boot::BootProtocol, BuildConfig}, + utils::get_current_crate_info, + vm_image::{AsterGrubIsoImageMeta, AsterVmImage, AsterVmImageType}, +}; pub fn create_bootdev_image( target_dir: impl AsRef, @@ -38,12 +41,7 @@ pub fn create_bootdev_image( // Make the kernel image and place it in the boot directory. match protocol { BootProtocol::LinuxLegacy32 | BootProtocol::LinuxEfiHandover64 => { - make_install_bzimage( - &iso_root.join("boot"), - &target_dir, - aster_bin, - protocol, - ); + make_install_bzimage(&iso_root.join("boot"), &target_dir, aster_bin, protocol); } BootProtocol::Multiboot | BootProtocol::Multiboot2 => { // Copy the kernel image to the boot directory. diff --git a/osdk/src/commands/build/mod.rs b/osdk/src/commands/build/mod.rs index 1a9f5b77d..2b58aceb4 100644 --- a/osdk/src/commands/build/mod.rs +++ b/osdk/src/commands/build/mod.rs @@ -3,21 +3,25 @@ mod bin; mod grub; -use std::path::{Path, PathBuf}; -use std::process; -use std::str::FromStr; +use std::{ + path::{Path, PathBuf}, + process, + str::FromStr, +}; use bin::strip_elf_for_qemu; -use crate::base_crate::new_base_crate; -use crate::bin::{AsterBin, AsterBinType, AsterElfMeta}; -use crate::bundle::{Bundle, BundleManifest}; -use crate::cli::CargoArgs; -use crate::config_manager::{qemu::QemuMachine, BuildConfig}; -use crate::utils::{get_current_crate_info, get_target_directory}; -use crate::{error::Errno, error_msg}; - use super::utils::{cargo, COMMON_CARGO_ARGS, DEFAULT_TARGET_RELPATH}; +use crate::{ + base_crate::new_base_crate, + bin::{AsterBin, AsterBinType, AsterElfMeta}, + bundle::{Bundle, BundleManifest}, + cli::CargoArgs, + config_manager::{qemu::QemuMachine, BuildConfig}, + error::Errno, + error_msg, + utils::{get_current_crate_info, get_target_directory}, +}; pub fn execute_build_command(config: &BuildConfig) { let osdk_target_directory = get_target_directory().join(DEFAULT_TARGET_RELPATH); diff --git a/osdk/src/commands/check.rs b/osdk/src/commands/check.rs index 5a96ea75f..3fd216447 100644 --- a/osdk/src/commands/check.rs +++ b/osdk/src/commands/check.rs @@ -2,14 +2,8 @@ use std::process; -use crate::commands::utils::create_target_json; -use crate::error::Errno; -use crate::error_msg; - use super::utils::{cargo, COMMON_CARGO_ARGS}; -use crate::{ - commands::utils::create_target_json, error::Errno, error_msg, utils::get_cargo_metadata, -}; +use crate::{commands::utils::create_target_json, error::Errno, error_msg}; pub fn execute_check_command() { let target_json_path = create_target_json(); diff --git a/osdk/src/commands/clippy.rs b/osdk/src/commands/clippy.rs index 332054237..018ee374e 100644 --- a/osdk/src/commands/clippy.rs +++ b/osdk/src/commands/clippy.rs @@ -3,9 +3,7 @@ use std::process; use super::utils::{cargo, COMMON_CARGO_ARGS}; -use crate::{ - error_msg, commands::utils::create_target_json, error::Errno, error_msg, utils::get_cargo_metadata, -}; +use crate::{commands::utils::create_target_json, error::Errno, error_msg}; pub fn execute_clippy_command() { let target_json_path = create_target_json(); diff --git a/osdk/src/commands/mod.rs b/osdk/src/commands/mod.rs index 97ac6c324..b7d600fec 100644 --- a/osdk/src/commands/mod.rs +++ b/osdk/src/commands/mod.rs @@ -11,6 +11,6 @@ mod test; mod utils; pub use self::{ - check::execute_check_command, clippy::execute_clippy_command, new::execute_new_command, - run::execute_run_command, test::execute_test_command, + build::execute_build_command, check::execute_check_command, clippy::execute_clippy_command, + new::execute_new_command, run::execute_run_command, test::execute_test_command, }; diff --git a/osdk/src/commands/new/mod.rs b/osdk/src/commands/new/mod.rs index ea1afb04f..e7bc92c73 100644 --- a/osdk/src/commands/new/mod.rs +++ b/osdk/src/commands/new/mod.rs @@ -1,14 +1,19 @@ // SPDX-License-Identifier: MPL-2.0 -use std::path::{Path, PathBuf}; -use std::str::FromStr; -use std::{fs, process}; -use std::ffi::OsStr; +use std::{ + ffi::OsStr, + fs, + path::{Path, PathBuf}, + process, + str::FromStr, +}; -use crate::cli::NewArgs; -use crate::error::Errno; -use crate::error_msg; -use crate::utils::{cargo_new_lib, get_cargo_metadata, ASTER_FRAME_DEP, KTEST_DEP}; +use crate::{ + cli::NewArgs, + error::Errno, + error_msg, + utils::{cargo_new_lib, get_cargo_metadata, ASTER_FRAME_DEP, KTEST_DEP}, +}; pub fn execute_new_command(args: &NewArgs) { cargo_new_lib(&args.crate_name); @@ -51,7 +56,7 @@ fn add_manifest_dependencies(cargo_metadata: &serde_json::Value, crate_name: &st let exclude = toml::Table::from_str(r#"exclude = ["target/osdk/base"]"#).unwrap(); manifest.insert("workspace".to_string(), toml::Value::Table(exclude)); } - + let content = toml::to_string(&manifest).unwrap(); fs::write(mainfest_path, content).unwrap(); } @@ -70,7 +75,9 @@ fn create_osdk_manifest(cargo_metadata: &serde_json::Value) { // Create `OSDK.toml` for the workspace // FIXME: we need ovmf for grub-efi, the user may not have it. // The apt OVMF repo installs to `/usr/share/OVMF` - fs::write(osdk_manifest_path, r#" + fs::write( + osdk_manifest_path, + r#" [boot] ovmf = "/usr/share/OVMF" [qemu] @@ -85,7 +92,9 @@ args = [ "-display none", "-device isa-debug-exit,iobase=0xf4,iosize=0x04", ] -"#).unwrap(); +"#, + ) + .unwrap(); } /// Write the default content of `src/kernel.rs`, with contents in provided template. diff --git a/osdk/src/commands/run.rs b/osdk/src/commands/run.rs index a65d4bb91..7fa683dc6 100644 --- a/osdk/src/commands/run.rs +++ b/osdk/src/commands/run.rs @@ -1,10 +1,10 @@ // SPDX-License-Identifier: MPL-2.0 -use crate::config_manager::{BuildConfig, RunConfig}; -use crate::utils::{get_current_crate_info, get_target_directory}; - -use super::build::create_base_and_build; -use super::utils::DEFAULT_TARGET_RELPATH; +use super::{build::create_base_and_build, utils::DEFAULT_TARGET_RELPATH}; +use crate::{ + config_manager::{BuildConfig, RunConfig}, + utils::{get_current_crate_info, get_target_directory}, +}; pub fn execute_run_command(config: &RunConfig) { let osdk_target_directory = get_target_directory().join(DEFAULT_TARGET_RELPATH); diff --git a/osdk/src/commands/test.rs b/osdk/src/commands/test.rs index 11def4698..22ad27710 100644 --- a/osdk/src/commands/test.rs +++ b/osdk/src/commands/test.rs @@ -2,12 +2,12 @@ use std::fs; -use crate::base_crate::new_base_crate; -use crate::config_manager::{BuildConfig, RunConfig, TestConfig}; -use crate::utils::{get_current_crate_info, get_target_directory}; - -use super::build::do_build; -use super::utils::DEFAULT_TARGET_RELPATH; +use super::{build::do_build, utils::DEFAULT_TARGET_RELPATH}; +use crate::{ + base_crate::new_base_crate, + config_manager::{BuildConfig, RunConfig, TestConfig}, + utils::{get_current_crate_info, get_target_directory}, +}; pub fn execute_test_command(config: &TestConfig) { let current_crate = get_current_crate_info(); diff --git a/osdk/src/commands/utils.rs b/osdk/src/commands/utils.rs index 85bd60c6d..f9ecb82cf 100644 --- a/osdk/src/commands/utils.rs +++ b/osdk/src/commands/utils.rs @@ -1,10 +1,6 @@ // SPDX-License-Identifier: MPL-2.0 -use std::{ - fs, - path::{Path, PathBuf}, - process::Command, -}; +use std::{fs, path::PathBuf, process::Command}; use crate::utils::get_target_directory; diff --git a/osdk/src/config_manager/manifest.rs b/osdk/src/config_manager/manifest.rs index 45150f5f5..e20572744 100644 --- a/osdk/src/config_manager/manifest.rs +++ b/osdk/src/config_manager/manifest.rs @@ -1,7 +1,9 @@ // SPDX-License-Identifier: MPL-2.0 -use std::path::{Path, PathBuf}; -use std::process; +use std::{ + path::{Path, PathBuf}, + process, +}; use regex::Regex; use serde::Deserialize; diff --git a/osdk/src/test/config_manager/manifest.rs b/osdk/src/test/config_manager/manifest.rs index 6bf27932f..b691ac110 100644 --- a/osdk/src/test/config_manager/manifest.rs +++ b/osdk/src/test/config_manager/manifest.rs @@ -9,7 +9,7 @@ use crate::{ cli::CargoArgs, config_manager::{ get_feature_strings, - manifest::{OsdkManifest, TomlManifest, FEATURE_REGEX}, + manifest::{OsdkManifest, TomlManifest, SELECT_REGEX}, }, test::utils::{assert_success, cargo_osdk, create_workspace}, }; diff --git a/osdk/src/utils.rs b/osdk/src/utils.rs index 6005f94f4..ac965d252 100644 --- a/osdk/src/utils.rs +++ b/osdk/src/utils.rs @@ -1,6 +1,10 @@ // SPDX-License-Identifier: MPL-2.0 -use std::{ffi::OsStr, path::{Path, PathBuf}, process::Command}; +use std::{ + ffi::OsStr, + path::{Path, PathBuf}, + process::Command, +}; use crate::{error::Errno, error_msg}; diff --git a/services/libs/comp-sys/component-macro/src/priority.rs b/services/libs/comp-sys/component-macro/src/priority.rs index f93791e0e..9be7345f6 100644 --- a/services/libs/comp-sys/component-macro/src/priority.rs +++ b/services/libs/comp-sys/component-macro/src/priority.rs @@ -1,6 +1,9 @@ // SPDX-License-Identifier: MPL-2.0 -use std::{collections::HashMap, fs::File, io::Read, ops::Add, path::PathBuf, process::Command, str::FromStr}; +use std::{ + collections::HashMap, fs::File, io::Read, ops::Add, path::PathBuf, process::Command, + str::FromStr, +}; use json::JsonValue; use proc_macro2::{Group, TokenStream}; @@ -88,7 +91,11 @@ pub fn component_generate() -> Vec { }; let component_info = ComponentInfo { name: package["name"].as_str().unwrap().to_string(), - path: PathBuf::from(&workspace_root).join(path).to_str().unwrap().to_string(), + path: PathBuf::from(&workspace_root) + .join(path) + .to_str() + .unwrap() + .to_string(), priority: *mapping .get(&package["name"].as_str().unwrap().to_string()) .unwrap(), diff --git a/tools/format_all.sh b/tools/format_all.sh index c040c25b9..7a2d1615b 100755 --- a/tools/format_all.sh +++ b/tools/format_all.sh @@ -38,7 +38,7 @@ for CRATE in $EXCLUDED_CRATES; do # is not currently in use or under development. case "$CRATE" in *cargo-component*) - continue + continue ;; esac @@ -52,4 +52,3 @@ for CRATE in $EXCLUDED_CRATES; do echo "Directory for crate $CRATE does not exist" fi done -