adding the master make check that was previously unimplemented

unstable
penguin 3 years ago
parent fe494f650f
commit 5ca581b496

9
Cargo.lock generated

@ -161,7 +161,6 @@ dependencies = [
"igloo_agent", "igloo_agent",
"igloo_cli", "igloo_cli",
"igloo_core", "igloo_core",
"igloo_make",
"igloo_manifest", "igloo_manifest",
] ]
@ -193,18 +192,10 @@ dependencies = [
"config", "config",
"igloo_base", "igloo_base",
"igloo_cli", "igloo_cli",
"igloo_make",
"igloo_manifest", "igloo_manifest",
"zmq", "zmq",
] ]
[[package]]
name = "igloo_make"
version = "0.1.0"
dependencies = [
"igloo_base",
]
[[package]] [[package]]
name = "igloo_manifest" name = "igloo_manifest"
version = "0.1.0" version = "0.1.0"

@ -14,8 +14,7 @@ igloo_core = { path = "./igloo_core" }
igloo_cli = { path = "./igloo_cli" } igloo_cli = { path = "./igloo_cli" }
igloo_agent = { path = "./igloo_agent" } igloo_agent = { path = "./igloo_agent" }
igloo_manifest = { path = "./igloo_manifest" } igloo_manifest = { path = "./igloo_manifest" }
igloo_make = { path = "./igloo_make" }
[workspace] [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"]

@ -7,4 +7,4 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
directories = "3.0.1" directories = "3.0.1"

@ -1,5 +1,3 @@
mod env_info;
use std::path::PathBuf; use std::path::PathBuf;
use std::env; use std::env;
use directories::*; use directories::*;

@ -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 struct IglooCliConfig
{ {
pub cli_conf: clap::ArgMatches, pub raw: clap::ArgMatches,
pub version_major: i8, pub version_major: i8,
pub version_minor: i8, pub version_minor: i8,
pub version_patch: i8, pub version_patch: i8,
@ -30,7 +33,7 @@ impl IglooCliConfig
{ {
Self Self
{ {
cli_conf: igloo_app(), raw: igloo_app(),
version_major: env!("CARGO_PKG_VERSION_MAJOR") version_major: env!("CARGO_PKG_VERSION_MAJOR")
.to_string() .to_string()
.parse() .parse()

@ -9,8 +9,7 @@ edition = "2018"
[dependencies] [dependencies]
clap = "3.0.0-beta.2" clap = "3.0.0-beta.2"
config = "0.10" config = "0.10"
igloo_base = { path = "../igloo_base" }
igloo_cli = { path = "../igloo_cli" } igloo_cli = { path = "../igloo_cli" }
igloo_manifest = { path = "../igloo_manifest" } igloo_manifest = { path = "../igloo_manifest" }
igloo_make = { path = "../igloo_make" }
igloo_base = { path = "../igloo_base" }
zmq = "0.9" zmq = "0.9"

@ -1 +0,0 @@
penguin@penguin-arch-home.90817:1632361064

@ -33,6 +33,7 @@ impl IglooPrj
IglooPrj IglooPrj
{ {
name: String::from(""), name: String::from(""),
/// target_bank -- a vector of targets added for this project
target_bank: Vec::default(), target_bank: Vec::default(),
project_dir: std::path::PathBuf::default(), project_dir: std::path::PathBuf::default(),
root: PathBuf::default(), root: PathBuf::default(),
@ -67,7 +68,7 @@ impl IglooPrj
return Err(res_err) 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) => Ok(v) =>
{ {

@ -62,7 +62,7 @@ impl Igloo
{ {
let mut res: IglooInstType = Null; let mut res: IglooInstType = Null;
// Load manifests first // 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 => (), ErrNone => (),
v => v =>
@ -71,7 +71,7 @@ impl Igloo
return Err(v) 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 => (), ErrNone => (),
v => v =>
@ -82,7 +82,7 @@ impl Igloo
} }
// Assign our instance type (new, run, flash, etc..) // 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, Ok(v) => res = v,
Err(e) => return Err(e), Err(e) => return Err(e),
@ -103,12 +103,6 @@ impl Igloo
{ {
let mut res_err = ErrNone; let mut res_err = ErrNone;
let mut prj: IglooPrj; 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 loop { match inst_type
{ {
Null => res_err = ErrNone, Null => res_err = ErrNone,
@ -116,7 +110,7 @@ impl Igloo
{ {
let prj_name: &str = self let prj_name: &str = self
.cli_conf .cli_conf
.cli_conf .raw
.subcommand() .subcommand()
.unwrap().1 .unwrap().1
.value_of("project_name") .value_of("project_name")
@ -124,7 +118,7 @@ impl Igloo
let target: &str = self let target: &str = self
.cli_conf .cli_conf
.cli_conf .raw
.subcommand() .subcommand()
.unwrap().1 .unwrap().1
.value_of("target") .value_of("target")
@ -147,7 +141,13 @@ impl Igloo
Info => Info =>
{ {
// list current version // 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 // list supported mcus
// if we're in a project, list the project info // if we're in a project, list the project info
// list targets/boards // list targets/boards
println!("Info in run handler"); println!("Info in run handler");

@ -1,10 +0,0 @@
[package]
name = "igloo_make"
version = "0.1.0"
authors = ["Penguin <penguin@epenguin.net>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
igloo_base = { path = "../igloo_base" }

@ -1,9 +0,0 @@
#[cfg(test)]
mod tests {
#[test]
fn it_works() {
assert_eq!(2 + 2, 4);
}
}
use igloo_base;

@ -0,0 +1 @@
penguin@penguin-arch-home.8452:1632509282

@ -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; extern crate config;
use igloo_base::*;
use igloo_base::IglooErrType::*;
use config::Config;
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#[test] #[test]
@ -12,111 +12,124 @@ mod tests {
} }
} }
/// Igloo Manifest -- Responsible for all lookups in manifest files pub mod IglooManifest
pub fn get_master_make_manifest(man: &mut Config) -> IglooErrType
{ {
let mut ret: IglooErrType = ErrNone; use igloo_base::*;
match man.merge( use igloo_base::IglooErrType::*;
config::File::with_name( use config::Config;
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 /// master_mm -- Master Make Manifest
{ /// master_tm -- Master Target Manifest
let mut ret: IglooErrType = ErrNone; /// name -- name of target
match man.merge( pub fn target_is_valid(master_mm: &Config, master_tm: &Config, name: &str)
config::File::with_name( -> Result<bool, IglooErrType>
IglooEnvInfo::get_env_info().esfd.join("manifest/target-manifest.toml")
.to_str()
.unwrap()))
{ {
Ok(_v) => (), let mut ret: bool = true;
Err(e) => if name.is_empty()
{ {
println!("Error: {:?}", e); return Err(InvalidTarget)
ret = FailedToLoadMasterTargetManifest;
} }
}
ret let mut target_make_name: String = String::default();
} match master_tm.get_table("target.make")
/// 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) Ok(v) =>
{ {
Some(v) => match v.get(name)
{ {
println!("target.make entry for \"{}\" exists!", v); Some(v) =>
} {
None => println!("target.make entry for \"{}\" exists!", v);
{ target_make_name = v.to_string();
println!("target.make entry for \"{}\" does not exist", name); println!("v.to_string() = {}", target_make_name);
ret = false; }
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); Ok(v) =>
return Err(FailedToLoadMasterMakeManifest) {
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
{ Ok(ret)
return Ok(ret)
} }
let target_table = master_tm.get_table("target.manifest"); /// Igloo Manifest -- Responsible for all lookups in manifest files
match target_table 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!("Error: {:?}", e);
{ ret = FailedToLoadMasterMakeManifest;
println!("target.manifest entry for \"{}\" exists!", v);
}
None =>
{
ret = false;
}
} }
} }
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); Ok(_v) => (),
return Err(FailedToLoadMasterTargetManifest) Err(e) =>
{
println!("Error: {:?}", e);
ret = FailedToLoadMasterTargetManifest;
}
} }
}
Ok(ret) ret
}
} }

Loading…
Cancel
Save