From 3f638f64757828fe9e7495608de575c045bda95c Mon Sep 17 00:00:00 2001 From: Penguin Date: Sat, 18 Dec 2021 21:23:38 -0600 Subject: [PATCH] beginning rewrite --- igloo_agent/src/lib.rs | 6 +++- igloo_core/src/igloo_action.rs | 18 ++--------- igloo_core/src/igloo_project.rs | 20 ++++++++++++ igloo_core/src/lib.rs | 40 ------------------------ igloo_manifest/src/.#lib.rs | 1 + igloo_manifest/src/lib.rs | 54 ++------------------------------- 6 files changed, 31 insertions(+), 108 deletions(-) create mode 120000 igloo_manifest/src/.#lib.rs diff --git a/igloo_agent/src/lib.rs b/igloo_agent/src/lib.rs index 2364926..1da55a3 100644 --- a/igloo_agent/src/lib.rs +++ b/igloo_agent/src/lib.rs @@ -45,7 +45,7 @@ fn gdb_thread(sender: &Sender, child: std::process::Child) } } -fn start_openocd_listener(sender: Sender, board_cfg_file: &str) +fn start_openocd_listener(sender: Sender, target: &igloo_target::IglooTarget) { let child = Command::new("openocd") .args(["-f", board_cfg_file]) @@ -60,5 +60,9 @@ fn start_openocd_listener(sender: Sender, board_cfg_file: &str) fn ia_push(target: &igloo_target::IglooTarget) -> Result { + let (oo_tx, oo_rx) = channel(); + start_openocd_listener(oo_tx, target); + let (gdb_tx, gdb_rx) = channel(); + Ok(String::from("working")) } diff --git a/igloo_core/src/igloo_action.rs b/igloo_core/src/igloo_action.rs index 32846a5..7b75c89 100644 --- a/igloo_core/src/igloo_action.rs +++ b/igloo_core/src/igloo_action.rs @@ -4,7 +4,7 @@ use igloo_base::IglooErrType::*; use crate::Igloo; use crate::igloo_project::IglooPrj; -pub fn run(prj_name: &str, target: &str) -> IglooErrType +pub fn iac_run(prj_name: &str, target: &str) -> IglooErrType { let res_err: IglooErrType = ErrNone; res_err @@ -52,21 +52,7 @@ pub fn new(inst: &Igloo, prj_name: &str, target: &str) res_err } -pub fn add_target(inst: &Igloo, prj_name: &str, target: &str) -> IglooErrType +pub fn push(inst: &Igloo) { - let mut res_err: IglooErrType = ErrNone; - - loop {{ - // Verify that we are inside of an igloo project - if !IglooPrj::is_igloo_prj(&std::env::current_dir().unwrap()) - { - res_err = ActionCalledOutsideProject; - break; - } - - }break;} - - - return res_err } diff --git a/igloo_core/src/igloo_project.rs b/igloo_core/src/igloo_project.rs index 1c7730e..e6e36cc 100644 --- a/igloo_core/src/igloo_project.rs +++ b/igloo_core/src/igloo_project.rs @@ -1,6 +1,7 @@ use igloo_base::*; use igloo_base::IglooErrType::*; use igloo_manifest::*; +use config::Config; use crate::Igloo; use crate::igloo_target::IglooTarget; @@ -9,6 +10,7 @@ use std::fs::File; use std::vec::Vec; use std::io::prelude::*; use std::path::PathBuf; +use std::collections::HashMap; // New Project // --- Verify location // --- Populate base folders @@ -111,6 +113,7 @@ impl IglooPrj &_targ_manifest_file_name).unwrap(); targetbank.push(targ); + println!("{:?}", targ); } break;} @@ -129,6 +132,23 @@ impl IglooPrj }) } + /// takes the cwd and turns the .igloo/ and .igloo.toml into the project + /// in memory + pub fn from_here() -> Result + { + let mut res = IglooErrType::ErrNone; + + // get project name and target(s) + let mut prj_file = config::Config::default(); + prj_file.merge(config::File::with_name(".igloo")).unwrap(); + let mut prj_name = prj_file.deserialize::>().unwrap(); + println!("This projects name is {:?}", prj_name); + + + Err(IglooErrType::ErrUnknown) + + } + pub fn populate(&self) -> IglooErrType { diff --git a/igloo_core/src/lib.rs b/igloo_core/src/lib.rs index 97e700e..18d038a 100644 --- a/igloo_core/src/lib.rs +++ b/igloo_core/src/lib.rs @@ -30,7 +30,6 @@ mod tests { pub struct Igloo { cli_conf: IglooCliConfig, - master_make_man: Config, master_target_man: Config, } @@ -46,7 +45,6 @@ impl Igloo { Igloo { - master_make_man: Config::new(), master_target_man: Config::new(), cli_conf: IglooCliConfig::new(), } @@ -61,16 +59,6 @@ impl Igloo pub fn start(&mut self) -> Result { let mut res: IglooInstType = Null; - // Load manifests first - match IglooManifest::get_master_make_manifest(&mut self.master_make_man) - { - ErrNone => (), - v => - { - println!("{:?}", v); - return Err(v) - } - } match IglooManifest::get_master_target_manifest(&mut self.master_target_man) { ErrNone => (), @@ -131,10 +119,7 @@ impl Igloo } Push => { - if IglooPrj::is_igloo_prj(&std::env::current_dir().unwrap()) - { - } } Run => { @@ -156,31 +141,6 @@ impl Igloo } Target => { - let tar_sub = self.cli_conf.raw.subcommand().unwrap(); - match &tar_sub.1.subcommand_name() - { - Some("add") => - { - println!("Attempting to add target \"{0}\"", - tar_sub.1 - .subcommand() - .unwrap().1 - .value_of("target_name") - .unwrap()); - - } - Some("remove") => - { - println!("Attempting to remove target \"{0}\"", - tar_sub.1 - .subcommand() - .unwrap().1 - .value_of("target_name") - .unwrap()); - } - None => unreachable!(), - _ => unreachable!(), - } } _ => println!("Unhandled case: {:?}", inst_type), } break; } diff --git a/igloo_manifest/src/.#lib.rs b/igloo_manifest/src/.#lib.rs new file mode 120000 index 0000000..5be521c --- /dev/null +++ b/igloo_manifest/src/.#lib.rs @@ -0,0 +1 @@ +penguin@gpenguin.3110:1639883851 \ No newline at end of file diff --git a/igloo_manifest/src/lib.rs b/igloo_manifest/src/lib.rs index f90ca58..8cb05ce 100644 --- a/igloo_manifest/src/lib.rs +++ b/igloo_manifest/src/lib.rs @@ -21,7 +21,7 @@ pub mod IglooManifest /// master_mm -- Master Make Manifest /// master_tm -- Master Target Manifest /// name -- name of target - pub fn target_is_valid(master_mm: &Config, master_tm: &Config, name: &str) + pub fn target_is_valid(master_tm: &Config, name: &str) -> Result { let mut ret: bool = true; @@ -30,7 +30,7 @@ pub mod IglooManifest return Err(InvalidTarget) } - let mut target_make_name: String = String::default(); + let mut target_man_path: String = String::default(); // Confirm the target.make table exists in the master target manifest match master_tm.get_table("target.make") { @@ -46,7 +46,7 @@ pub mod IglooManifest // Now we've confirmed the target has an entry in the target.make table println!("target.make entry for \"{}\" exists!", v); // store the target's full name for use in the master make manifest later - target_make_name = v.to_string(); + target_man_path = v.to_string(); } None => { @@ -94,54 +94,6 @@ pub mod IglooManifest return Err(FailedToLoadMasterTargetManifest) } } - - // Now confirm the target has an entry in the master make manifest - // strip the name for usable pieces of information - let (dummy, arch, family, mcu_name) = sscanf::scanf!( - target_make_name, "{}.{}.{}.{}", String, String, String, String).unwrap(); - // verify an entry exists for the arch - match master_mm.get_table(&format!("{}.{}", dummy, arch)) - { - Ok(_v) => - { - println!("Make parameters found for arch"); - } - Err(e) => - { - println!("Make parameters not found: {}", e); - ret = false; - } - } - - // verify an entry exists for the mcu family - // later this will be family, then series, then mcu - match master_mm.get_table(&format!("{}.{}.{}", dummy, arch, family)) - { - Ok(_v) => - { - println!("Make parameters found for mcu family"); - } - Err(e) => - { - println!("Make parameters not found: {}", e); - ret = false; - } - } - - // finally, ver - match master_mm.get_table(&format!("{}.{}.{}.{}", dummy, arch, family, mcu_name)) - { - Ok(_v) => - { - println!("Make parameters found for mcu family"); - } - Err(e) => - { - println!("Make parameters not found: {}", e); - ret = false; - } - } - Ok(ret) }