collection of manifests works

unstable
penguin 4 years ago
parent e646a85c5e
commit b7d2f01c10

@ -11,7 +11,6 @@ pub mod IglooManifest
return Err(IglooErrType::IGLOO_INVALID_TARGET) return Err(IglooErrType::IGLOO_INVALID_TARGET)
} }
let make_table = inst.target_manifest.get_table("target.make"); let make_table = inst.target_manifest.get_table("target.make");
match make_table match make_table
{ {
@ -69,4 +68,7 @@ pub mod IglooManifest
Ok(ret) Ok(ret)
} }
} }

@ -13,7 +13,6 @@ pub struct IglooPrj
{ {
name: String, name: String,
target_bank: Vec<IglooTarget>, target_bank: Vec<IglooTarget>,
env_info: IglooEnvInfo,
} }
pub struct IglooTarget pub struct IglooTarget
@ -31,7 +30,6 @@ impl IglooPrj
{ {
name: String::from(""), name: String::from(""),
target_bank: Vec::default(), target_bank: Vec::default(),
env_info: IglooEnvInfo::info(),
} }
} }
@ -39,16 +37,11 @@ impl IglooPrj
-> Result<IglooPrj, IglooErrType> -> Result<IglooPrj, IglooErrType>
{ {
let mut res_err = IglooErrType::IGLOO_ERR_NONE; 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;
{ return Err(res_err)
res_err = IglooErrType::IGLOO_INVALID_PROJECT_NAME; }
break;
}
break; }
if res_err != IglooErrType::IGLOO_ERR_NONE 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<IglooTarget> = Vec::new();
let targ = IglooTarget::from(
inst,
targetIn,
&_targ_make_table_name,
&_targ_manifest_file_name).unwrap();
temp.push(targ);
Ok(IglooPrj Ok(IglooPrj
{ {
name: String::from(nameIn), name: String::from(nameIn),
target_bank: Vec::new(), target_bank: temp,
env_info: IglooEnvInfo::info(),
}) })
} }
pub fn populate(&self) -> IglooErrType pub fn populate(&self) -> IglooErrType
{ {
// Create new directory // Create new directory
let mut active_dir = IglooEnvInfo::info().cwd; let mut active_dir = IglooEnvInfo::info().cwd;
//println!("Active Directory: {:?}", active_dir.display()); //println!("Active Directory: {:?}", active_dir.display());
@ -135,11 +140,11 @@ impl IglooPrj
// load targets // load targets
//create symlinks in ESF //create symlinks in ESF
// match std::os::unix::fs::symlink("", "") match std::os::unix::fs::symlink("", "")
// { {
// Err(e) => println!("{:?}", e), Err(e) => println!("{:?}", e),
// _ => (), _ => (),
// } }
println!("Displaying contents of {:?}", active_dir.display()); println!("Displaying contents of {:?}", active_dir.display());
for entry in active_dir.read_dir() for entry in active_dir.read_dir()
.unwrap() .unwrap()
@ -148,12 +153,32 @@ impl IglooPrj
println!("{:?}", dir.file_name()); println!("{:?}", dir.file_name());
} }
self.debugManifests();
IglooErrType::IGLOO_ERR_NONE 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<IglooTarget, IglooErrType>
{
// 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<String, config::Value> = 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(),
})
}
} }

Loading…
Cancel
Save