浏览代码

bugfix: 修复dadk文件的env字段为空的时候,DADK_CURRENT_BUILD_DIR环境变量不会被设置的问题 (#20)

* bugfix: 修复dadk文件的env字段为空的时候,DADK_CURRENT_BUILD_DIR环境变量不会被设置的问题
LoGin 1 年之前
父节点
当前提交
a9a95a9a13
共有 3 个文件被更改,包括 8 次插入9 次删除
  1. 1 1
      Cargo.toml
  2. 6 7
      src/executor/mod.rs
  3. 1 1
      src/executor/source.rs

+ 1 - 1
Cargo.toml

@@ -1,7 +1,7 @@
 [package]
 name = "dadk"
 authors = ["longjin <longjin@DragonOS.org>", "chikejian <chikejian@DragonOS.org>"]
-version = "0.1.5"
+version = "0.1.6"
 edition = "2021"
 description = "DragonOS Application Development Kit\nDragonOS应用开发工具"
 license = "GPL-2.0-only"

+ 6 - 7
src/executor/mod.rs

@@ -325,6 +325,7 @@ impl Executor {
         }
         drop(env_list);
         for (key, value) in self.local_envs.envs.iter() {
+            debug!("Local env found: {}={}", key, value.value);
             command.env(key, value.value.clone());
         }
 
@@ -338,14 +339,12 @@ impl Executor {
 
         let binding = self.entity.task();
         let task_envs: Option<&Vec<TaskEnv>> = binding.envs.as_ref();
-        if task_envs.is_none() {
-            return Ok(());
-        }
 
-        let task_envs = task_envs.unwrap();
-        for tv in task_envs.iter() {
-            self.local_envs
-                .add(EnvVar::new(tv.key().to_string(), tv.value().to_string()));
+        if let Some(task_envs) = task_envs {
+            for tv in task_envs.iter() {
+                self.local_envs
+                    .add(EnvVar::new(tv.key().to_string(), tv.value().to_string()));
+            }
         }
 
         // 添加`DADK_CURRENT_BUILD_DIR`环境变量,便于构建脚本把构建结果拷贝到这里

+ 1 - 1
src/executor/source.rs

@@ -427,7 +427,7 @@ impl ArchiveSource {
             })?
         {
             //如果source文件夹非空,就直接使用,不再重复下载压缩文件,这里可以考虑加入交互
-            info!("Source files already exist. Using previous source file cache. You should clean {:?} before re-download the archive ",target_dir);
+            info!("Source files already exist. Using previous source file cache. You should clean {:?} before re-download the archive ", target_dir.path);
             return Ok(());
         }