From b7d2f01c109e8b2cba1d1d17397df48325336e88 Mon Sep 17 00:00:00 2001 From: penguin Date: Wed, 21 Oct 2020 14:02:26 -0500 Subject: [PATCH] collection of manifests works --- src/igloo_manifest.rs | 4 +- src/igloo_prj.rs | 126 +++++++++++++++++++++++++++++++++++------- 2 files changed, 109 insertions(+), 21 deletions(-) diff --git a/src/igloo_manifest.rs b/src/igloo_manifest.rs index 61a7410..8b3c522 100644 --- a/src/igloo_manifest.rs +++ b/src/igloo_manifest.rs @@ -11,7 +11,6 @@ pub mod IglooManifest return Err(IglooErrType::IGLOO_INVALID_TARGET) } - let make_table = inst.target_manifest.get_table("target.make"); match make_table { @@ -69,4 +68,7 @@ pub mod IglooManifest Ok(ret) } + + + } diff --git a/src/igloo_prj.rs b/src/igloo_prj.rs index 063705d..c44764b 100644 --- a/src/igloo_prj.rs +++ b/src/igloo_prj.rs @@ -13,7 +13,6 @@ pub struct IglooPrj { name: String, target_bank: Vec, - env_info: IglooEnvInfo, } pub struct IglooTarget @@ -31,7 +30,6 @@ impl IglooPrj { name: String::from(""), target_bank: Vec::default(), - env_info: IglooEnvInfo::info(), } } @@ -39,16 +37,11 @@ impl IglooPrj -> Result { let mut res_err = IglooErrType::IGLOO_ERR_NONE; - loop + if String::from(nameIn).is_empty() { - if String::from(nameIn).is_empty() - { - res_err = IglooErrType::IGLOO_INVALID_PROJECT_NAME; - break; - } - - - break; } + res_err = IglooErrType::IGLOO_INVALID_PROJECT_NAME; + return Err(res_err) + } if res_err != IglooErrType::IGLOO_ERR_NONE { @@ -74,17 +67,29 @@ impl IglooPrj } } + let mut _targ_make_table_name = inst.target_manifest.get_str( + &("target.make.".to_owned() + &targetIn)).unwrap(); + let mut _targ_manifest_file_name = inst.target_manifest.get_str( + &("target.manifest.".to_owned() + &targetIn)).unwrap(); + + let mut temp: Vec = Vec::new(); + let targ = IglooTarget::from( + inst, + targetIn, + &_targ_make_table_name, + &_targ_manifest_file_name).unwrap(); + temp.push(targ); Ok(IglooPrj { name: String::from(nameIn), - target_bank: Vec::new(), - env_info: IglooEnvInfo::info(), + target_bank: temp, }) } pub fn populate(&self) -> IglooErrType { + // Create new directory let mut active_dir = IglooEnvInfo::info().cwd; //println!("Active Directory: {:?}", active_dir.display()); @@ -135,11 +140,11 @@ impl IglooPrj // load targets //create symlinks in ESF - // match std::os::unix::fs::symlink("", "") - // { - // Err(e) => println!("{:?}", e), - // _ => (), - // } + match std::os::unix::fs::symlink("", "") + { + Err(e) => println!("{:?}", e), + _ => (), + } println!("Displaying contents of {:?}", active_dir.display()); for entry in active_dir.read_dir() .unwrap() @@ -148,12 +153,32 @@ impl IglooPrj println!("{:?}", dir.file_name()); } + self.debugManifests(); IglooErrType::IGLOO_ERR_NONE } - pub fn env(self) -> IglooEnvInfo + pub fn debugManifests(&self) { - self.env_info.clone() + for target in &self.target_bank + { + println!("Target manifest:"); + for (key, val) in &target.target_manifest + { + println!("{} = {:?}", key, val); + } + println!("\nMake Manifest:"); + for (key, val) in &target.make_manifest + { + println!("{} = {:?}", key, val); + } + } + } + + /// Generates the target directories for all targets + pub fn gen_targets(&self) -> IglooErrType + { + + IglooErrType::IGLOO_ERR_NONE } } @@ -169,6 +194,67 @@ impl IglooTarget } } + pub fn from(inst: &Igloo, name_in: &str, + target_make_loc: &str, + target_man_loc: &str) -> Result + { + // target man first + let mut target_man = config::Config::new(); + target_man.merge( + config::File::with_name( + IglooEnvInfo::info().esfd.join(target_man_loc) + .to_str().unwrap())) + .unwrap(); + + // now make man + let mut makefile: HashMap = HashMap::new(); + let mut make_table_head = &target_make_loc[0..target_make_loc.len()]; + println!("{}", make_table_head); + let mut b_quit: bool = false; + loop + { + let mut _active_table = inst.make_manifest.get_table(&make_table_head).unwrap(); + for (name, val) in _active_table + { + match val.clone().into_table() + { + Err(_e) => + { + if !makefile.contains_key(&name) + { + makefile.insert(name, val); + } + else + { + let mut newval = val.clone().into_array().unwrap(); + let mut newvec = makefile.get_key_value(&name).unwrap().1.clone().into_array().unwrap(); + newvec.append(&mut newval); + makefile.insert(name, config::Value::from(newvec)); + } + } + Ok(_v) => {} + } + } + match make_table_head.rfind('.') + { + None => b_quit = true, + Some(v) => make_table_head = &make_table_head[0..v], + } + if b_quit + { + break; + } + } + + Ok(IglooTarget + { + name: String::from(name_in), + make_manifest: makefile, + target_manifest: target_man.get_table("esf.links").unwrap(), + + }) + } + }