Skip to content

Commit

Permalink
增加vscode的检查、修正fmt问题 (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
fslongjin authored Sep 28, 2023
1 parent b40b6b4 commit ea33032
Show file tree
Hide file tree
Showing 27 changed files with 39 additions and 78 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/target
Cargo.lock
/DragonReach
/.vscode
16 changes: 16 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"rust-analyzer.check.overrideCommand": [
"cargo",
"+nightly",
"-Z",
"build-std=core,alloc,compiler_builtins",
"check",
"--workspace",
"--message-format=json",
"--target",
"target.json",
],

"rust-analyzer.cargo.target": "x86_64-unknown-dragonos",

}
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ hashbrown = "0.11"
cfg-if = { version = "1.0"}

[target.'cfg(target_os = "dragonos")'.dependencies]
drstd = {git = "https://git.mirrors.dragonos.org/DragonOS-Community/drstd.git", revision = "a5a37880a8"}
drstd = { git = "https://git.mirrors.dragonos.org/DragonOS-Community/drstd.git", rev = "0fe3ff0054" }

lazy_static = { version = "1.4.0", default-features = false, features = ["spin_no_std"] }

[target.'cfg(not(target_os = "dragonos"))'.dependencies]
lazy_static = {version = "1.4.0"}
lazy_static = { version = "1.4.0" }

[profile.release]
panic = 'abort'
Expand Down
19 changes: 13 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
OUTPUT_DIR = $(DADK_BUILD_CACHE_DIR_DRAGONREACH_0_1_0)
REACH_ETC_DIR=$(OUTPUT_DIR)/etc/reach
REACH_BIN_DIR=$(OUTPUT_DIR)/bin/
TMP_INSTALL_DIR=$(OUTPUT_DIR)/tmp_install

build:
cargo -Z build-std=core,alloc,compiler_builtins build --target ./target.json
cargo -Z build-std=core,alloc,compiler_builtins build --target ./target.json --release

install:
cp ./parse_test/shell.service $(ROOT_PATH)/bin/sysroot/etc/reach/system/shell.service
mkdir -p $(TMP_INSTALL_DIR)
mkdir -p $(REACH_ETC_DIR)
mkdir -p $(REACH_ETC_DIR)/system/
mkdir -p $(REACH_BIN_DIR)

mkdir -p $(OUTPUT_DIR)/tmp
cargo -Z build-std=core,alloc,compiler_builtins install --target $(TARGET) --path . --root $(OUTPUT_DIR)/tmp
mv $(OUTPUT_DIR)/tmp/bin/DragonReach $(ROOT_PATH)/bin/user/DragonReach
rm -rf $(OUTPUT_DIR)/tmp
cp ./parse_test/shell.service $(REACH_ETC_DIR)/system/shell.service

cargo -Z build-std=core,alloc,compiler_builtins install --target $(TARGET) --path . --root $(TMP_INSTALL_DIR)
mv $(OUTPUT_DIR)/tmp/bin/DragonReach $(REACH_BIN_DIR)/DragonReach
rm -rf $(TMP_INSTALL_DIR)

build-linux:
cargo -Z build-std=core,alloc,compiler_builtins build --target x86_64-unknown-linux-gnu
Expand Down
2 changes: 2 additions & 0 deletions src/contants.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(dead_code)]

pub const AF_INET: i32 = 2;
pub const AF_INET6: i32 = 10;

Expand Down
3 changes: 0 additions & 3 deletions src/error/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#[cfg(target_os = "dragonos")]
use drstd as std;

pub mod parse_error;
pub mod runtime_error;

Expand Down
2 changes: 0 additions & 2 deletions src/error/parse_error/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#[cfg(target_os = "dragonos")]
use drstd as std;
use std::format;
use std::string::String;
use std::string::ToString;
Expand Down
3 changes: 1 addition & 2 deletions src/error/runtime_error/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use super::ErrorFormat;
#[cfg(target_os = "dragonos")]
use drstd as std;

use std::format;
use std::string::String;

Expand Down
3 changes: 0 additions & 3 deletions src/executor/dep_graph/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#[cfg(target_os = "dragonos")]
use drstd as std;

use std::sync::Arc;
use std::sync::Mutex;
use std::vec::Vec;
Expand Down
3 changes: 0 additions & 3 deletions src/executor/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#[cfg(target_os = "dragonos")]
use drstd as std;

pub mod dep_graph;
pub mod service_executor;

Expand Down
3 changes: 0 additions & 3 deletions src/executor/service_executor/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#[cfg(target_os = "dragonos")]
use drstd as std;

use crate::{
error::runtime_error::{RuntimeError, RuntimeErrorType},
manager::{timer_manager::TimerManager, UnitManager},
Expand Down
16 changes: 3 additions & 13 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,8 @@
#![feature(slice_pattern)]
#![feature(fn_traits)]

use cfg_if::cfg_if;

cfg_if! {
if #[cfg(target_os = "dragonos")]{
extern crate drstd;
use drstd as std;
}
}
#[cfg(target_os = "dragonos")]
extern crate drstd as std;

extern crate hashbrown;

Expand Down Expand Up @@ -41,11 +35,7 @@ fn main() {
use manager::timer_manager::TimerManager;
use parse::UnitParser;

use crate::{
executor::Executor,
manager::{Manager, UnitManager},
parse::parse_util::UnitParseUtil,
};
use crate::{executor::Executor, manager::Manager};

let mut units_file_name = Vec::new();
//读取目录里面的unit文件
Expand Down
3 changes: 0 additions & 3 deletions src/manager/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#[cfg(target_os = "dragonos")]
use drstd as std;

use std::{eprint, eprintln, print, println, vec::Vec};

pub mod timer_manager;
Expand Down
3 changes: 0 additions & 3 deletions src/manager/timer_manager/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#[cfg(target_os = "dragonos")]
use drstd as std;

use crate::{error::runtime_error::RuntimeError, time::timer::Timer};
use lazy_static::lazy_static;
use std::{boxed::Box, sync::RwLock, time::Duration, vec::Vec};
Expand Down
2 changes: 0 additions & 2 deletions src/manager/unit_manager/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#[cfg(target_os = "dragonos")]
use drstd as std;
use std::hash::{Hash, Hasher};
use std::{
collections::hash_map::DefaultHasher,
Expand Down
2 changes: 0 additions & 2 deletions src/parse/graph/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ use crate::{
unit::UnitType,
};

#[cfg(target_os = "dragonos")]
use drstd as std;
use std::io::BufRead;
use std::string::{String, ToString};
use std::vec::Vec;
Expand Down
3 changes: 0 additions & 3 deletions src/parse/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ use crate::{
unit::{service::ServiceUnitAttr, BaseUnitAttr, InstallUnitAttr, UnitType},
};

#[cfg(target_os = "dragonos")]
use drstd as std;

use hashbrown::HashMap;
use lazy_static::lazy_static;
use std::format;
Expand Down
3 changes: 0 additions & 3 deletions src/parse/parse_service/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ use super::parse_util::UnitParseUtil;
use crate::error::parse_error::ParseError;
use crate::manager::UnitManager;

#[cfg(target_os = "dragonos")]
use drstd as std;

use std::string::ToString;

pub struct ServiceParser;
Expand Down
3 changes: 0 additions & 3 deletions src/parse/parse_target/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ use super::parse_util::UnitParseUtil;
use crate::error::parse_error::ParseError;
use crate::manager::UnitManager;

#[cfg(target_os = "dragonos")]
use drstd as std;

use std::string::ToString;

pub struct TargetParser;
Expand Down
3 changes: 0 additions & 3 deletions src/parse/parse_util/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ use crate::{
FileDescriptor,
};

#[cfg(target_os = "dragonos")]
use drstd as std;

use std::{
fs, io::BufRead, os::unix::prelude::PermissionsExt, path::Path, string::String,
string::ToString, vec, vec::Vec,
Expand Down
3 changes: 0 additions & 3 deletions src/task/cmdtask/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#[cfg(target_os = "dragonos")]
use drstd as std;

use std::{eprint, eprintln, print, process::Command, string::String, vec::Vec};

use crate::{
Expand Down
2 changes: 0 additions & 2 deletions src/time/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
#[cfg(target_os = "dragonos")]
use drstd as std;
pub mod timer;
pub mod watchdog;
3 changes: 0 additions & 3 deletions src/time/timer/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#[cfg(target_os = "dragonos")]
use drstd as std;

use std::boxed::Box;
use std::time::{Duration, Instant};
use std::{print, println};
Expand Down
3 changes: 1 addition & 2 deletions src/time/watchdog/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
#[cfg(target_os = "dragonos")]
use drstd as std;

3 changes: 0 additions & 3 deletions src/unit/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ use crate::executor::ExitStatus;
use crate::parse::parse_util::UnitParseUtil;
use crate::parse::Segment;

#[cfg(target_os = "dragonos")]
use drstd as std;

use std::any::Any;
use std::default::Default;
use std::fmt::Debug;
Expand Down
3 changes: 0 additions & 3 deletions src/unit/service/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ use crate::parse::parse_util::UnitParseUtil;
use crate::parse::{Segment, SERVICE_UNIT_ATTR_TABLE};
use crate::task::cmdtask::CmdTask;

#[cfg(target_os = "dragonos")]
use drstd as std;

use std::string::{String, ToString};

use std::vec::Vec;
Expand Down
3 changes: 1 addition & 2 deletions src/unit/target/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ use crate::parse::parse_target::TargetParser;
use crate::parse::Segment;

use core::result::Result::{self, Ok};
#[cfg(target_os = "dragonos")]
use drstd as std;

use std::marker::{Send, Sized, Sync};

#[derive(Debug, Clone, Default)]
Expand Down

0 comments on commit ea33032

Please sign in to comment.