From 3e754c166cbe00e7056231c36d85a91470f66e40 Mon Sep 17 00:00:00 2001 From: Penguin Date: Sat, 18 Jul 2020 13:10:22 -0500 Subject: [PATCH] trying to fix things --- Cargo.lock | 196 +++++++++++++++++++++++++++ Cargo.toml | 3 +- src/igloo.rs | 168 +++++++++++++++++++++++ src/main.rs | 370 ++++++++++++++++++++++++--------------------------- src/util.rs | 67 ---------- 5 files changed, 541 insertions(+), 263 deletions(-) create mode 100644 src/igloo.rs delete mode 100644 src/util.rs diff --git a/Cargo.lock b/Cargo.lock index af4dbee..1e284d8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,5 +1,13 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +[[package]] +name = "aho-corasick" +version = "0.7.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "atty" version = "0.2.14" @@ -50,6 +58,21 @@ dependencies = [ "syn 1.0.33 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "config" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "nom 4.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "rust-ini 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.114 (registry+https://github.com/rust-lang/crates.io-index)", + "serde-hjson 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.56 (registry+https://github.com/rust-lang/crates.io-index)", + "toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", + "yaml-rust 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "heck" version = "0.3.1" @@ -71,6 +94,7 @@ name = "igloo" version = "0.1.0" dependencies = [ "clap 3.0.0-beta.1 (registry+https://github.com/rust-lang/crates.io-index)", + "config 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -81,6 +105,16 @@ dependencies = [ "autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "itoa" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "lazy_static" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "lazy_static" version = "1.4.0" @@ -91,6 +125,50 @@ name = "libc" version = "0.2.71" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "linked-hash-map" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "serde 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_test 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "linked-hash-map" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "memchr" +version = "2.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "nom" +version = "4.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "num-traits" +version = "0.1.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "num-traits 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "num-traits" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "os_str_bytes" version = "2.3.1" @@ -136,6 +214,72 @@ dependencies = [ "proc-macro2 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "regex" +version = "1.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "aho-corasick 0.7.13 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.6.18 (registry+https://github.com/rust-lang/crates.io-index)", + "thread_local 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "regex-syntax" +version = "0.6.18" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "rust-ini" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "ryu" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "serde" +version = "0.8.23" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "serde" +version = "1.0.114" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "serde-hjson" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "linked-hash-map 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "serde_json" +version = "1.0.56" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "itoa 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "ryu 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.114 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "serde_test" +version = "0.8.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "serde 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "strsim" version = "0.10.0" @@ -177,6 +321,22 @@ dependencies = [ "unicode-width 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "thread_local" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "toml" +version = "0.4.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "serde 1.0.114 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "unicode-segmentation" version = "1.6.0" @@ -197,6 +357,11 @@ name = "vec_map" version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "version_check" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "version_check" version = "0.9.2" @@ -229,33 +394,64 @@ name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "yaml-rust" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "linked-hash-map 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + [metadata] +"checksum aho-corasick 0.7.13 (registry+https://github.com/rust-lang/crates.io-index)" = "043164d8ba5c4c3035fec9bbee8647c0261d788f3474306f93bb65901cae0e86" "checksum atty 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" "checksum autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d" "checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" "checksum clap 3.0.0-beta.1 (registry+https://github.com/rust-lang/crates.io-index)" = "860643c53f980f0d38a5e25dfab6c3c93b2cb3aa1fe192643d17a293c6c41936" "checksum clap_derive 3.0.0-beta.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fb51c9e75b94452505acd21d929323f5a5c6c4735a852adbd39ef5fb1b014f30" +"checksum config 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "f9107d78ed62b3fa5a86e7d18e647abed48cfd8f8fab6c72f4cdb982d196f7e6" "checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" "checksum hermit-abi 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "b9586eedd4ce6b3c498bc3b4dd92fc9f11166aa908a914071953768066c67909" "checksum indexmap 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c398b2b113b55809ceb9ee3e753fcbac793f1956663f3c36549c1346015c2afe" +"checksum itoa 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "dc6f3ad7b9d11a0c00842ff8de1b60ee58661048eb8049ed33c73594f359d7e6" +"checksum lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "76f033c7ad61445c5b347c7382dd1237847eb1bce590fe50365dcb33d546be73" "checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" "checksum libc 0.2.71 (registry+https://github.com/rust-lang/crates.io-index)" = "9457b06509d27052635f90d6466700c65095fdf75409b3fbdd903e988b886f49" +"checksum linked-hash-map 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6d262045c5b87c0861b3f004610afd0e2c851e2908d08b6c870cbb9d5f494ecd" +"checksum linked-hash-map 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8dd5a6d5999d9907cda8ed67bbd137d3af8085216c2ac62de5be860bd41f304a" +"checksum memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400" +"checksum nom 4.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2ad2a91a8e869eeb30b9cb3119ae87773a8f4ae617f41b1eb9c154b2905f7bd6" +"checksum num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)" = "92e5113e9fd4cc14ded8e499429f396a20f98c772a47cc8622a736e1ec843c31" +"checksum num-traits 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)" = "ac267bcc07f48ee5f8935ab0d24f316fb722d7a1292e2913f0cc196b29ffd611" "checksum os_str_bytes 2.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "06de47b848347d8c4c94219ad8ecd35eb90231704b067e67e6ae2e36ee023510" "checksum proc-macro-error 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)" = "18f33027081eba0a6d8aba6d1b1c3a3be58cbb12106341c2d5759fcd9b5277e7" "checksum proc-macro-error-attr 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)" = "8a5b4b77fdb63c1eca72173d68d24501c54ab1269409f6b672c85deb18af69de" "checksum proc-macro2 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)" = "beae6331a816b1f65d04c45b078fd8e6c93e8071771f41b8163255bbd8d7c8fa" "checksum quote 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37" +"checksum regex 1.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "9c3780fcf44b193bc4d09f36d2a3c87b251da4a046c87795a0d35f4f927ad8e6" +"checksum regex-syntax 0.6.18 (registry+https://github.com/rust-lang/crates.io-index)" = "26412eb97c6b088a6997e05f69403a802a92d520de2f8e63c2b65f9e0f47c4e8" +"checksum rust-ini 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3e52c148ef37f8c375d49d5a73aa70713125b7f19095948a923f80afdeb22ec2" +"checksum ryu 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" +"checksum serde 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)" = "9dad3f759919b92c3068c696c15c3d17238234498bbdcc80f2c469606f948ac8" +"checksum serde 1.0.114 (registry+https://github.com/rust-lang/crates.io-index)" = "5317f7588f0a5078ee60ef675ef96735a1442132dc645eb1d12c018620ed8cd3" +"checksum serde-hjson 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0b833c5ad67d52ced5f5938b2980f32a9c1c5ef047f0b4fb3127e7a423c76153" +"checksum serde_json 1.0.56 (registry+https://github.com/rust-lang/crates.io-index)" = "3433e879a558dde8b5e8feb2a04899cf34fdde1fafb894687e52105fc1162ac3" +"checksum serde_test 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)" = "110b3dbdf8607ec493c22d5d947753282f3bae73c0f56d322af1e8c78e4c23d5" "checksum strsim 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" "checksum syn 1.0.33 (registry+https://github.com/rust-lang/crates.io-index)" = "e8d5d96e8cbb005d6959f119f773bfaebb5684296108fb32600c00cde305b2cd" "checksum syn-mid 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7be3539f6c128a931cf19dcee741c1af532c7fd387baa739c03dd2e96479338a" "checksum termcolor 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb6bfa289a4d7c5766392812c0a1f4c1ba45afa1ad47803c11e1f407d846d75f" "checksum textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" +"checksum thread_local 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14" +"checksum toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "758664fc71a3a69038656bee8b6be6477d2a6c315a6b81f7081f591bffa4111f" "checksum unicode-segmentation 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e83e153d1053cbb5a118eeff7fd5be06ed99153f00dbcd8ae310c5fb2b22edc0" "checksum unicode-width 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" "checksum unicode-xid 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" "checksum vec_map 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" +"checksum version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd" "checksum version_check 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed" "checksum winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" "checksum winapi-util 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +"checksum yaml-rust 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "39f0c922f1a334134dc2f7a8b67dc5d25f0735263feec974345ff706bcf20b0d" diff --git a/Cargo.toml b/Cargo.toml index 60b34b6..40eefd6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,4 +10,5 @@ license="GPL-3.0+" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -clap = "3.0.0-beta.1" \ No newline at end of file +clap = "3.0.0-beta.1" +config = "0.9" diff --git a/src/igloo.rs b/src/igloo.rs new file mode 100644 index 0000000..3405c00 --- /dev/null +++ b/src/igloo.rs @@ -0,0 +1,168 @@ + + +use std::vec::Vec; +use std::string::String; +use std::collections::HashMap; +use config::*; + +use clap::{Arg, App}; +enum BuildType +{ + Release, + Debug, +} +// used for managing existing igloo projects +// Igloo Project Manager - A struct for holding all +// information pertaining to the current Igloo Project +// An igloo project uses the .igloo folder to maintain +// knowledge of its existence. +pub struct ProjectManager +{ + +} + +// used for managing cli requests for new and existing igloo projects +pub struct CliManager<'b> +{ + app: clap::App<'b>, + debug_mode: bool, + release_mode: bool, + fresh_mode: bool, + version: String, + name: String, + author: &'b str, + description: &'b str, +} + +impl<'b> CliManager<'b> +{ + pub fn new(this: &'b Self) -> Self + { + let _version = "v".to_owned() + crate_version!(); + CliManager + { + version: _version.to_owned(), + name: crate_name!().to_owned(), + author: crate_authors!(), + description: crate_description!(), + debug_mode: true, + release_mode: false, + fresh_mode: false, + app: clap::App::new(this.name) + .author(this.author) + .version(&*this.version) + .about(this.description), + + } + } +} +// Make Manifest contains default flags, files, and +// include directories. User files, flags, and directories +// can be added via the user yml in the cfg folder. They will be +// appended to these lists which are read from the default make manifest +// section in the mcu series yml file +pub struct MakeManifest +{ + linker_script: String, + src_files: Vec, + inc_dirs: Vec, + cflags: Vec, + libs: Vec, + cc: String, + ld: String, + ar: String, +} + +impl MakeManifest +{ + fn from_config(conf: &mut config::Config) -> MakeManifest + { + MakeManifest + { + src_files: conf.get_array("MAKEFILE_DEFAULT_SRC_FILES").unwrap_or_default(), + inc_dirs: conf.get_array("MAKEFILE_DEFAULT_INC_DIRS").unwrap_or_default(), + cflags: conf.get_array("CFLAGS").unwrap_or_default(), + libs: conf.get_array("EP_LIBS").unwrap_or_default(), + cc: conf.get_str("CC").unwrap_or_default(), + ld: conf.get_str("LD").unwrap_or_default(), + ar: conf.get_str("AR").unwrap_or_default(), + linker_script: conf.get_str("LINKER_SCRIPT").unwrap_or_default(), + } + } +} +impl std::fmt::Display for MakeManifest +{ + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result + { + // print src files + for src_file in &self.src_files + { + write!(f, "{}\n", src_file).unwrap(); + } + // print inc dirs + // print cflags + // print cc + // print ld + // print ar + // print default linker script + + Ok(()) + } +} + +// MCU Manifest contains the options for the mcu +// If, for example, a MCU has a USART peripheral, +// it is listed as a driver option here +// The user project manifest's mcu options are compared to the +// available options from the epsf which are stored here once read +struct McuManifest +{ + core_deps: HashMap, + drivers: Vec, + modules: Vec, + +} + +impl McuManifest +{ + + pub fn from_config(conf: &mut config::Config) -> McuManifest + { + McuManifest + { + core_deps: conf.get_table("EP_DEPS").unwrap_or_default(), + drivers: conf.get_array("DRIVERS").unwrap_or_default(), + modules: conf.get_array("MODULES").unwrap_or_default(), + } + } +} + +impl std::fmt::Display for McuManifest +{ + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result + { + // print ep deps + write!(f, "Printing core dependencies:\n").unwrap(); + for dep in &self.core_deps + { + write!(f, "{}: {}\n", &dep.0, &dep.1).unwrap(); + } + + // Available drivers + write!(f, "\nAvailable drivers:\n").unwrap(); + for driver in &self.drivers + { + write!(f, "{}\n", &driver).unwrap(); + } + + // Available modules + write!(f, "\nAvailable modules:\n").unwrap(); + for module in &self.modules + { + write!(f, "{}\n", &module).unwrap(); + } + Ok(()) + } +} + + diff --git a/src/main.rs b/src/main.rs index 6a06882..7d4aa00 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,214 +1,194 @@ +mod igloo; #[macro_use] extern crate clap; -use clap::{Arg, App, ArgGroup}; -use std::str::FromStr; -use std::process; -use std::path::Path; -use std::fs; -use std::fs::{File, OpenOptions}; -use std::os::unix; -enum BuildTypes -{ - Release, - Debug, -} - -struct Igloo -{ - debug_mode: bool, - release_mode: bool, - fresh_mode: bool, - version: String, - name: String, - author: String, - description: String, -} fn main() { - let mut _igloo: Igloo = Igloo - { - debug_mode: true, - release_mode: false, - fresh_mode: false, - version: "v".to_owned() + crate_version!(), - name: String::from("Igloo"), - author: crate_authors!().to_owned(), - description: crate_description!().to_owned(), - }; - let matches = App::new(&*_igloo.name) - .version(&*_igloo.version) - .author(&*_igloo.author) - .about(&*_igloo.description) - .arg(Arg::with_name("VERSION") - .short('v') - .multiple(true) - .about("Sets the level of verbosity")) - .subcommand(App::new("new") - .about("Creates a new igloo project") - .arg( - Arg::new("NAME") - .required(true) - .about("The name of your new project"))) - .subcommand(App::new("run") - .about("Builds project on target selected in config file") - .arg(Arg::new("RELEASE") - .short('R') - .long("release") - .about("builds in release mode")) - .arg(Arg::new("DEBUG") - .short('D') - .long("debug") - .about("builds in debug mode")) - .arg(Arg::new("FRESH") - .short('F') - .long("fresh") - .about("Clean project, then builds project"))) - .subcommand(App::new("build") - .about("Builds project on target selected in config file") - .arg(Arg::new("RELEASE") - .short('R') - .long("release") - .about("builds in release mode")) - .arg(Arg::new("DEBUG") - .short('D') - .long("debug") - .about("builds in debug mode")) - .arg(Arg::new("FRESH") - .short('F') - .long("fresh") - .about("Clean project, then builds project"))) - .subcommand(App::new("clean") - .about("Cleans project") - .version("0.0") - .arg(Arg::new("verbose") - .short('v') - .about("cleans project and prints extra info"))) - .get_matches(); - - - match matches.subcommand() - { - ("new", Some(new_matches)) => - { - igloo_new(&_igloo, new_matches.value_of("NAME").unwrap()); - } - - ("run", Some(run_matches)) => - { - - if run_matches.is_present("FRESH") - { - println!("Building fresh project"); - _igloo.fresh_mode = true; - } - - if run_matches.is_present("RELEASE") && run_matches.is_present("DEBUG") - { - println!("Can't run in debug and release mode..."); - process::exit(1); - } - else if run_matches.is_present("DEBUG") - { - _igloo.debug_mode = true; - } - else if run_matches.is_present("RELEASE") - { - _igloo.release_mode = true; - _igloo.debug_mode = false; - } - - igloo_run(&_igloo); - - - } - ("build", Some(build_matches)) => - { - if build_matches.is_present("FRESH") - { - println!("Building fresh project"); - _igloo.fresh_mode = true; - } - - if build_matches.is_present("RELEASE") && build_matches.is_present("DEBUG") - { - println!("Can't run in debug and release mode..."); - process::exit(1); - } - else if build_matches.is_present("DEBUG") - { - _igloo.debug_mode = true; - } - else if build_matches.is_present("RELEASE") - { - _igloo.release_mode = true; - _igloo.debug_mode = false; - } - } - ("", None) => println!("No subcommand was used"), - _ => unreachable!(), - } -} -fn igloo_new_with_dir(igloo_inst: &Igloo, prj_name: &str, prj_dir: &str) -{ - // WIP -} -fn igloo_new(igloo_inst: &Igloo, prj_name: &str) -{ - let path = Path::new(prj_name); - if path.exists() - { - println!("Project already exists. Exiting..."); - process::exit(1); - } - - println!("Making new project named {}", path.display()); - match fs::create_dir(prj_name) - { - Err(why) => println!("! {:?}", why.kind()), - Ok(_) => {}, - } - - if cfg!(target_family = "unix") - { - println!("You are on unix!\n"); - } - else - { - println!("only unix is currently supported!"); - } + println!("Hi"); + let _igloo = igloo::CliManager::new(); +// let mut _igloo: Igloo = Igloo +// { +// debug_mode: true, +// release_mode: false, +// fresh_mode: false, +// version: "v".to_owned() + crate_version!(), +// name: String::from("Igloo"), +// author: crate_authors!().to_owned(), +// description: crate_description!().to_owned(), +// }; +// let matches = App::new(&*_igloo.name) +// .version(&*_igloo.version) +// .author(&*_igloo.author) +// .about(&*_igloo.description) +// .arg(Arg::with_name("VERSION") +// .short('v') +// .multiple(true) +// .about("Sets the level of verbosity")) +// .subcommand(App::new("new") +// .about("Creates a new igloo project") +// .arg( +// Arg::new("NAME") +// .required(true) +// .about("The name of your new project"))) +// .subcommand(App::new("run") +// .about("Builds project on target selected in config file") +// .arg(Arg::new("RELEASE") +// .short('R') +// .long("release") +// .about("builds in release mode")) +// .arg(Arg::new("DEBUG") +// .short('D') +// .long("debug") +// .about("builds in debug mode")) +// .arg(Arg::new("FRESH") +// .short('F') +// .long("fresh") +// .about("Clean project, then builds project"))) +// .subcommand(App::new("build") +// .about("Builds project on target selected in config file") +// .arg(Arg::new("RELEASE") +// .short('R') +// .long("release") +// .about("builds in release mode")) +// .arg(Arg::new("DEBUG") +// .short('D') +// .long("debug") +// .about("builds in debug mode")) +// .arg(Arg::new("FRESH") +// .short('F') +// .long("fresh") +// .about("Clean project, then builds project"))) +// .subcommand(App::new("clean") +// .about("Cleans project") +// .version("0.0") +// .arg(Arg::new("verbose") +// .short('v') +// .about("cleans project and prints extra info"))) +// .get_matches(); + + +// match matches.subcommand() +// { +// ("new", Some(new_matches)) => +// { +// igloo_new(&_igloo, new_matches.value_of("NAME").unwrap()); +// } + +// ("run", Some(run_matches)) => +// { + +// if run_matches.is_present("FRESH") +// { +// println!("Building fresh project"); +// _igloo.fresh_mode = true; +// } + +// if run_matches.is_present("RELEASE") && run_matches.is_present("DEBUG") +// { +// println!("Can't run in debug and release mode..."); +// process::exit(1); +// } +// else if run_matches.is_present("DEBUG") +// { +// _igloo.debug_mode = true; +// } +// else if run_matches.is_present("RELEASE") +// { +// _igloo.release_mode = true; +// _igloo.debug_mode = false; +// } + +// igloo_run(&_igloo); + + +// } +// ("build", Some(build_matches)) => +// { +// if build_matches.is_present("FRESH") +// { +// println!("Building fresh project"); +// _igloo.fresh_mode = true; +// } + +// if build_matches.is_present("RELEASE") && build_matches.is_present("DEBUG") +// { +// println!("Can't run in debug and release mode..."); +// process::exit(1); +// } +// else if build_matches.is_present("DEBUG") +// { +// _igloo.debug_mode = true; +// } +// else if build_matches.is_present("RELEASE") +// { +// _igloo.release_mode = true; +// _igloo.debug_mode = false; +// } +// } +// ("", None) => println!("No subcommand was used"), +// _ => unreachable!(), +// } } -fn igloo_run(igloo_inst: &Igloo) -{ +// fn igloo_new_with_dir(igloo_inst: &Igloo, prj_name: &str, prj_dir: &str) +// { +// // WIP +// } +// fn igloo_new(igloo_inst: &Igloo, prj_name: &str) +// { +// let path = Path::new(prj_name); +// if path.exists() +// { +// println!("Project already exists. Exiting..."); +// process::exit(1); +// } + +// println!("Making new project named {}", path.display()); +// match fs::create_dir(prj_name) +// { +// Err(why) => println!("! {:?}", why.kind()), +// Ok(_) => {}, +// } + +// if cfg!(target_family = "unix") +// { +// println!("You are on unix!\n"); +// } +// else +// { +// println!("only unix is currently supported!"); +// } +// } +// fn igloo_run(igloo_inst: &Igloo) +// { -} +// } -fn igloo_build(igloo_inst: &Igloo) -{ +// fn igloo_build(igloo_inst: &Igloo) +// { -} +// } -fn igloo_clean(igloo_inst: &Igloo) -{ +// fn igloo_clean(igloo_inst: &Igloo) +// { -} +// } -fn igloo_init(igloo_inst: &Igloo) -{ +// fn igloo_init(igloo_inst: &Igloo) +// { -} +// } -fn igloo_search(igloo_inst: &Igloo) -{ +// fn igloo_search(igloo_inst: &Igloo) +// { -} +// } -fn igloo_test(igloo_inst: &Igloo) -{ +// fn igloo_test(igloo_inst: &Igloo) +// { -} +// } -fn igloo_doc(igloo_inst: &Igloo) -{ +// fn igloo_doc(igloo_inst: &Igloo) +// { -} +// } diff --git a/src/util.rs b/src/util.rs deleted file mode 100644 index 0d31878..0000000 --- a/src/util.rs +++ /dev/null @@ -1,67 +0,0 @@ -use std::vec::Vec; -use std::string::String; -use std::collections::HashMap; -use std::fmt::Display; -use config::*; - -struct McuManifest -{ - ep_deps: HashMap, - makefile_default_src_files: Vec, - makefile_default_inc_dirs: Vec, - drivers: Vec, - modules: Vec, -} -impl Display for McuManifest -{ - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result - { - // print ep deps - write!(f, "Printing EP DEPS:\n").unwrap(); - for dep in &self.ep_deps - { - write!(f, "{}: {}\n", &dep.0, &dep.1).unwrap(); - } - - // print makefile default src files - write!(f, "\nDefault makefile sources:\n").unwrap(); - for src_file in &self.makefile_default_src_files - { - write!(f, "{}\n", &src_file).unwrap(); - } - - // print makefile default inc dirs - for inc_dir in &self.makefile_default_inc_dirs - { - write!(f, "{}\n", &inc_dir).unwrap(); - } - - // Available drivers - write!(f, "\nAvailable drivers:\n").unwrap(); - for driver in &self.drivers - { - write!(f, "{}\n", &driver).unwrap(); - } - - // Available modules - write!(f, "\nAvailable modules:\n").unwrap(); - for module in &self.modules - { - write!(f, "{}\n", &module).unwrap(); - } - - Ok(()) - } -} - -fn yml_to_mcu_manifest(conf: &mut config::Config) -> McuManifest -{ - McuManifest - { - ep_deps: conf.get_table("EP_DEPS").unwrap_or_default(), - makefile_default_inc_dirs: conf.get_array("MAKEFILE_DEFAULT_INC_DIRS").unwrap_or_default(), - makefile_default_src_files: conf.get_array("MAKEFILE_DEFAULT_SRC_FILES").unwrap_or_default(), - drivers: conf.get_array("DRIVERS").unwrap_or_default(), - modules: conf.get_array("MODULES").unwrap_or_default(), - } -}