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

unstable
Penguin 3 years ago
parent 711deeef76
commit 9945374437

52
Cargo.lock generated

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

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

@ -1,6 +1,6 @@
#[derive(Debug)]
#[derive(PartialEq)]
#[derive(Clone)]
use crate::{PathBuf, env, UserDirs};
#[derive(Debug, PartialEq, Clone)]
pub struct IglooEnv
{
// Current Working Directory
@ -13,9 +13,15 @@ pub struct IglooEnv
impl IglooEnv
{
pub fn get_env() -> IglooEnvInfo
pub fn get_env() -> IglooEnv
{
IglooEnv
{
cwd: match env::current_dir()
{
cwd: env::current_dir().unwrap(),
Ok(v) => v,
Err(e) => panic!(),
},
hd: match UserDirs::new()
{
Some(v) => v.home_dir().to_owned(),
@ -28,7 +34,7 @@ impl IglooEnv
},
esfd: match std::env::var("ESF_DIR")
{
Ok(v)
Ok(v) =>
{
std::path::PathBuf::from(&v.to_owned())
}
@ -42,4 +48,5 @@ impl IglooEnv
}
}
}
}
}

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

@ -18,6 +18,16 @@ pub struct 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
/// This means we do not yet have any project in storage
/// 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
pub fn from_existing(igloo: &'a Igloo) -> IglooProject
{
IglooProject
{
name:
}
IglooProject::default(igloo)
}
pub fn is_igloo_prj(path: &std::path::PathBuf) -> bool

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

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