Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ DADK是一个Rust程序,您可以通过Cargo来安装DADK。
# 从GitHub安装最新版
cargo install --git https://github.com/DragonOS-Community/DADK.git

# 从crates.io下载
cargo install dadk

```

Expand Down
2 changes: 1 addition & 1 deletion dadk-config/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "dadk-config"
version = "0.5.0"
version = "0.5.1"
edition = "2021"
authors = [
"longjin <longjin@DragonOS.org>",
Expand Down
4 changes: 2 additions & 2 deletions dadk-user/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "dadk-user"
version = "0.5.0"
version = "0.5.1"
edition = "2021"
description = "DragonOS Application Development Kit - user prog build"
license = "GPL-2.0-only"
Expand All @@ -9,7 +9,7 @@ license = "GPL-2.0-only"
anyhow = { version = "1.0.100", features = ["std", "backtrace"] }
chrono = { version = "=0.4.35", features = ["serde"] }
clap = { version = "=4.5.20", features = ["derive"] }
dadk-config = { version = "0.5.0", path = "../dadk-config" }
dadk-config = { version = "0.5.1", path = "../dadk-config" }
derive_builder = "0.20.0"
lazy_static = "1.4.0"
log = "0.4.17"
Expand Down
9 changes: 9 additions & 0 deletions dadk-user/src/executor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,10 @@ impl Executor {
fn clean_src(&self) -> Result<(), ExecutorError> {
let cmd: Option<Command> = self.create_command()?;
if cmd.is_none() {
log::warn!(
"{}: No clean command specified, skipping source directory clean.",
self.entity.task().name_version()
);
// 如果这里没有命令,则认为用户不需要在源文件目录执行清理
return Ok(());
}
Expand Down Expand Up @@ -506,6 +510,11 @@ impl Executor {

let raw_cmd = raw_cmd.unwrap();

// 如果命令是空字符串,也返回 None
if raw_cmd.is_empty() {
return Ok(None);
}

let mut command = Command::new("bash");
command.current_dir(self.src_work_dir().unwrap());

Expand Down
71 changes: 68 additions & 3 deletions dadk-user/src/scheduler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use crate::{
executor::Executor,
parser::task::DADKTask,
};
use dadk_config::user::UserCleanLevel;

use self::task_deque::TASK_DEQUE;

Expand Down Expand Up @@ -406,7 +407,10 @@ impl Scheduler {
// 准备全局环境变量
crate::executor::prepare_env(&self.target, &self.context)
.map_err(|e| SchedulerError::RunError(format!("{:?}", e)))?;

log::info!(
"Global environment variables prepared, action: {:?}",
self.action
);
match self.action {
Action::Build | Action::Install => {
self.run_with_topo_sort()?;
Expand Down Expand Up @@ -461,6 +465,11 @@ impl Scheduler {
}

pub fn execute(action: Action, dragonos_dir: PathBuf, entity: Arc<SchedEntity>) {
log::info!(
"Starting task {} with action {:?}",
entity.task().name_version(),
action
);
let mut executor = Executor::new(entity.clone(), action.clone(), dragonos_dir.clone())
.map_err(|e| {
error!(
Expand Down Expand Up @@ -558,8 +567,64 @@ impl Scheduler {
/// 无
pub fn clean_daemon(action: Action, dragonos_dir: PathBuf, r: &mut Vec<Arc<SchedEntity>>) {
let mut guard = TASK_DEQUE.lock().unwrap();
while !guard.queue().is_empty() && !r.is_empty() {
guard.clean_task(action, dragonos_dir.clone(), r.pop().unwrap().clone());
log::info!(
"Starting clean daemon for {} tasks, queue length: {}",
r.len(),
guard.queue().len()
);

// 清理操作不需要拓扑排序,直接处理所有任务
while !r.is_empty() {
let entity = r.pop().unwrap();

// 检查任务是否需要清理
match action {
// Clean(Output) 对所有任务都有效(清理构建输出目录)
Action::Clean(UserCleanLevel::Output) => {
log::info!(
"Adding task {} to clean queue",
entity.task().name_version()
);
guard.clean_task(action, dragonos_dir.clone(), entity.clone());
}
// Clean(InSrc) 和 Clean(All) 需要有源码目录
Action::Clean(_level @ (UserCleanLevel::InSrc | UserCleanLevel::All)) => {
// 判断任务是否有源码目录
// 1. 本地路径的任务(source_path 不为 None)
// 2. git 或 archive 类型的任务(会创建 source_dir)
let has_source_dir = entity.task().source_path().is_some()
|| matches!(
entity.task().task_type,
crate::parser::task::TaskType::BuildFromSource(_)
| crate::parser::task::TaskType::InstallFromPrebuilt(
crate::parser::task::PrebuiltSource::Archive(_)
)
);

if has_source_dir {
log::info!(
"Adding task {} to clean queue",
entity.task().name_version()
);
guard.clean_task(action, dragonos_dir.clone(), entity.clone());
} else {
log::info!(
"Skipping task {} (no source directory to clean)",
entity.task().name_version()
);
}
}

_ => {}
}
}

// 等待所有清理任务完成
while !guard.queue().is_empty() {
guard.queue_mut().retain(|x| !x.is_finished());
if !guard.queue().is_empty() {
std::thread::sleep(std::time::Duration::from_millis(100));
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion dadk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ authors = [
"xuzihao <xuzihao@DragonOS.org>"
]

version = "0.5.0"
version = "0.5.1"
edition = "2021"
description = "DragonOS Application Development Kit\nDragonOS应用开发工具"
license = "GPL-2.0-only"
Expand Down