preparing run and push commands

unstable
penguin 4 years ago
parent cba83ac5e1
commit b207661d00

@ -48,3 +48,9 @@ n
n n
n n
q q
q
break igloo_prj.rs:232
break src/igloo_prj.rs:232
del 2
r
q

@ -30,6 +30,7 @@ pub enum IglooErrType
IGLOO_INVALID_TARGET = 9, IGLOO_INVALID_TARGET = 9,
IGLOO_FAILED_TO_LOAD_MAKE_MAN = 10, IGLOO_FAILED_TO_LOAD_MAKE_MAN = 10,
IGLOO_FAILED_TO_LOAD_TARG_MAN = 11, IGLOO_FAILED_TO_LOAD_TARG_MAN = 11,
IGLOO_PRJ_SCRIPTS_DIR_NOT_FOUND = 12,
} }
#[derive(Debug)] #[derive(Debug)]

@ -14,16 +14,16 @@ pub mod IglooAction
-> IglooErrType -> IglooErrType
{ {
let mut res_err: IglooErrType = IglooErrType::IGLOO_ERR_NONE; let mut res_err: IglooErrType = IglooErrType::IGLOO_ERR_NONE;
// Check if we are already inside of an igloo project /// Check if we are already inside of an igloo project
// Creating an igloo project inside an igloo project /// Creating an igloo project inside an igloo project
// is a no no /// is a no no
if std::path::Path::new(".igloo").exists() if std::path::Path::new(".igloo").exists()
{ {
res_err = IglooErrType::IGLOO_NEW_CALLED_INSIDE_PRJ; res_err = IglooErrType::IGLOO_NEW_CALLED_INSIDE_PRJ;
return res_err return res_err
} }
// Check if the project folder already exists /// Check if the project folder already exists
// Don't want to accidentally overwrite anything /// Don't want to accidentally overwrite anything
if std::path::Path::new(prj_name).exists() if std::path::Path::new(prj_name).exists()
{ {
res_err = IglooErrType::IGLOO_FOLDER_ALREADY_EXISTS; res_err = IglooErrType::IGLOO_FOLDER_ALREADY_EXISTS;

@ -24,6 +24,7 @@ pub struct IglooTargetManifest
{ {
links: HashMap<String, config::Value>, links: HashMap<String, config::Value>,
includes: Vec<config::Value>, includes: Vec<config::Value>,
openocd: HashMap<String, config::Value>,
} }
pub struct IglooTarget pub struct IglooTarget
@ -194,14 +195,51 @@ impl IglooPrj
{ {
let mut target_root = prj_root.join(&("target/".to_owned() + &target.name)); let mut target_root = prj_root.join(&("target/".to_owned() + &target.name));
println!("{:?}", target_root.display()); println!("{:?}", target_root.display());
match std::fs::create_dir(target_root) match std::fs::create_dir(&target_root)
{ {
Err(e) => println!("{:?}", e), Err(e) => println!("{:?}", e),
_ => (), _ => (),
} }
// create project scripts dir
let mut scripts_dir = target_root.join("scripts");
match std::fs::create_dir(&scripts_dir)
{
Err(e) => println!("{:?}", e),
_ => (),
}
// populate scripts dir
//sym link gdb scripts
let mut gdb_scripts_paths = std::fs::read_dir(
&(String::from(
IglooEnvInfo::info()
.esfd.to_str()
.unwrap()) + "/scripts"))
.unwrap();
let mut gdb_scripts: std::vec::Vec<std::path::PathBuf>
= std::vec::Vec::new();
for entry in gdb_scripts_paths
{
match &entry
{
Ok(v) => if !v.path().is_dir() {
gdb_scripts.push(v.path()) },
Err(e) => println!("{:?}", e),
}
}
for file in gdb_scripts
{
println!("Project Scripts Dir: {:?}", scripts_dir);
println!("ePenguin Scripts Dir: {:?}", file);
std::os::unix::fs::symlink(
&file, &scripts_dir.join(&file.file_name().unwrap()));
}
let mut prj_esf_dir = self.project_dir.join("ESF"); let mut prj_esf_dir = self.project_dir.join("ESF");
println!("NEEDED {:?}", prj_esf_dir);
for (sym_dir, loc_in_esf) in &target.target_manifest.links for (sym_dir, loc_in_esf) in &target.target_manifest.links
{ {
let link_to_dir = IglooEnvInfo::info() let link_to_dir = IglooEnvInfo::info()
@ -210,11 +248,65 @@ impl IglooPrj
std::os::unix::fs::symlink(link_to_dir, prj_esf_dir.join(sym_dir)).unwrap(); std::os::unix::fs::symlink(link_to_dir, prj_esf_dir.join(sym_dir)).unwrap();
} }
self.gen_openocd_config(&target);
self.gen_makefile(&target); self.gen_makefile(&target);
} }
IglooErrType::IGLOO_ERR_NONE IglooErrType::IGLOO_ERR_NONE
} }
pub fn gen_openocd_config(&self, target: &IglooTarget) -> IglooErrType
{
let mut ret: IglooErrType = IglooErrType::IGLOO_ERR_NONE;
let mut openocd_cfg = self.project_dir.join(".igloo/target");
openocd_cfg.push(&target.name);
openocd_cfg.push("scripts");
openocd_cfg.push(&target.name);
if openocd_cfg.with_extension("cfg").exists()
{
std::fs::remove_file(openocd_cfg.with_extension("cfg"));
}
std::fs::File::create(
openocd_cfg.with_extension("cfg")).unwrap();
let mut ocfg_file = OpenOptions::new()
.write(true)
.append(true)
.open(openocd_cfg.with_extension("cfg"))
.unwrap();
writeln!(ocfg_file, "#\n# ePenguin Generated OpenOCD \
Config Script\n#\n").unwrap();
writeln!(ocfg_file, "\n# Transport Select").unwrap();
writeln!(ocfg_file, "source [find interface//{}.cfg]", target
.target_manifest
.openocd.get("transport_cfg")
.unwrap()
.clone()
.into_str()
.unwrap()).unwrap();
writeln!(ocfg_file, "transport select {}", target
.target_manifest
.openocd.get("transport")
.unwrap()
.clone()
.into_str()
.unwrap()).unwrap();
writeln!(ocfg_file, "\n# Chip Information").unwrap();
writeln!(ocfg_file, "set CHIPNAME {}", target.name);
writeln!(ocfg_file, "source [find target//{}.cfg]", target
.target_manifest
.openocd.get("chip_name_cfg")
.unwrap()
.clone()
.into_str()
.unwrap()).unwrap();
ret
}
/// Generates a makefile for a target /// Generates a makefile for a target
pub fn gen_makefile(&self, target: &IglooTarget) -> IglooErrType pub fn gen_makefile(&self, target: &IglooTarget) -> IglooErrType
{ {
@ -223,7 +315,7 @@ impl IglooPrj
// If the Makefile already exists, trash it // If the Makefile already exists, trash it
if target_root.join("Makefile").exists() if target_root.join("Makefile").exists()
{ {
std::fs::remove_file("Makefile"); std::fs::remove_file(target_root.join("Makefile"));
} }
// Make our Makefile, set it to append mode // Make our Makefile, set it to append mode
@ -235,7 +327,8 @@ impl IglooPrj
.unwrap(); .unwrap();
// //
writeln!(app_file, "# ePenguin Generated Variables").unwrap(); writeln!(app_file, "# ePenguin Generated Variables").unwrap();
writeln!(app_file, "PROJECT_NAME={}", self.name); writeln!(app_file, "PROJECT_NAME={}", self.name).unwrap();
writeln!(app_file, "TARGET_NAME={}", target.name).unwrap();
match target.make_manifest.get("TOOLCHAIN") match target.make_manifest.get("TOOLCHAIN")
{ {
@ -859,13 +952,12 @@ endif\n").unwrap();
} }
Some(v) => Some(v) =>
{ {
write!(app_file, "\n\t").unwrap(); write!(app_file, "\n").unwrap();
for cflag in v.clone().into_array().unwrap() for cflag in v.clone().into_array().unwrap()
{ {
if !cflag.to_string().is_empty() if !cflag.to_string().is_empty()
{ {
writeln!(app_file, " \\").unwrap(); writeln!(app_file, "\t{}", cflag).unwrap()
write!(app_file, "\t{}", cflag).unwrap()
} }
} }
}, },
@ -876,7 +968,7 @@ endif\n").unwrap();
{ {
None => None =>
{ {
println!("DEBUG_TARGET_PREREQS Not found"); println!("DEBUG_PREREQS Not found");
} }
Some(v) => Some(v) =>
{ {
@ -912,6 +1004,47 @@ endif\n").unwrap();
}, },
} }
writeln!(app_file, "\n").unwrap();
match target.make_manifest.get("PUSH_PREREQS")
{
None =>
{
println!("PUSH_PREREQS Not found");
}
Some(v) =>
{
write!(app_file, "push:").unwrap();
for cflag in v.clone().into_array().unwrap()
{
if !cflag.to_string().is_empty()
{
writeln!(app_file, "\\").unwrap();
write!(app_file, "{}", cflag).unwrap()
}
}
},
}
match target.make_manifest.get("PUSH_CMDS")
{
None =>
{
println!("PUSH_CMDS Not found");
}
Some(v) =>
{
write!(app_file, "\n\t").unwrap();
for cflag in v.clone().into_array().unwrap()
{
if !cflag.to_string().is_empty()
{
writeln!(app_file, " \\").unwrap();
write!(app_file, "\t{}", cflag).unwrap()
}
}
},
}
writeln!(app_file, "\n\nQUOTE:=\"").unwrap(); writeln!(app_file, "\n\nQUOTE:=\"").unwrap();
@ -978,8 +1111,8 @@ endif\n").unwrap();
IglooErrType::IGLOO_ERR_NONE IglooErrType::IGLOO_ERR_NONE
} }
}
}
impl IglooTarget impl IglooTarget
{ {
pub fn default() -> IglooTarget pub fn default() -> IglooTarget
@ -1045,7 +1178,6 @@ impl IglooTarget
}) })
} }
} }
impl IglooTargetManifest impl IglooTargetManifest
@ -1056,6 +1188,7 @@ impl IglooTargetManifest
{ {
links: HashMap::default(), links: HashMap::default(),
includes: Vec::default(), includes: Vec::default(),
openocd: HashMap::default(),
} }
} }
@ -1079,6 +1212,8 @@ impl IglooTargetManifest
.clone() .clone()
.into_array() .into_array()
.unwrap(), .unwrap(),
openocd: target_man.get_table("esf.openocd")
.unwrap(),
} }
} }
} }

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save