|
|
|
@ -1,5 +1,5 @@
|
|
|
|
|
use crate::igloo::{Igloo, IglooEnvInfo, IglooErrType};
|
|
|
|
|
use crate::igloo_manifest::{IglooManifest};
|
|
|
|
|
use crate::igloo_manifest::IglooManifest;
|
|
|
|
|
use std::collections::HashMap;
|
|
|
|
|
// New Project
|
|
|
|
|
// --- Verify location
|
|
|
|
@ -35,7 +35,7 @@ impl IglooPrj
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn new(nameIn: &str, targetIn: &str, env_infoIn: &IglooEnvInfo)
|
|
|
|
|
pub fn new(inst: &Igloo, nameIn: &str, targetIn: &str)
|
|
|
|
|
-> Result<IglooPrj, IglooErrType>
|
|
|
|
|
{
|
|
|
|
|
let mut res_err = IglooErrType::IGLOO_ERR_NONE;
|
|
|
|
@ -54,6 +54,26 @@ impl IglooPrj
|
|
|
|
|
{
|
|
|
|
|
return Err(res_err)
|
|
|
|
|
}
|
|
|
|
|
match IglooManifest::target_exists(inst, targetIn)
|
|
|
|
|
{
|
|
|
|
|
Ok(v) =>
|
|
|
|
|
{
|
|
|
|
|
if v
|
|
|
|
|
{
|
|
|
|
|
println!("Verified target exists {}", nameIn);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
println!("Couldn't verify target exists {}", nameIn);
|
|
|
|
|
return Err(IglooErrType::IGLOO_INVALID_TARGET)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Err(e) =>
|
|
|
|
|
{
|
|
|
|
|
return Err(e)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Ok(IglooPrj
|
|
|
|
|
{
|
|
|
|
@ -62,6 +82,79 @@ impl IglooPrj
|
|
|
|
|
env_info: IglooEnvInfo::info(),
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn populate(&self) -> IglooErrType
|
|
|
|
|
{
|
|
|
|
|
// Create new directory
|
|
|
|
|
let mut active_dir = IglooEnvInfo::info().cwd;
|
|
|
|
|
//println!("Active Directory: {:?}", active_dir.display());
|
|
|
|
|
println!("NAME: {}", self.name);
|
|
|
|
|
active_dir.push(&self.name);
|
|
|
|
|
match std::fs::create_dir(&active_dir)
|
|
|
|
|
{
|
|
|
|
|
Err(e) => println!("{:?}", e),
|
|
|
|
|
_ => (),
|
|
|
|
|
}
|
|
|
|
|
//println!("Active Directory: {:?}", active_dir.display());
|
|
|
|
|
println!("Creating .igloo dir...");
|
|
|
|
|
match std::fs::create_dir(
|
|
|
|
|
std::path::Path::new(&active_dir)
|
|
|
|
|
.join(".igloo"))
|
|
|
|
|
{
|
|
|
|
|
Err(e) => println!("{:?}", e),
|
|
|
|
|
_ => (),
|
|
|
|
|
}
|
|
|
|
|
match std::fs::create_dir(
|
|
|
|
|
std::path::Path::new(&active_dir)
|
|
|
|
|
.join("src"))
|
|
|
|
|
{
|
|
|
|
|
Err(e) => println!("{:?}", e),
|
|
|
|
|
_ => (),
|
|
|
|
|
}
|
|
|
|
|
match std::fs::create_dir(
|
|
|
|
|
std::path::Path::new(&active_dir)
|
|
|
|
|
.join("inc"))
|
|
|
|
|
{
|
|
|
|
|
Err(e) => println!("{:?}", e),
|
|
|
|
|
_ => (),
|
|
|
|
|
}
|
|
|
|
|
match std::fs::create_dir(
|
|
|
|
|
std::path::Path::new(&active_dir)
|
|
|
|
|
.join("cfg"))
|
|
|
|
|
{
|
|
|
|
|
Err(e) => println!("{:?}", e),
|
|
|
|
|
_ => (),
|
|
|
|
|
}
|
|
|
|
|
match std::fs::create_dir(
|
|
|
|
|
std::path::Path::new(&active_dir)
|
|
|
|
|
.join("ESF"))
|
|
|
|
|
{
|
|
|
|
|
Err(e) => println!("{:?}", e),
|
|
|
|
|
_ => (),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// load targets
|
|
|
|
|
//create symlinks in ESF
|
|
|
|
|
// 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()
|
|
|
|
|
{
|
|
|
|
|
let dir = entry.unwrap();
|
|
|
|
|
println!("{:?}", dir.file_name());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IglooErrType::IGLOO_ERR_NONE
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn env(self) -> IglooEnvInfo
|
|
|
|
|
{
|
|
|
|
|
self.env_info.clone()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl IglooTarget
|
|
|
|
@ -76,16 +169,6 @@ impl IglooTarget
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn from(inst: &Igloo, nameIn: &str) -> Result<IglooTarget, IglooErrType>
|
|
|
|
|
{
|
|
|
|
|
if !IglooManifest::target_exists(inst, nameIn)
|
|
|
|
|
{
|
|
|
|
|
return Err(IglooErrType::IGLOO_INVALID_TARGET)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Ok(IglooTarget::default())
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|