Browse Source

更新用户配置文件模版

Jomocool 5 months ago
parent
commit
9cd07b5ec9

+ 6 - 0
dadk-config/templates/config/userapp_config.toml

@@ -44,6 +44,12 @@ revision = "01cdc56863"
 # (可选)构建命令
 build-command = "make install"
 
+# (可选)预构建脚本路径
+pre-build = "config/pre_build.sh"
+
+# (可选)构建后脚本路径
+post-build = "config/post_build.sh"
+
 # 安装相关信息
 [install]
 

+ 5 - 1
dadk-config/tests/test_user_config.rs

@@ -51,7 +51,11 @@ fn test_parse_dadk_user_config(ctx: &mut DadkConfigTestContext) {
                 version: "0.1.2".to_string(),
             },
         ],
-        build: BuildConfig::new(Some("make install".to_string()), None, None),
+        build: BuildConfig::new(
+            Some("make install".to_string()),
+            Some(PathBuf::from("config/pre_build.sh")),
+            Some(PathBuf::from("config/post_build.sh")),
+        ),
         install: InstallConfig::new(Some(PathBuf::from("/bin"))),
         clean: CleanConfig::new(Some("make clean".to_string())),
         envs: vec![

+ 6 - 3
dadk-user/src/executor/mod.rs

@@ -199,7 +199,7 @@ impl Executor {
     fn build(&mut self) -> Result<(), ExecutorError> {
         if let Some(status) = self.task_log().build_status() {
             if let Some(build_time) = self.task_log().build_time() {
-                let mut last_modified = last_modified_time(&self.entity.file_path(), build_time)?; 
+                let mut last_modified = last_modified_time(&self.entity.file_path(), build_time)?;
                 last_modified = core::cmp::max(
                     last_modified,
                     last_modified_time(&self.src_work_dir(), build_time)?,
@@ -232,7 +232,7 @@ impl Executor {
             } else {
                 error!("Post-build script failed");
                 return Err(ExecutorError::TaskFailed(
-                    "Post-buildscript failed".to_string(),
+                    "Post-build script failed".to_string(),
                 ));
             }
         }
@@ -280,7 +280,10 @@ impl Executor {
                 }
             }
         }
-        log::trace!("dadk-user: to do install {}", self.entity.task().name_version());
+        log::trace!(
+            "dadk-user: to do install {}",
+            self.entity.task().name_version()
+        );
         return self.do_install();
     }
 

+ 0 - 1
dadk-user/src/parser/mod.rs

@@ -221,7 +221,6 @@ impl Parser {
         // 从toml文件中解析出DADKTask
         let mut task: DADKTask = Self::parse_toml_file(config_file)?;
 
-
         // 去除字符串中的空白字符
         task.trim();