mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-21 00:06:34 +00:00
Apply the new format policy
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
60e996ea2f
commit
3494bc45af
@ -130,10 +130,11 @@ pub fn call_aster_main() -> ! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn run_ktests(test_whitelist: Option<&[&str]>, crate_whitelist: Option<&[&str]>) -> ! {
|
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 alloc::{boxed::Box, string::ToString};
|
||||||
use core::any::Any;
|
use core::any::Any;
|
||||||
|
|
||||||
|
use crate::arch::qemu::{exit_qemu, QemuExitCode};
|
||||||
|
|
||||||
let fn_catch_unwind = &(unwinding::panic::catch_unwind::<(), fn()>
|
let fn_catch_unwind = &(unwinding::panic::catch_unwind::<(), fn()>
|
||||||
as fn(fn()) -> Result<(), Box<(dyn Any + Send + 'static)>>);
|
as fn(fn()) -> Result<(), Box<(dyn Any + Send + 'static)>>);
|
||||||
|
|
||||||
|
@ -7,8 +7,9 @@ pub type Result<T> = core::result::Result<T, crate::error::Error>;
|
|||||||
pub(crate) use alloc::{boxed::Box, sync::Arc, vec::Vec};
|
pub(crate) use alloc::{boxed::Box, sync::Arc, vec::Vec};
|
||||||
pub(crate) use core::any::Any;
|
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 aster_main::aster_main;
|
||||||
|
|
||||||
|
pub use crate::{
|
||||||
|
early_print as print, early_println as println,
|
||||||
|
vm::{Paddr, Vaddr},
|
||||||
|
};
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
//! Test runner enabling control over the tests.
|
//! 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 core::format_args;
|
||||||
|
|
||||||
use owo_colors::OwoColorize;
|
use owo_colors::OwoColorize;
|
||||||
|
@ -4,13 +4,9 @@
|
|||||||
//! It will depend on the kernel crate.
|
//! It will depend on the kernel crate.
|
||||||
//!
|
//!
|
||||||
|
|
||||||
use std::path::Path;
|
use std::{fs, path::Path, process, process::Command, str::FromStr};
|
||||||
use std::process::Command;
|
|
||||||
use std::str::FromStr;
|
|
||||||
use std::{fs, process};
|
|
||||||
|
|
||||||
use crate::error::Errno;
|
use crate::{error::Errno, error_msg};
|
||||||
use crate::error_msg;
|
|
||||||
|
|
||||||
pub fn new_base_crate(
|
pub fn new_base_crate(
|
||||||
base_crate_path: impl AsRef<Path>,
|
base_crate_path: impl AsRef<Path>,
|
||||||
|
@ -1,17 +1,22 @@
|
|||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
use std::path::{Path, PathBuf};
|
use std::{
|
||||||
use std::process::Command;
|
path::{Path, PathBuf},
|
||||||
|
process::Command,
|
||||||
use crate::bin::AsterBin;
|
};
|
||||||
use crate::cli::CargoArgs;
|
|
||||||
use crate::config_manager::{
|
use crate::{
|
||||||
boot::Boot,
|
bin::AsterBin,
|
||||||
qemu::{Qemu, QemuMachine},
|
cli::CargoArgs,
|
||||||
RunConfig,
|
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.
|
/// The osdk bundle artifact that stores as `bundle` directory.
|
||||||
///
|
///
|
||||||
|
@ -1,17 +1,19 @@
|
|||||||
// SPDX-License-Identifier: MPL-2.0
|
// 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::{
|
use std::{
|
||||||
fs::OpenOptions,
|
fs::OpenOptions,
|
||||||
io::{Seek, SeekFrom, Write},
|
io::{Seek, SeekFrom, Write},
|
||||||
|
path::{Path, PathBuf},
|
||||||
|
process::Command,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::bin::{AsterBin, AsterBinType, AsterBzImageMeta, AsterElfMeta};
|
use linux_bzimage_builder::{legacy32_rust_target_json, make_bzimage, BzImageType};
|
||||||
use crate::config_manager::boot::BootProtocol;
|
|
||||||
use crate::utils::get_current_crate_info;
|
use crate::{
|
||||||
|
bin::{AsterBin, AsterBinType, AsterBzImageMeta, AsterElfMeta},
|
||||||
|
config_manager::boot::BootProtocol,
|
||||||
|
utils::get_current_crate_info,
|
||||||
|
};
|
||||||
|
|
||||||
pub fn make_install_bzimage(
|
pub fn make_install_bzimage(
|
||||||
install_dir: impl AsRef<Path>,
|
install_dir: impl AsRef<Path>,
|
||||||
|
@ -1,14 +1,17 @@
|
|||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
use std::fs;
|
use std::{
|
||||||
use std::path::{Path, PathBuf};
|
fs,
|
||||||
|
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 super::bin::make_install_bzimage;
|
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(
|
pub fn create_bootdev_image(
|
||||||
target_dir: impl AsRef<Path>,
|
target_dir: impl AsRef<Path>,
|
||||||
@ -38,12 +41,7 @@ pub fn create_bootdev_image(
|
|||||||
// Make the kernel image and place it in the boot directory.
|
// Make the kernel image and place it in the boot directory.
|
||||||
match protocol {
|
match protocol {
|
||||||
BootProtocol::LinuxLegacy32 | BootProtocol::LinuxEfiHandover64 => {
|
BootProtocol::LinuxLegacy32 | BootProtocol::LinuxEfiHandover64 => {
|
||||||
make_install_bzimage(
|
make_install_bzimage(&iso_root.join("boot"), &target_dir, aster_bin, protocol);
|
||||||
&iso_root.join("boot"),
|
|
||||||
&target_dir,
|
|
||||||
aster_bin,
|
|
||||||
protocol,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
BootProtocol::Multiboot | BootProtocol::Multiboot2 => {
|
BootProtocol::Multiboot | BootProtocol::Multiboot2 => {
|
||||||
// Copy the kernel image to the boot directory.
|
// Copy the kernel image to the boot directory.
|
||||||
|
@ -3,21 +3,25 @@
|
|||||||
mod bin;
|
mod bin;
|
||||||
mod grub;
|
mod grub;
|
||||||
|
|
||||||
use std::path::{Path, PathBuf};
|
use std::{
|
||||||
use std::process;
|
path::{Path, PathBuf},
|
||||||
use std::str::FromStr;
|
process,
|
||||||
|
str::FromStr,
|
||||||
|
};
|
||||||
|
|
||||||
use bin::strip_elf_for_qemu;
|
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 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) {
|
pub fn execute_build_command(config: &BuildConfig) {
|
||||||
let osdk_target_directory = get_target_directory().join(DEFAULT_TARGET_RELPATH);
|
let osdk_target_directory = get_target_directory().join(DEFAULT_TARGET_RELPATH);
|
||||||
|
@ -2,14 +2,8 @@
|
|||||||
|
|
||||||
use std::process;
|
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 super::utils::{cargo, COMMON_CARGO_ARGS};
|
||||||
use crate::{
|
use crate::{commands::utils::create_target_json, error::Errno, error_msg};
|
||||||
commands::utils::create_target_json, error::Errno, error_msg, utils::get_cargo_metadata,
|
|
||||||
};
|
|
||||||
|
|
||||||
pub fn execute_check_command() {
|
pub fn execute_check_command() {
|
||||||
let target_json_path = create_target_json();
|
let target_json_path = create_target_json();
|
||||||
|
@ -3,9 +3,7 @@
|
|||||||
use std::process;
|
use std::process;
|
||||||
|
|
||||||
use super::utils::{cargo, COMMON_CARGO_ARGS};
|
use super::utils::{cargo, COMMON_CARGO_ARGS};
|
||||||
use crate::{
|
use crate::{commands::utils::create_target_json, error::Errno, error_msg};
|
||||||
error_msg, commands::utils::create_target_json, error::Errno, error_msg, utils::get_cargo_metadata,
|
|
||||||
};
|
|
||||||
|
|
||||||
pub fn execute_clippy_command() {
|
pub fn execute_clippy_command() {
|
||||||
let target_json_path = create_target_json();
|
let target_json_path = create_target_json();
|
||||||
|
@ -11,6 +11,6 @@ mod test;
|
|||||||
mod utils;
|
mod utils;
|
||||||
|
|
||||||
pub use self::{
|
pub use self::{
|
||||||
check::execute_check_command, clippy::execute_clippy_command, new::execute_new_command,
|
build::execute_build_command, check::execute_check_command, clippy::execute_clippy_command,
|
||||||
run::execute_run_command, test::execute_test_command,
|
new::execute_new_command, run::execute_run_command, test::execute_test_command,
|
||||||
};
|
};
|
||||||
|
@ -1,14 +1,19 @@
|
|||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
use std::path::{Path, PathBuf};
|
use std::{
|
||||||
use std::str::FromStr;
|
ffi::OsStr,
|
||||||
use std::{fs, process};
|
fs,
|
||||||
use std::ffi::OsStr;
|
path::{Path, PathBuf},
|
||||||
|
process,
|
||||||
|
str::FromStr,
|
||||||
|
};
|
||||||
|
|
||||||
use crate::cli::NewArgs;
|
use crate::{
|
||||||
use crate::error::Errno;
|
cli::NewArgs,
|
||||||
use crate::error_msg;
|
error::Errno,
|
||||||
use crate::utils::{cargo_new_lib, get_cargo_metadata, ASTER_FRAME_DEP, KTEST_DEP};
|
error_msg,
|
||||||
|
utils::{cargo_new_lib, get_cargo_metadata, ASTER_FRAME_DEP, KTEST_DEP},
|
||||||
|
};
|
||||||
|
|
||||||
pub fn execute_new_command(args: &NewArgs) {
|
pub fn execute_new_command(args: &NewArgs) {
|
||||||
cargo_new_lib(&args.crate_name);
|
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();
|
let exclude = toml::Table::from_str(r#"exclude = ["target/osdk/base"]"#).unwrap();
|
||||||
manifest.insert("workspace".to_string(), toml::Value::Table(exclude));
|
manifest.insert("workspace".to_string(), toml::Value::Table(exclude));
|
||||||
}
|
}
|
||||||
|
|
||||||
let content = toml::to_string(&manifest).unwrap();
|
let content = toml::to_string(&manifest).unwrap();
|
||||||
fs::write(mainfest_path, content).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
|
// Create `OSDK.toml` for the workspace
|
||||||
// FIXME: we need ovmf for grub-efi, the user may not have it.
|
// FIXME: we need ovmf for grub-efi, the user may not have it.
|
||||||
// The apt OVMF repo installs to `/usr/share/OVMF`
|
// The apt OVMF repo installs to `/usr/share/OVMF`
|
||||||
fs::write(osdk_manifest_path, r#"
|
fs::write(
|
||||||
|
osdk_manifest_path,
|
||||||
|
r#"
|
||||||
[boot]
|
[boot]
|
||||||
ovmf = "/usr/share/OVMF"
|
ovmf = "/usr/share/OVMF"
|
||||||
[qemu]
|
[qemu]
|
||||||
@ -85,7 +92,9 @@ args = [
|
|||||||
"-display none",
|
"-display none",
|
||||||
"-device isa-debug-exit,iobase=0xf4,iosize=0x04",
|
"-device isa-debug-exit,iobase=0xf4,iosize=0x04",
|
||||||
]
|
]
|
||||||
"#).unwrap();
|
"#,
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Write the default content of `src/kernel.rs`, with contents in provided template.
|
/// Write the default content of `src/kernel.rs`, with contents in provided template.
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
use crate::config_manager::{BuildConfig, RunConfig};
|
use super::{build::create_base_and_build, utils::DEFAULT_TARGET_RELPATH};
|
||||||
use crate::utils::{get_current_crate_info, get_target_directory};
|
use crate::{
|
||||||
|
config_manager::{BuildConfig, RunConfig},
|
||||||
use super::build::create_base_and_build;
|
utils::{get_current_crate_info, get_target_directory},
|
||||||
use super::utils::DEFAULT_TARGET_RELPATH;
|
};
|
||||||
|
|
||||||
pub fn execute_run_command(config: &RunConfig) {
|
pub fn execute_run_command(config: &RunConfig) {
|
||||||
let osdk_target_directory = get_target_directory().join(DEFAULT_TARGET_RELPATH);
|
let osdk_target_directory = get_target_directory().join(DEFAULT_TARGET_RELPATH);
|
||||||
|
@ -2,12 +2,12 @@
|
|||||||
|
|
||||||
use std::fs;
|
use std::fs;
|
||||||
|
|
||||||
use crate::base_crate::new_base_crate;
|
use super::{build::do_build, utils::DEFAULT_TARGET_RELPATH};
|
||||||
use crate::config_manager::{BuildConfig, RunConfig, TestConfig};
|
use crate::{
|
||||||
use crate::utils::{get_current_crate_info, get_target_directory};
|
base_crate::new_base_crate,
|
||||||
|
config_manager::{BuildConfig, RunConfig, TestConfig},
|
||||||
use super::build::do_build;
|
utils::{get_current_crate_info, get_target_directory},
|
||||||
use super::utils::DEFAULT_TARGET_RELPATH;
|
};
|
||||||
|
|
||||||
pub fn execute_test_command(config: &TestConfig) {
|
pub fn execute_test_command(config: &TestConfig) {
|
||||||
let current_crate = get_current_crate_info();
|
let current_crate = get_current_crate_info();
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
use std::{
|
use std::{fs, path::PathBuf, process::Command};
|
||||||
fs,
|
|
||||||
path::{Path, PathBuf},
|
|
||||||
process::Command,
|
|
||||||
};
|
|
||||||
|
|
||||||
use crate::utils::get_target_directory;
|
use crate::utils::get_target_directory;
|
||||||
|
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
use std::path::{Path, PathBuf};
|
use std::{
|
||||||
use std::process;
|
path::{Path, PathBuf},
|
||||||
|
process,
|
||||||
|
};
|
||||||
|
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
@ -9,7 +9,7 @@ use crate::{
|
|||||||
cli::CargoArgs,
|
cli::CargoArgs,
|
||||||
config_manager::{
|
config_manager::{
|
||||||
get_feature_strings,
|
get_feature_strings,
|
||||||
manifest::{OsdkManifest, TomlManifest, FEATURE_REGEX},
|
manifest::{OsdkManifest, TomlManifest, SELECT_REGEX},
|
||||||
},
|
},
|
||||||
test::utils::{assert_success, cargo_osdk, create_workspace},
|
test::utils::{assert_success, cargo_osdk, create_workspace},
|
||||||
};
|
};
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
// SPDX-License-Identifier: MPL-2.0
|
// 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};
|
use crate::{error::Errno, error_msg};
|
||||||
|
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
// SPDX-License-Identifier: MPL-2.0
|
// 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 json::JsonValue;
|
||||||
use proc_macro2::{Group, TokenStream};
|
use proc_macro2::{Group, TokenStream};
|
||||||
@ -88,7 +91,11 @@ pub fn component_generate() -> Vec<ComponentInfo> {
|
|||||||
};
|
};
|
||||||
let component_info = ComponentInfo {
|
let component_info = ComponentInfo {
|
||||||
name: package["name"].as_str().unwrap().to_string(),
|
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
|
priority: *mapping
|
||||||
.get(&package["name"].as_str().unwrap().to_string())
|
.get(&package["name"].as_str().unwrap().to_string())
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
|
@ -38,7 +38,7 @@ for CRATE in $EXCLUDED_CRATES; do
|
|||||||
# is not currently in use or under development.
|
# is not currently in use or under development.
|
||||||
case "$CRATE" in
|
case "$CRATE" in
|
||||||
*cargo-component*)
|
*cargo-component*)
|
||||||
continue
|
continue
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
@ -52,4 +52,3 @@ for CRATE in $EXCLUDED_CRATES; do
|
|||||||
echo "Directory for crate $CRATE does not exist"
|
echo "Directory for crate $CRATE does not exist"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user