1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
extern crate config;

use igloo_base::*;
use igloo_base::IglooErrType::*;
use config::Config;

#[cfg(test)]
mod tests {
    #[test]
    fn it_works() {
        assert_eq!(2 + 2, 4);
    }
}

/// Igloo Manifest -- Responsible for all lookups in manifest files
pub fn get_master_make_manifest(man: &mut Config) -> IglooErrType
{
	let mut ret: IglooErrType = ErrNone;
	match man.merge(
		config::File::with_name(
			IglooEnvInfo::get_env_info().esfd.join("manifest/make-manifest.toml")
				.to_str()
				.unwrap()))
	{
		Ok(_v) => (),
		Err(e) =>
		{
			println!("Error: {:?}", e);
			ret = FailedToLoadMasterMakeManifest;
		}
	}

	ret
}

pub fn get_master_target_manifest(man: &mut Config) -> IglooErrType
{
	let mut ret: IglooErrType = ErrNone;
	match man.merge(
		config::File::with_name(
			IglooEnvInfo::get_env_info().esfd.join("manifest/target-manifest.toml")
				.to_str()
				.unwrap()))
	{
		Ok(_v) => (),
		Err(e) =>
		{
			println!("Error: {:?}", e);
			ret = FailedToLoadMasterTargetManifest;
		}
	}

	ret
}
/// 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)
					 -> Result<bool, IglooErrType>
{
	let mut ret: bool = true;
	if name.is_empty()
	{
		return Err(InvalidTarget)
	}

	match master_tm.get_table("target.make")
	{
		Ok(v) =>
		{
			match v.get(name)
			{
				Some(v) =>
				{
					println!("target.make entry for \"{}\" exists!", v);
				}
				None =>
				{
					println!("target.make entry for \"{}\" does not exist", name);
					ret = false;
				}
			}

		}
		Err(e) =>
		{
			println!("{:?}", e);
			return Err(FailedToLoadMasterMakeManifest)
		}
	}

	if !ret
	{
		return Ok(ret)
	}

	let target_table = master_tm.get_table("target.manifest");
	match target_table
	{
		Ok(v) =>
		{
			match v.get(name)
			{
				Some(v) =>
				{
					println!("target.manifest entry for \"{}\" exists!", v);
				}
				None =>
				{
					ret = false;
				}
			}
		}
		Err(e) =>
		{
			println!("{:?}", e);
			return Err(FailedToLoadMasterTargetManifest)
		}
	}

	Ok(ret)
}