configs have been a real pain... added a bunch of stubs for testing

unstable
Penguin 2 years ago
parent 711deeef76
commit 9945374437

52
Cargo.lock generated

@ -79,14 +79,14 @@ dependencies = [
[[package]] [[package]]
name = "config" name = "config"
version = "0.10.1" version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "19b076e143e1d9538dde65da30f8481c2a6c44040edb8e02b9bf1351edb92ce3" checksum = "1b1b9d958c2b1368a663f05538fc1b5975adce1e19f435acceae987aceeeb369"
dependencies = [ dependencies = [
"lazy_static", "lazy_static",
"nom", "nom",
"rust-ini", "rust-ini",
"serde 1.0.130", "serde 1.0.132",
"serde-hjson", "serde-hjson",
"serde_json", "serde_json",
"toml", "toml",
@ -170,6 +170,8 @@ dependencies = [
"clap", "clap",
"config", "config",
"directories", "directories",
"serde 1.0.132",
"toml",
] ]
[[package]] [[package]]
@ -213,16 +215,6 @@ version = "0.2.102"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2a5ac8f984bfcf3a823267e5fde638acc3325f6496633a5da6bb6eb2171e103" checksum = "a2a5ac8f984bfcf3a823267e5fde638acc3325f6496633a5da6bb6eb2171e103"
[[package]]
name = "linked-hash-map"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d262045c5b87c0861b3f004610afd0e2c851e2908d08b6c870cbb9d5f494ecd"
dependencies = [
"serde 0.8.23",
"serde_test",
]
[[package]] [[package]]
name = "linked-hash-map" name = "linked-hash-map"
version = "0.5.4" version = "0.5.4"
@ -368,9 +360,12 @@ checksum = "9dad3f759919b92c3068c696c15c3d17238234498bbdcc80f2c469606f948ac8"
[[package]] [[package]]
name = "serde" name = "serde"
version = "1.0.130" version = "1.0.132"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f12d06de37cf59146fbdecab66aa99f9fe4f78722e3607577a5375d66bd0c913" checksum = "8b9875c23cf305cd1fd7eb77234cbb705f21ea6a72c637a5c6db5fe4b8e7f008"
dependencies = [
"serde_derive",
]
[[package]] [[package]]
name = "serde-hjson" name = "serde-hjson"
@ -379,30 +374,31 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a3a4e0ea8a88553209f6cc6cfe8724ecad22e1acf372793c27d995290fe74f8" checksum = "6a3a4e0ea8a88553209f6cc6cfe8724ecad22e1acf372793c27d995290fe74f8"
dependencies = [ dependencies = [
"lazy_static", "lazy_static",
"linked-hash-map 0.3.0",
"num-traits 0.1.43", "num-traits 0.1.43",
"regex", "regex",
"serde 0.8.23", "serde 0.8.23",
] ]
[[package]] [[package]]
name = "serde_json" name = "serde_derive"
version = "1.0.68" version = "1.0.132"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0f690853975602e1bfe1ccbf50504d67174e3bcf340f23b5ea9992e0587a52d8" checksum = "ecc0db5cb2556c0e558887d9bbdcf6ac4471e83ff66cf696e5419024d1606276"
dependencies = [ dependencies = [
"itoa", "proc-macro2",
"ryu", "quote",
"serde 1.0.130", "syn",
] ]
[[package]] [[package]]
name = "serde_test" name = "serde_json"
version = "0.8.23" version = "1.0.68"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "110b3dbdf8607ec493c22d5d947753282f3bae73c0f56d322af1e8c78e4c23d5" checksum = "0f690853975602e1bfe1ccbf50504d67174e3bcf340f23b5ea9992e0587a52d8"
dependencies = [ dependencies = [
"serde 0.8.23", "itoa",
"ryu",
"serde 1.0.132",
] ]
[[package]] [[package]]
@ -452,7 +448,7 @@ version = "0.5.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa" checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa"
dependencies = [ dependencies = [
"serde 1.0.130", "serde 1.0.132",
] ]
[[package]] [[package]]
@ -528,5 +524,5 @@ version = "0.4.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85" checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85"
dependencies = [ dependencies = [
"linked-hash-map 0.5.4", "linked-hash-map",
] ]

@ -7,5 +7,7 @@ edition = "2021"
[dependencies] [dependencies]
clap = "3.0.0-beta.2" clap = "3.0.0-beta.2"
config = "0.10" config = "0.11"
directories = "3.0.1" directories = "3.0.1"
toml = "0.5.8"
serde = { version = "1.0.132", features = ["derive"]}

@ -1,6 +1,6 @@
#[derive(Debug)] use crate::{PathBuf, env, UserDirs};
#[derive(PartialEq)]
#[derive(Clone)] #[derive(Debug, PartialEq, Clone)]
pub struct IglooEnv pub struct IglooEnv
{ {
// Current Working Directory // Current Working Directory
@ -13,32 +13,39 @@ pub struct IglooEnv
impl IglooEnv impl IglooEnv
{ {
pub fn get_env() -> IglooEnvInfo pub fn get_env() -> IglooEnv
{ {
cwd: env::current_dir().unwrap(), IglooEnv
hd: match UserDirs::new()
{ {
Some(v) => v.home_dir().to_owned(), cwd: match env::current_dir()
None =>
{ {
println!("Error: Failed to get home directory.\n\ Ok(v) => v,
This should never happen. Exiting..."); Err(e) => panic!(),
std::process::exit(1); },
} hd: match UserDirs::new()
},
esfd: match std::env::var("ESF_DIR")
{
Ok(v)
{ {
std::path::PathBuf::from(&v.to_owned()) Some(v) => v.home_dir().to_owned(),
} None =>
Err(e) => {
println!("Error: Failed to get home directory.\n\
This should never happen. Exiting...");
std::process::exit(1);
}
},
esfd: match std::env::var("ESF_DIR")
{ {
// Note : Need to change new to return actual errors Ok(v) =>
// instead of exiting early {
println!("Error: $ESF_DIR not defined as an environment\ std::path::PathBuf::from(&v.to_owned())
variable -- {:?}", e); }
std::process::exit(1); Err(e) =>
{
// Note : Need to change new to return actual errors
// instead of exiting early
println!("Error: $ESF_DIR not defined as an environment\
variable -- {:?}", e);
std::process::exit(1);
}
} }
} }
} }

@ -12,62 +12,48 @@ use crate::IglooType::*;
use crate::igloo_target::IglooTarget; use crate::igloo_target::IglooTarget;
/// Igloo Manifest Helper functions use serde::{Serialize, Deserialize};
/// USES: environment variables (home dir, esf dir, current dir) use config::Config;
/// DOES: brings target manifest into memory
pub fn imh_get_master_target_manifest(inst: &mut Igloo) -> IglooStatus
{
let mut ret: IglooStatus = IS_GOOD;
match inst.master_target_manifest.merge( #[derive(Serialize, Deserialize, Debug)]
config::File::with_name( pub struct IglooProjectManifest
inst.env.esfd.join("manifest/target-manifest.toml").to_str.unwrap())) {
{ name: String,
Ok(_v) => (), targets: Vec::<String>
Err(e) =>
{
println!("Error: {:?}", e);
ret = IS_FAILED_TO_LOAD_MTM;
}
}
ret
} }
pub fn imh_get_project_name(inst: &Igloo) -> String impl IglooProjectManifest
{ {
let project_config: config::Config = config::Config::new(); pub fn default() -> IglooProjectManifest
match project_config.merge(
config::File::with_name(
inst.env.cwd.clone().join("igloo.toml").to_str().unwrap()))
{ {
Ok(v) => IglooProjectManifest
{ {
return v.deserialize::<HashMap<String, String>>().unwrap()["Project"] name: String::from(""),
targets: Vec::default(),
} }
Err(e) => panic!(),
} }
} pub fn from_project_file(self, igloo: &Igloo) -> Result<IglooProjectManifest, IglooStatus>
pub fn imh_get_targets(inst: &Igloo) -> Vec<IglooTarget>
{
let project_config: config::Config = config::Config::new();
match project_config.merge(
config::File::with_name(
inst.env.cwd.clone().join("igloo.toml").to_str().unwrap()))
{ {
Ok(v) => let mut config = config::Config::default();
{ config.merge(
match v.get("Targets") config::File::with_name(
{ igloo.env
Some(v2) => .cwd
{ .clone()
for target in .join("igloo.toml")
{ .to_str().unwrap())).unwrap();
let z = config.deserialize::<IglooProjectManifest>().unwrap();
println!("{:?}", z);
Ok(IglooProjectManifest::default())
}
} pub fn to_project_file(self, igloo: &Igloo) -> IglooStatus
} {
None => panic!(), IglooStatus::IS_GOOD
}
}
} }
} }

@ -18,6 +18,16 @@ pub struct IglooProject<'a>
impl<'a> IglooProject<'a> impl<'a> IglooProject<'a>
{ {
pub fn default(igloo_in: &'a Igloo) -> IglooProject
{
IglooProject
{
igloo: igloo_in,
name: String::new(),
targets: Vec::default(),
}
}
/// Used to populate an IglooProject from scratch /// Used to populate an IglooProject from scratch
/// This means we do not yet have any project in storage /// This means we do not yet have any project in storage
/// and we must generate those directories, files, and symlinks /// and we must generate those directories, files, and symlinks
@ -41,10 +51,8 @@ impl<'a> IglooProject<'a>
/// igloo run, push, pull, erase, etc... are called /// igloo run, push, pull, erase, etc... are called
pub fn from_existing(igloo: &'a Igloo) -> IglooProject pub fn from_existing(igloo: &'a Igloo) -> IglooProject
{ {
IglooProject IglooProject::default(igloo)
{
name:
}
} }
pub fn is_igloo_prj(path: &std::path::PathBuf) -> bool pub fn is_igloo_prj(path: &std::path::PathBuf) -> bool

@ -1,6 +1,8 @@
#![allow(warnings)] #![allow(warnings)]
extern crate clap; extern crate clap;
extern crate config; extern crate config;
extern crate toml;
extern crate serde;
use config::Config; use config::Config;
use std::path::PathBuf; use std::path::PathBuf;
@ -16,6 +18,7 @@ mod igloo_env;
use igloo_cli::IglooCliInfo; use igloo_cli::IglooCliInfo;
use igloo_env::IglooEnv; use igloo_env::IglooEnv;
use igloo_project::IglooProject;
#[derive(Debug)] #[derive(Debug)]
#[derive(PartialEq)] #[derive(PartialEq)]
@ -80,15 +83,15 @@ impl Igloo
{ {
let mut res: IglooType = IT_NULL; let mut res: IglooType = IT_NULL;
match igloo_manifest::get_master_target_manifest(self) // let master_target_manifest = match igloo_manifest::get_master_target_manifest(self)
{ // {
IS_GOOD => (), // IS_GOOD => ,
e => // e =>
{ // {
println!("{:?}", e); // println!("{:?}", e);
return Err(e) // return Err(e)
}, // },
} // }
// Assign instance type (new, run, push, etc) // Assign instance type (new, run, push, etc)
igloo_action::igloo_subcommand(&self.cli_info.raw) igloo_action::igloo_subcommand(&self.cli_info.raw)

@ -11,8 +11,8 @@ fn main()
{ {
match ig.run(it) match ig.run(it)
{ {
Ok(rt) => println!("{:?}", rt), IS_GOOD => println!("success"),
Err(e) => println!("Run Error: {:?}", e), _ => println!("??"),
} }
} }
Err(e) => println!("Error: {:?}", e), Err(e) => println!("Error: {:?}", e),

@ -0,0 +1,17 @@
[esf.links]
common = "arch/arm/common"
mcu = "arch/arm/SAMD21/SAMD21A/mcu"
ld = "arch/arm/SAMD21/SAMD21A/ld"
cfg = "arch/arm/SAMD21/SAMD21A/manifest"
[esf.includes]
IGLOO_INCLUDES = ["sam.h"]
# These are defaults. Once a project is generated, the .cfg can be freely edited without fear of anything being overwritten. However, I do not recommend editing any of the _cfg variables.
[esf.scripts]
scripts = ["arch/arm/SAMD21/SAMD21A/scripts/${TARGET}.cfg", "scripts"]
# lineage for this family of mcus
# this is used to evaluate makefile requirements for mcus
# this will be evaluated to "arch.arm.samd21a.<mcu_name>
[esf.make]
series = "arch.arm.samd21a.${TARGET}"
Loading…
Cancel
Save