From 5ca581b4964cc5a37ce257849f6d18cab94ff293 Mon Sep 17 00:00:00 2001 From: penguin Date: Fri, 24 Sep 2021 17:21:37 -0500 Subject: [PATCH] adding the master make check that was previously unimplemented --- Cargo.lock | 9 -- Cargo.toml | 3 +- igloo_base/Cargo.toml | 2 +- igloo_base/src/env_info.rs | 0 igloo_base/src/lib.rs | 2 - igloo_cli/src/lib.rs | 7 +- igloo_core/Cargo.toml | 3 +- igloo_core/src/.#lib.rs | 1 - igloo_core/src/igloo_project.rs | 3 +- igloo_core/src/lib.rs | 22 ++-- igloo_make/Cargo.toml | 10 -- igloo_make/src/lib.rs | 9 -- igloo_manifest/src/.#lib.rs | 1 + igloo_manifest/src/lib.rs | 183 +++++++++++++++++--------------- 14 files changed, 120 insertions(+), 135 deletions(-) delete mode 100644 igloo_base/src/env_info.rs delete mode 120000 igloo_core/src/.#lib.rs delete mode 100644 igloo_make/Cargo.toml delete mode 100644 igloo_make/src/lib.rs create mode 120000 igloo_manifest/src/.#lib.rs diff --git a/Cargo.lock b/Cargo.lock index ce5530e..8ec6bb7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -161,7 +161,6 @@ dependencies = [ "igloo_agent", "igloo_cli", "igloo_core", - "igloo_make", "igloo_manifest", ] @@ -193,18 +192,10 @@ dependencies = [ "config", "igloo_base", "igloo_cli", - "igloo_make", "igloo_manifest", "zmq", ] -[[package]] -name = "igloo_make" -version = "0.1.0" -dependencies = [ - "igloo_base", -] - [[package]] name = "igloo_manifest" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index 4826ebe..4e7d482 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,8 +14,7 @@ igloo_core = { path = "./igloo_core" } igloo_cli = { path = "./igloo_cli" } igloo_agent = { path = "./igloo_agent" } igloo_manifest = { path = "./igloo_manifest" } -igloo_make = { path = "./igloo_make" } [workspace] -members = ["igloo_base", "igloo_core", "igloo_cli", "igloo_agent", "igloo_manifest", "igloo_make"] +members = ["igloo_base", "igloo_core", "igloo_cli", "igloo_agent", "igloo_manifest"] diff --git a/igloo_base/Cargo.toml b/igloo_base/Cargo.toml index 364be5a..d9dc557 100644 --- a/igloo_base/Cargo.toml +++ b/igloo_base/Cargo.toml @@ -7,4 +7,4 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -directories = "3.0.1" \ No newline at end of file +directories = "3.0.1" diff --git a/igloo_base/src/env_info.rs b/igloo_base/src/env_info.rs deleted file mode 100644 index e69de29..0000000 diff --git a/igloo_base/src/lib.rs b/igloo_base/src/lib.rs index ade5485..3d644e9 100644 --- a/igloo_base/src/lib.rs +++ b/igloo_base/src/lib.rs @@ -1,5 +1,3 @@ -mod env_info; - use std::path::PathBuf; use std::env; use directories::*; diff --git a/igloo_cli/src/lib.rs b/igloo_cli/src/lib.rs index a0bea98..073acf8 100644 --- a/igloo_cli/src/lib.rs +++ b/igloo_cli/src/lib.rs @@ -15,9 +15,12 @@ mod tests { } } +/// IglooCliConfig stores information about the igloo command being run. +/// It is all handled in active memory because we only care about this +/// information during the execution of that command. pub struct IglooCliConfig { - pub cli_conf: clap::ArgMatches, + pub raw: clap::ArgMatches, pub version_major: i8, pub version_minor: i8, pub version_patch: i8, @@ -30,7 +33,7 @@ impl IglooCliConfig { Self { - cli_conf: igloo_app(), + raw: igloo_app(), version_major: env!("CARGO_PKG_VERSION_MAJOR") .to_string() .parse() diff --git a/igloo_core/Cargo.toml b/igloo_core/Cargo.toml index 53d7a25..6b0aae0 100644 --- a/igloo_core/Cargo.toml +++ b/igloo_core/Cargo.toml @@ -9,8 +9,7 @@ edition = "2018" [dependencies] clap = "3.0.0-beta.2" config = "0.10" +igloo_base = { path = "../igloo_base" } igloo_cli = { path = "../igloo_cli" } igloo_manifest = { path = "../igloo_manifest" } -igloo_make = { path = "../igloo_make" } -igloo_base = { path = "../igloo_base" } zmq = "0.9" \ No newline at end of file diff --git a/igloo_core/src/.#lib.rs b/igloo_core/src/.#lib.rs deleted file mode 120000 index 7df5325..0000000 --- a/igloo_core/src/.#lib.rs +++ /dev/null @@ -1 +0,0 @@ -penguin@penguin-arch-home.90817:1632361064 \ No newline at end of file diff --git a/igloo_core/src/igloo_project.rs b/igloo_core/src/igloo_project.rs index c9f1996..1b3a255 100644 --- a/igloo_core/src/igloo_project.rs +++ b/igloo_core/src/igloo_project.rs @@ -33,6 +33,7 @@ impl IglooPrj IglooPrj { name: String::from(""), + /// target_bank -- a vector of targets added for this project target_bank: Vec::default(), project_dir: std::path::PathBuf::default(), root: PathBuf::default(), @@ -67,7 +68,7 @@ impl IglooPrj return Err(res_err) } - match target_is_valid(&inst.master_make_man, &inst.master_target_man, target_in) + match IglooManifest::target_is_valid(&inst.master_make_man, &inst.master_target_man, target_in) { Ok(v) => { diff --git a/igloo_core/src/lib.rs b/igloo_core/src/lib.rs index 547085d..4ebd53a 100644 --- a/igloo_core/src/lib.rs +++ b/igloo_core/src/lib.rs @@ -62,7 +62,7 @@ impl Igloo { let mut res: IglooInstType = Null; // Load manifests first - match get_master_make_manifest(&mut self.master_make_man) + match IglooManifest::get_master_make_manifest(&mut self.master_make_man) { ErrNone => (), v => @@ -71,7 +71,7 @@ impl Igloo return Err(v) } } - match get_master_target_manifest(&mut self.master_target_man) + match IglooManifest::get_master_target_manifest(&mut self.master_target_man) { ErrNone => (), v => @@ -82,7 +82,7 @@ impl Igloo } // Assign our instance type (new, run, flash, etc..) - match igloo_subcommand(&self.cli_conf.cli_conf) + match igloo_subcommand(&self.cli_conf.raw) { Ok(v) => res = v, Err(e) => return Err(e), @@ -103,12 +103,6 @@ impl Igloo { let mut res_err = ErrNone; let mut prj: IglooPrj; - println!("Version Major: {0}\n\ - Version Minor: {1}\n\ - Version Patch: {2}", - self.cli_conf.version_major, - self.cli_conf.version_minor, - self.cli_conf.version_patch); loop { match inst_type { Null => res_err = ErrNone, @@ -116,7 +110,7 @@ impl Igloo { let prj_name: &str = self .cli_conf - .cli_conf + .raw .subcommand() .unwrap().1 .value_of("project_name") @@ -124,7 +118,7 @@ impl Igloo let target: &str = self .cli_conf - .cli_conf + .raw .subcommand() .unwrap().1 .value_of("target") @@ -147,7 +141,13 @@ impl Igloo Info => { // list current version + println!("Igloo Version: {0}.{1}.{2}\n", + self.cli_conf.version_major, + self.cli_conf.version_minor, + self.cli_conf.version_patch); + // list esf version // list supported mcus + // if we're in a project, list the project info // list targets/boards println!("Info in run handler"); diff --git a/igloo_make/Cargo.toml b/igloo_make/Cargo.toml deleted file mode 100644 index d298b8d..0000000 --- a/igloo_make/Cargo.toml +++ /dev/null @@ -1,10 +0,0 @@ -[package] -name = "igloo_make" -version = "0.1.0" -authors = ["Penguin "] -edition = "2018" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -igloo_base = { path = "../igloo_base" } \ No newline at end of file diff --git a/igloo_make/src/lib.rs b/igloo_make/src/lib.rs deleted file mode 100644 index 58d05b0..0000000 --- a/igloo_make/src/lib.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[cfg(test)] -mod tests { - #[test] - fn it_works() { - assert_eq!(2 + 2, 4); - } -} - -use igloo_base; diff --git a/igloo_manifest/src/.#lib.rs b/igloo_manifest/src/.#lib.rs new file mode 120000 index 0000000..06ed8ad --- /dev/null +++ b/igloo_manifest/src/.#lib.rs @@ -0,0 +1 @@ +penguin@penguin-arch-home.8452:1632509282 \ No newline at end of file diff --git a/igloo_manifest/src/lib.rs b/igloo_manifest/src/lib.rs index 6ca7308..7d0069c 100644 --- a/igloo_manifest/src/lib.rs +++ b/igloo_manifest/src/lib.rs @@ -1,9 +1,9 @@ +/// Igloo Manifest is a subproject responsible for working with manifests. +/// Manifests are anything from config files to giant lists or ... manifests. +/// For now, all functionality is going to sit in this lib.rs until I figure out +/// how I want to structure manifests extern crate config; -use igloo_base::*; -use igloo_base::IglooErrType::*; -use config::Config; - #[cfg(test)] mod tests { #[test] @@ -12,111 +12,124 @@ mod tests { } } -/// Igloo Manifest -- Responsible for all lookups in manifest files -pub fn get_master_make_manifest(man: &mut Config) -> IglooErrType +pub mod IglooManifest { - 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 -} + use igloo_base::*; + use igloo_base::IglooErrType::*; + use config::Config; -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())) + /// 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 { - Ok(_v) => (), - Err(e) => + let mut ret: bool = true; + if name.is_empty() { - println!("Error: {:?}", e); - ret = FailedToLoadMasterTargetManifest; + return Err(InvalidTarget) } - } - 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 -{ - let mut ret: bool = true; - if name.is_empty() - { - return Err(InvalidTarget) - } - - match master_tm.get_table("target.make") - { - Ok(v) => + let mut target_make_name: String = String::default(); + match master_tm.get_table("target.make") { - match v.get(name) + Ok(v) => { - Some(v) => + match v.get(name) { - println!("target.make entry for \"{}\" exists!", v); - } - None => - { - println!("target.make entry for \"{}\" does not exist", name); - ret = false; + Some(v) => + { + println!("target.make entry for \"{}\" exists!", v); + target_make_name = v.to_string(); + println!("v.to_string() = {}", target_make_name); + } + None => + { + println!("target.make entry for \"{}\" does not exist", name); + ret = false; + } } + } + Err(e) => + { + println!("{:?}", e); + return Err(FailedToLoadMasterMakeManifest) + } + } + if !ret + { + return Ok(ret) } - Err(e) => + + let target_table = master_tm.get_table("target.manifest"); + match target_table { - println!("{:?}", e); - return Err(FailedToLoadMasterMakeManifest) + 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) + } } - } - if !ret - { - return Ok(ret) + + Ok(ret) } - let target_table = master_tm.get_table("target.manifest"); - match target_table + /// Igloo Manifest -- Responsible for all lookups in manifest files + pub fn get_master_make_manifest(man: &mut Config) -> IglooErrType { - Ok(v) => + 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())) { - match v.get(name) + Ok(_v) => (), + Err(e) => { - Some(v) => - { - println!("target.manifest entry for \"{}\" exists!", v); - } - None => - { - ret = false; - } + println!("Error: {:?}", e); + ret = FailedToLoadMasterMakeManifest; } } - Err(e) => + + 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())) { - println!("{:?}", e); - return Err(FailedToLoadMasterTargetManifest) + Ok(_v) => (), + Err(e) => + { + println!("Error: {:?}", e); + ret = FailedToLoadMasterTargetManifest; + } } - } - Ok(ret) + ret + } } +