beginning rewrite

unstable
Penguin 2 years ago
parent 3a775f71dc
commit 3f638f6475

@ -45,7 +45,7 @@ fn gdb_thread(sender: &Sender<String>, child: std::process::Child)
} }
} }
fn start_openocd_listener(sender: Sender<String>, board_cfg_file: &str) fn start_openocd_listener(sender: Sender<String>, target: &igloo_target::IglooTarget)
{ {
let child = Command::new("openocd") let child = Command::new("openocd")
.args(["-f", board_cfg_file]) .args(["-f", board_cfg_file])
@ -60,5 +60,9 @@ fn start_openocd_listener(sender: Sender<String>, board_cfg_file: &str)
fn ia_push(target: &igloo_target::IglooTarget) -> Result<String, igloo_base::IglooErrType> fn ia_push(target: &igloo_target::IglooTarget) -> Result<String, igloo_base::IglooErrType>
{ {
let (oo_tx, oo_rx) = channel();
start_openocd_listener(oo_tx, target);
let (gdb_tx, gdb_rx) = channel();
Ok(String::from("working")) Ok(String::from("working"))
} }

@ -4,7 +4,7 @@ use igloo_base::IglooErrType::*;
use crate::Igloo; use crate::Igloo;
use crate::igloo_project::IglooPrj; use crate::igloo_project::IglooPrj;
pub fn run(prj_name: &str, target: &str) -> IglooErrType pub fn iac_run(prj_name: &str, target: &str) -> IglooErrType
{ {
let res_err: IglooErrType = ErrNone; let res_err: IglooErrType = ErrNone;
res_err res_err
@ -52,21 +52,7 @@ pub fn new(inst: &Igloo, prj_name: &str, target: &str)
res_err res_err
} }
pub fn add_target(inst: &Igloo, prj_name: &str, target: &str) -> IglooErrType pub fn push(inst: &Igloo)
{ {
let mut res_err: IglooErrType = ErrNone;
loop {{
// Verify that we are inside of an igloo project
if !IglooPrj::is_igloo_prj(&std::env::current_dir().unwrap())
{
res_err = ActionCalledOutsideProject;
break;
}
}break;}
return res_err
} }

@ -1,6 +1,7 @@
use igloo_base::*; use igloo_base::*;
use igloo_base::IglooErrType::*; use igloo_base::IglooErrType::*;
use igloo_manifest::*; use igloo_manifest::*;
use config::Config;
use crate::Igloo; use crate::Igloo;
use crate::igloo_target::IglooTarget; use crate::igloo_target::IglooTarget;
@ -9,6 +10,7 @@ use std::fs::File;
use std::vec::Vec; use std::vec::Vec;
use std::io::prelude::*; use std::io::prelude::*;
use std::path::PathBuf; use std::path::PathBuf;
use std::collections::HashMap;
// New Project // New Project
// --- Verify location // --- Verify location
// --- Populate base folders // --- Populate base folders
@ -111,6 +113,7 @@ impl IglooPrj
&_targ_manifest_file_name).unwrap(); &_targ_manifest_file_name).unwrap();
targetbank.push(targ); targetbank.push(targ);
println!("{:?}", targ);
} break;} } break;}
@ -129,6 +132,23 @@ impl IglooPrj
}) })
} }
/// takes the cwd and turns the .igloo/ and .igloo.toml into the project
/// in memory
pub fn from_here() -> Result<IglooPrj, IglooErrType>
{
let mut res = IglooErrType::ErrNone;
// get project name and target(s)
let mut prj_file = config::Config::default();
prj_file.merge(config::File::with_name(".igloo")).unwrap();
let mut prj_name = prj_file.deserialize::<HashMap<String, String>>().unwrap();
println!("This projects name is {:?}", prj_name);
Err(IglooErrType::ErrUnknown)
}
pub fn populate(&self) -> IglooErrType pub fn populate(&self) -> IglooErrType
{ {

@ -30,7 +30,6 @@ mod tests {
pub struct Igloo pub struct Igloo
{ {
cli_conf: IglooCliConfig, cli_conf: IglooCliConfig,
master_make_man: Config,
master_target_man: Config, master_target_man: Config,
} }
@ -46,7 +45,6 @@ impl Igloo
{ {
Igloo Igloo
{ {
master_make_man: Config::new(),
master_target_man: Config::new(), master_target_man: Config::new(),
cli_conf: IglooCliConfig::new(), cli_conf: IglooCliConfig::new(),
} }
@ -61,16 +59,6 @@ impl Igloo
pub fn start(&mut self) -> Result<IglooInstType, IglooErrType> pub fn start(&mut self) -> Result<IglooInstType, IglooErrType>
{ {
let mut res: IglooInstType = Null; let mut res: IglooInstType = Null;
// Load manifests first
match IglooManifest::get_master_make_manifest(&mut self.master_make_man)
{
ErrNone => (),
v =>
{
println!("{:?}", v);
return Err(v)
}
}
match IglooManifest::get_master_target_manifest(&mut self.master_target_man) match IglooManifest::get_master_target_manifest(&mut self.master_target_man)
{ {
ErrNone => (), ErrNone => (),
@ -131,10 +119,7 @@ impl Igloo
} }
Push => Push =>
{ {
if IglooPrj::is_igloo_prj(&std::env::current_dir().unwrap())
{
}
} }
Run => Run =>
{ {
@ -156,31 +141,6 @@ impl Igloo
} }
Target => Target =>
{ {
let tar_sub = self.cli_conf.raw.subcommand().unwrap();
match &tar_sub.1.subcommand_name()
{
Some("add") =>
{
println!("Attempting to add target \"{0}\"",
tar_sub.1
.subcommand()
.unwrap().1
.value_of("target_name")
.unwrap());
}
Some("remove") =>
{
println!("Attempting to remove target \"{0}\"",
tar_sub.1
.subcommand()
.unwrap().1
.value_of("target_name")
.unwrap());
}
None => unreachable!(),
_ => unreachable!(),
}
} }
_ => println!("Unhandled case: {:?}", inst_type), _ => println!("Unhandled case: {:?}", inst_type),
} break; } } break; }

@ -0,0 +1 @@
penguin@gpenguin.3110:1639883851

@ -21,7 +21,7 @@ pub mod IglooManifest
/// master_mm -- Master Make Manifest /// master_mm -- Master Make Manifest
/// master_tm -- Master Target Manifest /// master_tm -- Master Target Manifest
/// name -- name of target /// name -- name of target
pub fn target_is_valid(master_mm: &Config, master_tm: &Config, name: &str) pub fn target_is_valid(master_tm: &Config, name: &str)
-> Result<bool, IglooErrType> -> Result<bool, IglooErrType>
{ {
let mut ret: bool = true; let mut ret: bool = true;
@ -30,7 +30,7 @@ pub mod IglooManifest
return Err(InvalidTarget) return Err(InvalidTarget)
} }
let mut target_make_name: String = String::default(); let mut target_man_path: String = String::default();
// Confirm the target.make table exists in the master target manifest // Confirm the target.make table exists in the master target manifest
match master_tm.get_table("target.make") match master_tm.get_table("target.make")
{ {
@ -46,7 +46,7 @@ pub mod IglooManifest
// Now we've confirmed the target has an entry in the target.make table // Now we've confirmed the target has an entry in the target.make table
println!("target.make entry for \"{}\" exists!", v); println!("target.make entry for \"{}\" exists!", v);
// store the target's full name for use in the master make manifest later // store the target's full name for use in the master make manifest later
target_make_name = v.to_string(); target_man_path = v.to_string();
} }
None => None =>
{ {
@ -94,54 +94,6 @@ pub mod IglooManifest
return Err(FailedToLoadMasterTargetManifest) return Err(FailedToLoadMasterTargetManifest)
} }
} }
// Now confirm the target has an entry in the master make manifest
// strip the name for usable pieces of information
let (dummy, arch, family, mcu_name) = sscanf::scanf!(
target_make_name, "{}.{}.{}.{}", String, String, String, String).unwrap();
// verify an entry exists for the arch
match master_mm.get_table(&format!("{}.{}", dummy, arch))
{
Ok(_v) =>
{
println!("Make parameters found for arch");
}
Err(e) =>
{
println!("Make parameters not found: {}", e);
ret = false;
}
}
// verify an entry exists for the mcu family
// later this will be family, then series, then mcu
match master_mm.get_table(&format!("{}.{}.{}", dummy, arch, family))
{
Ok(_v) =>
{
println!("Make parameters found for mcu family");
}
Err(e) =>
{
println!("Make parameters not found: {}", e);
ret = false;
}
}
// finally, ver
match master_mm.get_table(&format!("{}.{}.{}.{}", dummy, arch, family, mcu_name))
{
Ok(_v) =>
{
println!("Make parameters found for mcu family");
}
Err(e) =>
{
println!("Make parameters not found: {}", e);
ret = false;
}
}
Ok(ret) Ok(ret)
} }

Loading…
Cancel
Save