Browse Source

refactor: 删除rust_target字段 (#83)

LoGin 4 months ago
parent
commit
a013ae121c

+ 0 - 1
dadk-user/src/lib.rs

@@ -108,7 +108,6 @@ pub mod context;
 pub mod executor;
 pub mod parser;
 mod scheduler;
-pub mod static_resources;
 mod utils;
 
 pub fn dadk_user_main(context: DadkUserExecuteContext) {

+ 0 - 49
dadk-user/src/static_resources/mod.rs

@@ -1,49 +0,0 @@
-use std::sync::Mutex;
-
-use log::error;
-
-use crate::executor::ExecutorError;
-
-lazy_static! {
-    // 全局内置target
-    pub static ref INLINE_TARGETS: Mutex<InlineTargets> = Mutex::new(InlineTargets::new());
-}
-
-/// #内置target
-pub struct InlineTargets {
-    /// 内置target文件列表
-    inline_list: Vec<(String, &'static [u8])>,
-}
-
-impl InlineTargets {
-    pub fn new() -> InlineTargets {
-        let mut inline_targets = InlineTargets {
-            inline_list: Vec::new(),
-        };
-        inline_targets.init();
-        return inline_targets;
-    }
-
-    pub fn init(&mut self) {
-        // 后续如果有新的内置target文件,只需要在inline_list中加入(目标三元组,binary数据)
-        let x86_64_unknown_dragonos: &'static [u8] =
-            include_bytes!("targets/rust/x86_64-unknown-dragonos.json");
-        self.inline_list.push((
-            "x86_64-unknown-dragonos".to_string(),
-            x86_64_unknown_dragonos,
-        ));
-    }
-
-    pub fn get(&self, rust_target: &str) -> Result<&'static [u8], ExecutorError> {
-        // 通过rust_target找到对应的binary数据
-        for (name, data) in &self.inline_list {
-            if name == rust_target {
-                return Ok(data);
-            }
-        }
-
-        let errmsg = format!("无效的内置target文件: {}", rust_target);
-        error!("{errmsg}");
-        return Err(ExecutorError::PrepareEnvError(errmsg));
-    }
-}

+ 0 - 35
dadk-user/src/static_resources/targets/rust/x86_64-unknown-dragonos.json

@@ -1,35 +0,0 @@
-{
-  "arch": "x86_64",
-  "code-model": "kernel",
-  "cpu": "x86-64",
-  "os": "dragonos",
-  "target-endian": "little",
-  "target-pointer-width": "64",
-  "target-family": [
-      "unix"
-  ],
-  "env": "musl",
-  "target-c-int-width": "32",
-  "data-layout": "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128",
-  "disable-redzone": true,
-  "features": "-3dnow,-3dnowa,-avx,-avx2",
-  "linker": "rust-lld",
-  "linker-flavor": "ld.lld",
-  "llvm-target": "x86_64-unknown-none",
-  "max-atomic-width": 64,
-  "panic-strategy": "abort",
-  "position-independent-executables": true,
-  "relro-level": "full",
-  "stack-probes": {
-      "kind": "inline-or-call",
-      "min-llvm-version-for-inline": [
-          16,
-          0,
-          0
-      ]
-  },
-  "static-position-independent-executables": true,
-  "supported-sanitizers": [
-      "kcfi"
-  ]
-}

+ 0 - 1
tests/data/dadk_config_v1/app_all_target_arch_0_1_0.dadk

@@ -2,7 +2,6 @@
   "name": "app_all_target_arch_0_1_0",
   "version": "0.1.0",
   "description": "An app targets to all arch",
-  "rust_target": null,
   "task_type": {
     "BuildFromSource": {
       "Git": {

+ 0 - 1
tests/data/dadk_config_v1/app_normal_0_1_0.dadk

@@ -2,7 +2,6 @@
   "name": "app_normal",
   "version": "0.1.0",
   "description": "A normal app",
-  "rust_target": null,
   "task_type": {
     "BuildFromSource": {
       "Local": {

+ 0 - 1
tests/data/dadk_config_v1/app_normal_with_env_0_1_0.dadk

@@ -2,7 +2,6 @@
   "name": "app_normal_with_env",
   "version": "0.1.0",
   "description": "A normal app with env",
-  "rust_target": null,
   "task_type": {
     "BuildFromSource": {
       "Local": {

+ 0 - 1
tests/data/dadk_config_v1/app_normal_with_env_fail_0_1_0.dadk

@@ -2,7 +2,6 @@
   "name": "app_normal_with_env_fail",
   "version": "0.1.0",
   "description": "A normal app with env which should failed",
-  "rust_target": null,
   "task_type": {
     "BuildFromSource": {
       "Local": {

+ 0 - 1
tests/data/dadk_config_v1/app_target_arch_empty_should_fail_0_1_0.dadk

@@ -2,7 +2,6 @@
   "name": "app_target_arch_empty_should_fail",
   "version": "0.1.0",
   "description": "An app targets empty, which should failed when parsing",
-  "rust_target": null,
   "task_type": {
     "BuildFromSource": {
       "Git": {

+ 0 - 1
tests/data/dadk_config_v1/app_target_arch_riscv64_only_0_1_0.dadk

@@ -2,7 +2,6 @@
   "name": "app_target_arch_riscv64_only",
   "version": "0.1.0",
   "description": "An app only target to riscv64",
-  "rust_target": null,
   "task_type": {
     "BuildFromSource": {
       "Git": {

+ 0 - 1
tests/data/dadk_config_v1/app_target_arch_x86_64_0_1_0.dadk

@@ -2,7 +2,6 @@
   "name": "app_target_arch_x86_64",
   "version": "0.1.0",
   "description": "An app targets x86_64",
-  "rust_target": null,
   "task_type": {
     "BuildFromSource": {
       "Git": {

+ 0 - 1
tests/data/dadk_config_v1/app_target_arch_x86_64_only_0_1_0.dadk

@@ -2,7 +2,6 @@
   "name": "app_target_arch_x86_64_only",
   "version": "0.1.0",
   "description": "An app only target to x86_64",
-  "rust_target": null,
   "task_type": {
     "BuildFromSource": {
       "Git": {

+ 0 - 1
tests/data/dadk_config_v1/app_target_arch_x86_64_uppercase_0_1_0.dadk

@@ -2,7 +2,6 @@
   "name": "app_target_arch_x86_64_uppercase",
   "version": "0.1.0",
   "description": "An app targets x86_64(upper case and empty space)",
-  "rust_target": null,
   "task_type": {
     "BuildFromSource": {
       "Git": {