diff --git a/igloo_core/src/.#igloo_action.rs b/igloo_core/src/.#igloo_action.rs new file mode 120000 index 0000000..10026a8 --- /dev/null +++ b/igloo_core/src/.#igloo_action.rs @@ -0,0 +1 @@ +penguin@gpenguin.2954:1640039390 \ No newline at end of file diff --git a/igloo_core/src/.#igloo_project.rs b/igloo_core/src/.#igloo_project.rs new file mode 120000 index 0000000..10026a8 --- /dev/null +++ b/igloo_core/src/.#igloo_project.rs @@ -0,0 +1 @@ +penguin@gpenguin.2954:1640039390 \ No newline at end of file diff --git a/igloo_core/src/igloo_action.rs b/igloo_core/src/igloo_action.rs index aeb0bde..bc14eb2 100644 --- a/igloo_core/src/igloo_action.rs +++ b/igloo_core/src/igloo_action.rs @@ -85,7 +85,7 @@ pub fn ia_new(igloo: &Igloo, project_name: String, initial_target: String) -> Ig return ret } - let created_project = match IglooProject::from_new(igloo, project_name) + let prj = match IglooProject::from_new(igloo, project_name) { Ok(v) => v, Err(e) => diff --git a/igloo_core/src/igloo_env.rs b/igloo_core/src/igloo_env.rs index cd1eb19..1700a71 100644 --- a/igloo_core/src/igloo_env.rs +++ b/igloo_core/src/igloo_env.rs @@ -1,5 +1,7 @@ use crate::{PathBuf, env, UserDirs}; +static PROJECT_CONFIG_FILE_NAME: &str = "igloo.toml"; + #[derive(Debug, PartialEq, Clone)] pub struct IglooEnv { diff --git a/igloo_core/src/igloo_manifest.rs b/igloo_core/src/igloo_manifest.rs index 0c25c70..ef77304 100644 --- a/igloo_core/src/igloo_manifest.rs +++ b/igloo_core/src/igloo_manifest.rs @@ -11,48 +11,53 @@ use crate::IglooType; use crate::IglooType::*; use crate::igloo_target::IglooTarget; - use serde::{Serialize, Deserialize}; use config::Config; -#[derive(Serialize, Deserialize, Debug)] -pub struct IglooProjectManifest +/// IglooTargetManifest - a manifest file locations which contain each target's +/// settings and configuration properties +#[derive(Serialize,Deserialize,Debug)] +pub struct IglooTargetManifest { - name: String, - targets: Vec:: + targets: HashMap::, } -impl IglooProjectManifest +#[derive(Serialize,Deserialize,Debug)] +pub struct IglooMakeManifest { - pub fn default() -> IglooProjectManifest + +} + +impl IglooTargetManifest +{ + pub fn default() -> IglooTargetManifest { - IglooProjectManifest + IglooTargetManifest { - name: String::from(""), - targets: Vec::default(), - + targets: HashMap::new(), } } - pub fn from_project_file(self, igloo: &Igloo) -> Result + pub fn get(igloo: &Igloo) -> Result { - let mut config = config::Config::default(); - config.merge( + let mut target_manifest = config::Config::default(); + target_manifest.merge( config::File::with_name( igloo.env - .cwd + .esfd .clone() - .join("igloo.toml") - .to_str().unwrap())).unwrap(); - - let z = config.deserialize::().unwrap(); - println!("{:?}", z); - - Ok(IglooProjectManifest::default()) + .join("manifest") + .join("target-manifest.toml") + .to_str().unwrap() + )).unwrap(); + let ret = target_manifest.try_into::().unwrap(); + println!("{:?}", ret); + println!("{:?}", ret.targets["samd21j18a"]); + Ok(IglooTargetManifest::default()) } +} + +impl IglooMakeManifest +{ - pub fn to_project_file(self, igloo: &Igloo) -> IglooStatus - { - IglooStatus::IS_GOOD - } } diff --git a/igloo_core/src/igloo_project.rs b/igloo_core/src/igloo_project.rs index f4ac746..beacb83 100644 --- a/igloo_core/src/igloo_project.rs +++ b/igloo_core/src/igloo_project.rs @@ -9,11 +9,84 @@ use crate::IglooStatus::*; use crate::igloo_target::IglooTarget; +use serde::{Serialize, Deserialize}; +use config::Config; + +#[derive(Serialize, Deserialize, Debug)] +pub struct Settings +{ + testvar: String, + profile: Profile, +} + +/// Basic profile settings +#[derive(Serialize, Deserialize, Debug)] +struct Profile +{ + name: String, + targets: Vec:: + +} + +impl Profile +{ + fn default() -> Profile + { + Profile + { + name: String::new(), + targets: Vec::new(), + } + } +} + +impl Settings +{ + pub fn default() -> Settings + { + Settings + { + testvar: String::new(), + profile: Profile::default(), + } + } + pub fn from_project_file(self, igloo: &Igloo) -> Result + { + let mut config = config::Config::default(); + config.merge( + config::File::with_name( + igloo.env + .cwd + .clone() + .join("test") + .join("igloo.toml") + .to_str().unwrap())).unwrap(); + let x = config.try_into::().unwrap(); + println!("{:?}", x); + Ok(x) + + } + + pub fn to_project_file(self, igloo: &Igloo) -> IglooStatus + { + IglooStatus::IS_GOOD + } + + pub fn set_profile_name(&mut self, name: String) + { + self.profile.name = name; + } + + pub fn add_target(&mut self, target_name: String) + { + self.profile.targets.push(target_name); + } +} + pub struct IglooProject<'a> { igloo: &'a Igloo, - name: String, - targets: Vec, + config: Settings, } impl<'a> IglooProject<'a> @@ -23,36 +96,33 @@ impl<'a> IglooProject<'a> IglooProject { igloo: igloo_in, - name: String::new(), - targets: Vec::default(), + config: Settings::default(), } } /// Used to populate an IglooProject from scratch - /// This means we do not yet have any project in storage - /// and we must generate those directories, files, and symlinks - /// and then populate the project in memory + /// This takes input from cli and generates the project in memory pub fn from_new(igloo_in: &'a Igloo, project_name: String) -> Result { + let mut settings = Settings::default(); + settings.set_profile_name(project_name); Ok(IglooProject { - name: ich_new_get_project_name(igloo_in), - /// targets -- a vector of targets added for this project - targets: Vec::default(), igloo: igloo_in, - - - + config: settings, }) } - /// Used to populate an IglooProject from an existing project + /// Used to create an IglooProject from an existing project /// So this will be called when things like /// igloo run, push, pull, erase, etc... are called - pub fn from_existing(igloo: &'a Igloo) -> IglooProject + pub fn from_existing(igloo_in: &'a Igloo) -> Result { - IglooProject::default(igloo) - + Ok(IglooProject + { + igloo: igloo_in, + config: Settings::default().from_project_file(igloo_in).unwrap(), + }) } pub fn is_igloo_prj(path: &std::path::PathBuf) -> bool @@ -68,4 +138,18 @@ impl<'a> IglooProject<'a> } return true } + + /// creates project files + /// including igloo.toml + pub fn generate(self) -> IglooStatus + { + IglooStatus::IS_GOOD + } + + pub fn add_target(&mut self, target: String) -> IglooStatus + { + let mut ret = IS_GOOD; + self.config.add_target(target); + ret + } } diff --git a/igloo_core/src/lib.rs b/igloo_core/src/lib.rs index 307b8c4..2e8c97a 100644 --- a/igloo_core/src/lib.rs +++ b/igloo_core/src/lib.rs @@ -19,6 +19,7 @@ mod igloo_env; use igloo_cli::IglooCliInfo; use igloo_env::IglooEnv; use igloo_project::IglooProject; +use igloo_manifest::IglooTargetManifest; #[derive(Debug)] #[derive(PartialEq)] @@ -61,6 +62,7 @@ use IglooType::*; pub struct Igloo { + master_target_manifest: IglooTargetManifest, cli_info: IglooCliInfo, env: IglooEnv, } @@ -73,6 +75,7 @@ impl Igloo { cli_info: IglooCliInfo::new(), env: IglooEnv::get_env(), + master_target_manifest: IglooTargetManifest::default(), } } @@ -80,6 +83,8 @@ impl Igloo { let mut res: IglooType = IT_NULL; + // get master target manifest + self.master_target_manifest = IglooTargetManifest::get(self).unwrap(); // Assign instance type (new, run, push, etc) igloo_action::igloo_subcommand(&self.cli_info.raw) } diff --git a/test/igloo.toml b/test/igloo.toml new file mode 100644 index 0000000..c58bf45 --- /dev/null +++ b/test/igloo.toml @@ -0,0 +1,4 @@ +testvar = "djskaddfjlka" +[profile] +name = "myproject" +targets = ["samd21j18a"] diff --git a/test/test_target_manifest.toml b/test/target.toml similarity index 100% rename from test/test_target_manifest.toml rename to test/target.toml