actual last commit til after christmas. rust + macros + workspaces = disaster... Moved igloo util into its own workspace member (subcrate?) rust building and dependencies are kinda a disaster.

unstable
Penguin 3 years ago
parent 912812a37a
commit ff5a3535db

@ -36,3 +36,36 @@ set listsize 30
s s
q q
q q
b igloo::main
r
n
q
b igloo::main
r
n
n
s
s
s
n
s
s
n
n
s
n
n
s
s
n
s
b
n
n
n
n
n
n
n
n
q

6
Cargo.lock generated

@ -154,6 +154,7 @@ version = "0.1.0"
dependencies = [ dependencies = [
"igloo_agent", "igloo_agent",
"igloo_core", "igloo_core",
"igloo_util",
] ]
[[package]] [[package]]
@ -170,10 +171,15 @@ dependencies = [
"clap", "clap",
"config", "config",
"directories", "directories",
"igloo_util",
"serde 1.0.132", "serde 1.0.132",
"toml", "toml",
] ]
[[package]]
name = "igloo_util"
version = "0.1.0"
[[package]] [[package]]
name = "indexmap" name = "indexmap"
version = "1.7.0" version = "1.7.0"

@ -12,7 +12,8 @@ license="GPL-2.0"
[dependencies] [dependencies]
igloo_core = { path = "./igloo_core" } igloo_core = { path = "./igloo_core" }
igloo_agent = { path = "./igloo_agent" } igloo_agent = { path = "./igloo_agent" }
igloo_util = { path = "./igloo_util" }
[workspace] [workspace]
members = ["igloo_core", "igloo_agent"] members = ["igloo_core", "igloo_agent", "igloo_util"]

@ -10,4 +10,5 @@ clap = "3.0.0-beta.2"
config = "0.11" config = "0.11"
directories = "3.0.1" directories = "3.0.1"
toml = "0.5.8" toml = "0.5.8"
serde = { version = "1.0.132", features = ["derive"]} serde = { version = "1.0.132", features = ["derive"]}
igloo_util = { path="../igloo_util" }

@ -1 +0,0 @@
penguin@gpenguin.2954:1640039390

@ -1,11 +1,13 @@
use clap::ArgMatches; use clap::ArgMatches;
use crate::IglooType::{self, *}; use igloo_util::IglooDebugSeverity::*;
use crate::IglooStatus::{self, *}; use igloo_util::IglooStatus::{self, *};
use crate::IglooDebugSeverity::{self, *}; use igloo_util::IglooType::{self, *};
use igloo_util::TRACE_LEVEL;
use crate::Igloo; use crate::Igloo;
use crate::igloo_project::IglooProject; use crate::igloo_project::IglooProject;
use crate::igloo_util::*; use crate::igloo_project::Settings;
pub fn igloo_subcommand(args: &ArgMatches) -> Result<IglooType, IglooStatus> pub fn igloo_subcommand(args: &ArgMatches) -> Result<IglooType, IglooStatus>
{ {
@ -92,22 +94,21 @@ pub fn ia_new(igloo: &Igloo, project_name: String, initial_target: String) -> Ig
return ret return ret
} }
igloo_debug!(TRACE, IS_NONE, "Creating new igloo project...");
let mut prj = match IglooProject::from_new(igloo, project_name) let mut prj = match IglooProject::from_new(igloo, project_name)
{ {
Ok(v) => v, Ok(v) => v,
Err(e) => Err(e) =>
{ {
igloo_debug!(ERROR, e); ret = e;
return e igloo_debug!(ERROR, ret);
return ret
} }
}; };
ret = prj.add_target_to_config(initial_target); // add initial target to config
if ret != IS_GOOD prj.config.add_target(initial_target);
{ prj.targets = Settings::get_targets_from_config(&prj);
igloo_debug!(ERROR, ret);
return ret
}
// Now populate // Now populate
ret = prj.generate(); ret = prj.generate();
@ -130,8 +131,11 @@ pub fn ia_new(igloo: &Igloo, project_name: String, initial_target: String) -> Ig
igloo_debug!(ERROR, ret); igloo_debug!(ERROR, ret);
} }
ret = prj.generate_project_config();
if ret != IS_GOOD
{
igloo_debug!(ERROR, ret);
}
ret ret
} }

@ -1,10 +1,9 @@
use clap::{App, Arg, ArgMatches}; use clap::{App, Arg};
use crate::Igloo; use crate::Igloo;
use crate::IglooType; // use igloo_util::IglooDebugSeverity::*;
use crate::IglooType::*; // use igloo_util::IglooStatus::{self, *};
use crate::IglooStatus; // use igloo_util::TRACE_LEVEL;
use crate::IglooStatus::*;
/// Information input via cli will be stored here for the lifetime of the process /// Information input via cli will be stored here for the lifetime of the process
pub struct IglooCliInfo pub struct IglooCliInfo

@ -1,6 +1,6 @@
use crate::{PathBuf, env, UserDirs}; use crate::{PathBuf, env, UserDirs};
static PROJECT_CONFIG_FILE_NAME: &str = "igloo.toml"; // static PROJECT_CONFIG_FILE_NAME: &str = "igloo.toml";
#[derive(Debug, PartialEq, Clone)] #[derive(Debug, PartialEq, Clone)]
pub struct IglooEnv pub struct IglooEnv

@ -1,17 +1,13 @@
// igloo_manifest is a simple collection of functions that work with configs // igloo_manifest is a simple collection of functions that work with configs
use std::collections::HashMap; use std::collections::HashMap;
use std::vec::Vec;
use crate::Igloo; use crate::Igloo;
use crate::IglooStatus::{self, *};
use crate::IglooType::{self, *};
use crate::IglooDebugSeverity::{self, *};
use crate::igloo_target::IglooTarget;
use crate::igloo_util::*;
use serde::{Serialize, Deserialize}; use serde::{Serialize, Deserialize};
use config::Config;
use igloo_util::IglooDebugSeverity::*;
use igloo_util::IglooStatus::{self, *};
use igloo_util::TRACE_LEVEL;
/// IglooTargetManifest - a manifest file locations which contain each target's /// IglooTargetManifest - a manifest file locations which contain each target's
/// settings and configuration properties /// settings and configuration properties

@ -1,21 +1,17 @@
use crate::Igloo; use crate::Igloo;
use crate::igloo_cli::*;
use crate::IglooType::{self, *};
use crate::IglooStatus::{self, *};
use crate::IglooDebugSeverity::{self, *};
use crate::igloo_util::*;
use crate::igloo_project;
use crate::igloo_target::IglooTarget; use crate::igloo_target::IglooTarget;
use serde::{Serialize, Deserialize}; use serde::{Serialize, Deserialize};
use config::Config; use std::fs::{OpenOptions};
use igloo_util::IglooDebugSeverity::*;
use igloo_util::IglooStatus::{self, *};
use igloo_util::TRACE_LEVEL;
#[derive(Serialize, Deserialize, Debug, Clone)] #[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Settings pub struct Settings
{ {
pub testvar: String, pub testvar: Option<String>,
pub profile: Profile, pub profile: Profile,
} }
@ -46,16 +42,16 @@ impl Settings
{ {
Settings Settings
{ {
testvar: String::new(), testvar: Option::default(),
profile: Profile::default(), profile: Profile::default(),
} }
} }
pub fn from_project_file(self, igloo: &Igloo) -> Result<Settings, IglooStatus> pub fn from_project_file(prj: &IglooProject) -> Result<Settings, IglooStatus>
{ {
let mut config = config::Config::default(); let mut config = config::Config::default();
config.merge( config.merge(
config::File::with_name( config::File::with_name(
igloo.env prj.igloo.env
.cwd .cwd
.clone() .clone()
.join("test") .join("test")
@ -67,8 +63,23 @@ impl Settings
} }
pub fn to_project_file(self, igloo: &Igloo) -> IglooStatus pub fn to_project_file(prj: &IglooProject) -> IglooStatus
{ {
let prj_cfg_path = prj
.root
.clone()
.join("igloo")
.join("igloo.toml");
std::fs::File::create(&prj_cfg_path).unwrap();
let mut prj_cfg_file = OpenOptions::new()
.write(true)
.append(true)
.open(&prj_cfg_path)
.unwrap();
let contents = toml::to_string(&prj.config).unwrap();
igloo_debug!(TRACE, IS_NONE, "{}", contents);
println!("PRINTING THIS ON ITS OWN: {}", contents);
IglooStatus::IS_GOOD IglooStatus::IS_GOOD
} }
@ -81,12 +92,14 @@ impl Settings
self.profile.targets.push(target_name); self.profile.targets.push(target_name);
} }
pub fn get_targets_from_config(igloo: &Igloo, config: &Settings) -> Vec<IglooTarget> /// This function is labeled .._from_config, but the project contains
/// the environment vars (from &Igloo) and config already
pub fn get_targets_from_config(prj: &IglooProject) -> Vec<IglooTarget>
{ {
let mut _targets: Vec<IglooTarget> = Vec::new(); let mut _targets: Vec<IglooTarget> = Vec::new();
for target in config.profile.targets.iter() for target in prj.config.profile.targets.iter()
{ {
_targets.push(IglooTarget::target_from_name(igloo, String::from(target)).unwrap()); _targets.push(IglooTarget::target_from_name(prj.igloo, String::from(target)).unwrap());
} }
_targets _targets
} }
@ -96,7 +109,7 @@ pub struct IglooProject<'a>
{ {
pub igloo: &'a Igloo, pub igloo: &'a Igloo,
pub config: Settings, pub config: Settings,
targets: Vec::<IglooTarget>, pub targets: Vec::<IglooTarget>,
pub root: std::path::PathBuf, pub root: std::path::PathBuf,
} }
@ -133,17 +146,15 @@ 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_in: &'a Igloo) -> Result<IglooProject, IglooStatus> pub fn from_existing(igloo_in: &'a Igloo) -> Result<IglooProject, IglooStatus>
{ {
let _config = Settings::default().from_project_file(igloo_in).unwrap(); // These vars need to be acquired in this order when creating a project from an existing project
let _targets = Settings::get_targets_from_config(igloo_in, &_config); // The config requires the &Igloo
let _root = igloo_in.env.cwd.join(&_config.profile.name); // targets requires config and &Igloo
let ret_project = IglooProject // root just requires the project name, but its best to do it last to make sure everything else is valid
{ let mut ret_project = IglooProject::default(igloo_in);
igloo: igloo_in, ret_project.config = Settings::from_project_file(&ret_project).unwrap();
config: _config, ret_project.targets = Settings::get_targets_from_config(&ret_project);
targets: _targets, ret_project.root = igloo_in.env.cwd.join(&ret_project.config.profile.name);
root: _root, Ok(ret_project)
};
Ok(IglooProject::default(igloo_in))
} }
pub fn is_igloo_prj(path: &std::path::PathBuf) -> bool pub fn is_igloo_prj(path: &std::path::PathBuf) -> bool
@ -170,25 +181,37 @@ impl<'a> IglooProject<'a>
// so i can make changes to active dir and still have my project root if i need it // so i can make changes to active dir and still have my project root if i need it
// so far i havent needed it so i may just remove this // so far i havent needed it so i may just remove this
let active_dir = std::path::PathBuf::new().join(&self.config.profile.name); let active_dir = self.root.clone();
// create new project directory // create new project directory
match std::fs::create_dir(&active_dir) match std::fs::create_dir(&active_dir)
{ {
Err(e) => Err(e) =>
{ {
println!("{:?}", e); ret = IS_FAILED_TO_CREATE_DIR;
return IS_BAD igloo_debug!(ERROR, ret, "Failed to create dir: {:?} | {:?}", &active_dir, e);
return ret
} }
_ => (), _ => (),
} }
// create igloo directory // create igloo directory
match std::fs::create_dir(&active_dir.clone().join("igloo"))
{
Err(e) =>
{
ret = IS_FAILED_TO_CREATE_DIR;
igloo_debug!(ERROR, ret, "Failed to create dir: {:?} | {:?}", &active_dir.clone().join("igloo"), e);
return ret
}
_ => (),
}
match std::fs::create_dir(&active_dir.clone().join("inc")) match std::fs::create_dir(&active_dir.clone().join("inc"))
{ {
Err(e) => Err(e) =>
{ {
println!("{:?}", e); ret = IS_FAILED_TO_CREATE_DIR;
return IS_BAD igloo_debug!(ERROR, ret, "Failed to create dir: {:?} | {:?}", &active_dir.clone().join("inc"), e);
return ret
} }
_ => (), _ => (),
} }
@ -198,8 +221,9 @@ impl<'a> IglooProject<'a>
{ {
Err(e) => Err(e) =>
{ {
println!("{:?}", e); ret = IS_FAILED_TO_CREATE_DIR;
return IS_BAD igloo_debug!(ERROR, ret, "Failed to create dir: {:?} | {:?}", &active_dir.clone().join("src"), e);
return ret
} }
_ => (), _ => (),
} }
@ -208,8 +232,9 @@ impl<'a> IglooProject<'a>
{ {
Err(e) => Err(e) =>
{ {
println!("{:?}", e); ret = IS_FAILED_TO_CREATE_DIR;
return IS_BAD igloo_debug!(ERROR, ret, "Failed to create dir: {:?} | {:?}", &active_dir.clone().join("cfg"), e);
return ret
} }
_ => (), _ => (),
} }
@ -218,42 +243,34 @@ impl<'a> IglooProject<'a>
{ {
Err(e) => Err(e) =>
{ {
println!("{:?}", e); ret = IS_FAILED_TO_CREATE_DIR;
return IS_BAD igloo_debug!(ERROR, ret, "Failed to create dir: {:?} | {:?}", &active_dir.clone().join("esf"), e);
return ret
} }
_ => (), _ => (),
} }
// project folders finished // project folders finished
// now do target folders // create project settings file (igloo.toml)
ret = self.generate_targets(); ret = self.generate_project_config();
if ret != IS_GOOD if ret != IS_GOOD
{ {
igloo_debug!(WARNING, ret);
return ret return ret
} }
ret = self.generate_igloo_header(); // now do target folders
ret = self.generate_targets();
if ret != IS_GOOD if ret != IS_GOOD
{ {
igloo_debug!(WARNING, ret);
return ret return ret
} }
ret = self.generate_igloo_main();
if ret != IS_GOOD
{
return ret
}
return ret return ret
} }
pub fn add_target_to_config(&mut self, target: String) -> IglooStatus
{
let mut ret = IS_GOOD;
self.config.add_target(target);
ret
}
fn generate_targets(&self) -> IglooStatus fn generate_targets(&self) -> IglooStatus
{ {
for target in &self.targets for target in &self.targets
@ -265,11 +282,18 @@ impl<'a> IglooProject<'a>
pub fn generate_igloo_header(&self) -> IglooStatus pub fn generate_igloo_header(&self) -> IglooStatus
{ {
IS_BAD IS_GOOD
} }
pub fn generate_igloo_main(&self) -> IglooStatus pub fn generate_igloo_main(&self) -> IglooStatus
{ {
IS_GOOD IS_GOOD
} }
pub fn generate_project_config(&self) -> IglooStatus
{
let mut ret = IS_GOOD;
Settings::to_project_file(self);
ret
}
} }

@ -13,17 +13,14 @@
// I could make the deserialization work by default by adding a billion different // I could make the deserialization work by default by adding a billion different
// structs, but this is honestly just a trash way of doing it and I think the idea // structs, but this is honestly just a trash way of doing it and I think the idea
// of doing it that way is only an ideal solution. It isn't very practical. // of doing it that way is only an ideal solution. It isn't very practical.
use igloo_util::*;
use crate::Igloo; use crate::Igloo;
use crate::IglooStatus;
use crate::IglooStatus::*;
use crate::IglooProject; use crate::IglooProject;
use serde::{Serialize, Deserialize}; use serde::{Serialize, Deserialize};
use config::Config;
use std::fs::{OpenOptions, File};
use std::vec::Vec; use std::vec::Vec;
use std::io::prelude::*; use igloo_util::IglooDebugSeverity::*;
use std::path::PathBuf; use igloo_util::IglooStatus::{self, *};
use std::collections::HashMap; use igloo_util::TRACE_LEVEL;
#[derive(Serialize, Deserialize, Debug)] #[derive(Serialize, Deserialize, Debug)]
pub struct IglooTarget pub struct IglooTarget
@ -40,7 +37,7 @@ pub struct IglooTarget
impl IglooTarget impl IglooTarget
{ {
fn default() -> IglooTarget fn _default() -> IglooTarget
{ {
IglooTarget IglooTarget
{ {
@ -59,20 +56,46 @@ impl IglooTarget
/// deserializes the targets manifest file and creates the target /// deserializes the targets manifest file and creates the target
pub fn target_from_name(igloo: &Igloo, name: String) -> Result<IglooTarget, IglooStatus> pub fn target_from_name(igloo: &Igloo, name: String) -> Result<IglooTarget, IglooStatus>
{ {
let target_path = &igloo.master_target_manifest.targets[&name]; let target_path = igloo
let mut target_config = config::Config::default(); .env
.esfd
.clone()
.join(&igloo.master_target_manifest.targets[&name]);
// We have to read in the file first so we can replace all variables with values
let targ_templ = match std::fs::read_to_string(&target_path)
{
Ok(v) => v,
Err(e) =>
{
igloo_debug!(ERROR,
IS_BAD,
"Failed to read {} | Error: {:?}",
&target_path.to_str().unwrap(),
e);
return Err(IS_BAD)
}
};
// replace all variables
// this will be expanded on later and more variables will be added
let final_targ_str = targ_templ.replace("${TARGET}", &name);
// create config from our string
let mut target_config: config::Config = config::Config::default();
target_config.merge( target_config.merge(
config::File::with_name( config::File::from_str(
igloo.env &final_targ_str, config::FileFormat::Toml)).unwrap();
.esfd
.clone() // get [esf] (which is technically a table...) from our config
.join(&target_path) let target_table: config::Value = target_config.get("esf").unwrap();
.to_str().unwrap()
)).unwrap(); // turn it into an IglooTarget
let mut target_table: config::Value = target_config.get("esf").unwrap();
let ret_target = target_table.try_into::<IglooTarget>().unwrap(); let ret_target = target_table.try_into::<IglooTarget>().unwrap();
println!("{:?}", ret_target); igloo_debug!(INFO,
IS_NONE,
"Found Igloo target and deserialized it: {:?}",
ret_target);
Ok(ret_target) Ok(ret_target)

@ -1,41 +0,0 @@
use crate::IglooStatus::{self, *};
use crate::IglooType::{self, *};
use crate::IglooDebugSeverity::{self, *};
pub static TRACE_LEVEL: IglooDebugSeverity = TRACE;
macro_rules! igloo_debug
{
($severity:expr, $status:expr) =>
{
if cfg!(debug_assertions)
{
if $severity as u8 <= TRACE_LEVEL.clone() as u8
{
println!("[{:?}]: Line {:?} in {:?} | {:?}",
$severity,
line!(),
file!(),
$status);
}
}
};
($severity:expr, $status:expr, $($message:tt)*) =>
{
if cfg!(debug_assertions)
{
if $severity as u8 <= TRACE_LEVEL.clone() as u8
{
println!("[{:?}]: Line {:?} in {} | {} -- STATUS: {:?}",
$severity,
line!(),
file!(),
format_args!($($message)*),
$status
);
}
}
};
}
pub(crate) use igloo_debug;

@ -1,8 +1,10 @@
#![allow(warnings)] #![allow(non_snake_case)]
extern crate clap; #![allow(non_camel_case_types)]
extern crate config;
extern crate toml; pub extern crate clap;
extern crate serde; pub extern crate config;
pub extern crate toml;
pub extern crate serde;
use config::Config; use config::Config;
use std::path::PathBuf; use std::path::PathBuf;
@ -15,69 +17,18 @@ pub mod igloo_project;
pub mod igloo_manifest; pub mod igloo_manifest;
pub mod igloo_cli; pub mod igloo_cli;
pub mod igloo_env; pub mod igloo_env;
pub mod igloo_util;
use igloo_cli::IglooCliInfo; use igloo_cli::IglooCliInfo;
use igloo_env::IglooEnv; use igloo_env::IglooEnv;
use igloo_project::IglooProject; use igloo_project::IglooProject;
use igloo_manifest::IglooTargetManifest; use igloo_manifest::IglooTargetManifest;
use igloo_util::*;
#[derive(Debug)]
#[derive(PartialEq)]
/// * IT_NEW: Create a new igloo project
/// * IT_RUN: build the project if needed, then run the project, defaults to default target set in your project's profile
/// * IT_PUSH: build the project if needed, then upload your binary to your target
/// * IT_PULL: extracts binary from mcu (if possible) and saves it
/// * IT_HELP: gets help
/// * IT_BUILD: builds the project for all targets unless otherwise specified
/// * IT_ERASE: erases the flash for the specified target
/// * IT_INFO: Gets information about igloo and your project.
/// * IT_NULL: Default type... used for debugging and development. More on this later
/// * IT_DEBUG: this state is useful for debugging project failures. Only to be used in debug build of igloo. More on this later
pub enum IglooType
{
IT_NEW = 0,
IT_RUN,
IT_PUSH,
IT_PULL,
IT_HELP,
IT_BUILD,
IT_ERASE,
IT_INFO,
IT_TARGET,
IT_NULL,
IT_DEBUG,
}
#[derive(Debug, PartialEq, Clone)]
pub enum IglooDebugSeverity
{
ERROR = 0,
WARNING = 1,
LOG = 2,
TRACE = 3,
INFO = 4,
}
#[derive(Debug)] #[macro_use] extern crate igloo_util;
#[derive(PartialEq)] use igloo_util::IglooDebugSeverity::{self, *};
pub enum IglooStatus use igloo_util::IglooStatus::{self, *};
{ use igloo_util::IglooType::{self, *};
IS_GOOD = 0x00, use igloo_util::TRACE_LEVEL;
IS_BAD = 0x01,
IS_UNKNOWN = 0x02,
IS_FAILED_TO_LOAD_MTM = 0x03,
IS_NEW_CALLED_IN_EXISTING_PRJ = 0x04,
IS_NEW_DIR_ALREADY_EXISTS = 0x05,
IS_NONE = 0xFF,
}
use IglooStatus::*;
use IglooType::*;
use IglooDebugSeverity::*;
pub struct Igloo pub struct Igloo
{ {
@ -142,9 +93,10 @@ impl Igloo
{ {
IT_NEW => IT_NEW =>
{ {
return igloo_action::ia_new(self, res_err = igloo_action::ia_new(self,
igloo_cli::ich_new_get_project_name(self), igloo_cli::ich_new_get_project_name(self),
igloo_cli::ich_new_get_target_name(self)) igloo_cli::ich_new_get_target_name(self));
println!("Value of res_err is: {:?}", res_err);
} }
IT_RUN => IT_RUN =>
{ {

@ -0,0 +1,8 @@
[package]
name = "igloo_util"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]

@ -0,0 +1,101 @@
#![allow(non_snake_case)]
#![allow(non_camel_case_types)]
#[cfg(test)]
mod tests {
#[test]
fn it_works() {
let result = 2 + 2;
assert_eq!(result, 4);
}
}
#[derive(Debug)]
#[derive(PartialEq)]
/// * IT_NEW: Create a new igloo project
/// * IT_RUN: build the project if needed, then run the project, defaults to default target set in your project's profile
/// * IT_PUSH: build the project if needed, then upload your binary to your target
/// * IT_PULL: extracts binary from mcu (if possible) and saves it
/// * IT_HELP: gets help
/// * IT_BUILD: builds the project for all targets unless otherwise specified
/// * IT_ERASE: erases the flash for the specified target
/// * IT_INFO: Gets information about igloo and your project.
/// * IT_NULL: Default type... used for debugging and development. More on this later
/// * IT_DEBUG: this state is useful for debugging project failures. Only to be used in debug build of igloo. More on this later
pub enum IglooType
{
IT_NEW = 0,
IT_RUN,
IT_PUSH,
IT_PULL,
IT_HELP,
IT_BUILD,
IT_ERASE,
IT_INFO,
IT_TARGET,
IT_NULL,
IT_DEBUG,
}
#[derive(Debug, PartialEq, Clone)]
pub enum IglooDebugSeverity
{
ERROR = 0,
WARNING = 1,
LOG = 2,
TRACE = 3,
INFO = 4,
}
#[derive(Debug)]
#[derive(PartialEq)]
pub enum IglooStatus
{
IS_GOOD = 0x00,
IS_BAD = 0x01,
IS_UNKNOWN = 0x02,
IS_FAILED_TO_LOAD_MTM = 0x03,
IS_NEW_CALLED_IN_EXISTING_PRJ = 0x04,
IS_NEW_DIR_ALREADY_EXISTS = 0x05,
IS_FAILED_TO_CREATE_PRJ_CFG_FILE = 0x06,
IS_FAILED_TO_CREATE_DIR = 0x07,
IS_NONE = 0xFF,
}
pub static TRACE_LEVEL: IglooDebugSeverity = IglooDebugSeverity::TRACE;
#[macro_export]
macro_rules! igloo_debug
{
($severity:expr, $status:expr) =>
{
if cfg!(debug_assertions)
{
if $severity as u8 <= TRACE_LEVEL.clone() as u8
{
println!("[{:?}]: Line {:?} in {:?} | {:?}",
$severity,
line!(),
file!(),
$status);
}
}
};
($severity:expr, $status:expr, $($message:tt)*) =>
{
if cfg!(debug_assertions)
{
if $severity as u8 <= TRACE_LEVEL.clone() as u8
{
println!("[{:?}]: Line {:?} in {} | {} -- STATUS: {:?}",
$severity,
line!(),
file!(),
format_args!($($message)*),
$status
);
}
}
};
}

@ -1,7 +1,14 @@
#![allow(warnings)] // #![allow(warnings)]
#![allow(non_snake_case)]
#![allow(non_camel_case_types)]
use igloo_core::Igloo; use igloo_core::Igloo;
#[macro_use] extern crate igloo_util;
use igloo_util::IglooDebugSeverity::{self, *};
use igloo_util::IglooStatus::{self, *};
use igloo_util::IglooType::{self, *};
use igloo_util::TRACE_LEVEL;
fn main() fn main()
{ {
let mut ig = Igloo::new(); let mut ig = Igloo::new();
@ -11,8 +18,9 @@ fn main()
{ {
match ig.run(it) match ig.run(it)
{ {
IS_GOOD => println!("success"), IS_GOOD => (),
_ => println!("??"), // this is actually so dumb and should not exist in any language
ANYTHING_ELSE => igloo_debug!(ERROR, ANYTHING_ELSE),
} }
} }
Err(e) => println!("Error: {:?}", e), Err(e) => println!("Error: {:?}", e),

Loading…
Cancel
Save