adding config stuff. think im going to split it up later, but this is fine for now

unstable
Penguin 4 years ago
parent 3231752235
commit 688d14bf9b

BIN
GPATH

Binary file not shown.

67
src/\

@ -1,67 +0,0 @@
#[macro_use]
extern crate clap;
use clap::{Arg, App};
fn main()
{
let str1 = "v";
let str2 = crate_version!();
let str3 = str1.to_owned() + str2;
println!("{}", str3);
let matches = App::new("Igloo")
.version(&*("v".to_owned() + crate_version!()))
.author(crate_authors!())
.about("Stuff")
.arg(Arg::with_name("v")
.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 and runs project on target selected in config file")
.arg(Arg::new("RELEASE")
.short('R')
.long("release")
.about("Run as the release build"))
.arg(Arg::new("DEBUG")
.short('D')
.long("debug")
.about("Run as the debug build"))
.arg(Arg::new("FRESH")
.short('F')
.long("fresh")
.about("Clean project, compile, and run")))
.subcommand(App::new("clean")
.about("Cleans project")
.version("0.0")
.arg(Arg::new("debug")
.short('d')
.about("print some debug information verbosely")))
.get_matches();
match matches.subcommand()
{
("new", Some(new_matches)) =>
{
println!("Creating new project named {}", new_matches.value_of("NAME").unwrap());
}
("run", Some(run_matches)) =>
{
("RELEASE") => println!("Running as release build"),
("DEBUG") => println!("Running as debug build"),
("FRESH") => println!("Running as fresh!"),
("", None) => println!("No subarg was used!"),
_ => unreachable!(),
}
("", None) => println!("No subcommand was used"),
_ => unreachable!(),
}
}

@ -3,6 +3,10 @@ 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,
@ -32,7 +36,7 @@ fn main()
author: crate_authors!().to_owned(),
description: crate_description!().to_owned(),
};
let matches = App::new(_igloo.name)
let matches = App::new(&*_igloo.name)
.version(&*_igloo.version)
.author(&*_igloo.author)
.about(&*_igloo.description)
@ -87,7 +91,7 @@ fn main()
{
("new", Some(new_matches)) =>
{
println!("Creating new project named {}", new_matches.value_of("NAME").unwrap());
igloo_new(&_igloo, new_matches.value_of("NAME").unwrap());
}
("run", Some(run_matches)) =>
@ -114,6 +118,8 @@ fn main()
_igloo.debug_mode = false;
}
igloo_run(&_igloo);
}
("build", Some(build_matches)) =>
@ -143,7 +149,35 @@ fn main()
_ => 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!");
}
}
fn igloo_run(igloo_inst: &Igloo)
{

@ -0,0 +1,67 @@
use std::vec::Vec;
use std::string::String;
use std::collections::HashMap;
use std::fmt::Display;
use config::*;
struct McuManifest
{
ep_deps: HashMap<String, config::Value>,
makefile_default_src_files: Vec<config::Value>,
makefile_default_inc_dirs: Vec<config::Value>,
drivers: Vec<config::Value>,
modules: Vec<config::Value>,
}
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(),
}
}
Loading…
Cancel
Save