generating projects works 100% verified on samd21j18a and samd21j17a

unstable
penguin 4 years ago
parent b7d2f01c10
commit 717ee81b7f

72
Cargo.lock generated

@ -9,6 +9,12 @@ dependencies = [
"memchr", "memchr",
] ]
[[package]]
name = "arrayvec"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8"
[[package]] [[package]]
name = "atty" name = "atty"
version = "0.2.14" version = "0.2.14"
@ -32,6 +38,12 @@ version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
[[package]]
name = "cfg-if"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
[[package]] [[package]]
name = "clap" name = "clap"
version = "3.0.0-beta.2" version = "3.0.0-beta.2"
@ -42,7 +54,7 @@ dependencies = [
"bitflags", "bitflags",
"clap_derive", "clap_derive",
"indexmap", "indexmap",
"lazy_static 1.4.0", "lazy_static",
"os_str_bytes", "os_str_bytes",
"strsim", "strsim",
"termcolor", "termcolor",
@ -66,11 +78,11 @@ dependencies = [
[[package]] [[package]]
name = "config" name = "config"
version = "0.9.3" version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f9107d78ed62b3fa5a86e7d18e647abed48cfd8f8fab6c72f4cdb982d196f7e6" checksum = "19b076e143e1d9538dde65da30f8481c2a6c44040edb8e02b9bf1351edb92ce3"
dependencies = [ dependencies = [
"lazy_static 1.4.0", "lazy_static",
"nom", "nom",
"rust-ini", "rust-ini",
"serde 1.0.114", "serde 1.0.114",
@ -123,15 +135,22 @@ checksum = "dc6f3ad7b9d11a0c00842ff8de1b60ee58661048eb8049ed33c73594f359d7e6"
[[package]] [[package]]
name = "lazy_static" name = "lazy_static"
version = "0.2.11" version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "76f033c7ad61445c5b347c7382dd1237847eb1bce590fe50365dcb33d546be73" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]] [[package]]
name = "lazy_static" name = "lexical-core"
version = "1.4.0" version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" checksum = "db65c6da02e61f55dae90a0ae427b2a5f6b3e8db09f58d10efab23af92592616"
dependencies = [
"arrayvec",
"bitflags",
"cfg-if",
"ryu",
"static_assertions",
]
[[package]] [[package]]
name = "libc" name = "libc"
@ -163,12 +182,13 @@ checksum = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400"
[[package]] [[package]]
name = "nom" name = "nom"
version = "4.2.3" version = "5.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2ad2a91a8e869eeb30b9cb3119ae87773a8f4ae617f41b1eb9c154b2905f7bd6" checksum = "ffb4262d26ed83a1c0a33a38fe2bb15797329c85770da05e6b828ddb782627af"
dependencies = [ dependencies = [
"lexical-core",
"memchr", "memchr",
"version_check 0.1.5", "version_check",
] ]
[[package]] [[package]]
@ -205,7 +225,7 @@ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn", "syn",
"version_check 0.9.2", "version_check",
] ]
[[package]] [[package]]
@ -216,7 +236,7 @@ checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"version_check 0.9.2", "version_check",
] ]
[[package]] [[package]]
@ -281,11 +301,11 @@ checksum = "5317f7588f0a5078ee60ef675ef96735a1442132dc645eb1d12c018620ed8cd3"
[[package]] [[package]]
name = "serde-hjson" name = "serde-hjson"
version = "0.8.2" version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b833c5ad67d52ced5f5938b2980f32a9c1c5ef047f0b4fb3127e7a423c76153" checksum = "6a3a4e0ea8a88553209f6cc6cfe8724ecad22e1acf372793c27d995290fe74f8"
dependencies = [ dependencies = [
"lazy_static 0.2.11", "lazy_static",
"linked-hash-map 0.3.0", "linked-hash-map 0.3.0",
"num-traits 0.1.43", "num-traits 0.1.43",
"regex", "regex",
@ -312,6 +332,12 @@ dependencies = [
"serde 0.8.23", "serde 0.8.23",
] ]
[[package]]
name = "static_assertions"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
[[package]] [[package]]
name = "strsim" name = "strsim"
version = "0.10.0" version = "0.10.0"
@ -353,14 +379,14 @@ version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14" checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14"
dependencies = [ dependencies = [
"lazy_static 1.4.0", "lazy_static",
] ]
[[package]] [[package]]
name = "toml" name = "toml"
version = "0.4.10" version = "0.5.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "758664fc71a3a69038656bee8b6be6477d2a6c315a6b81f7081f591bffa4111f" checksum = "75cf45bb0bef80604d001caaec0d09da99611b3c0fd39d3080468875cdb65645"
dependencies = [ dependencies = [
"serde 1.0.114", "serde 1.0.114",
] ]
@ -389,12 +415,6 @@ version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
[[package]]
name = "version_check"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd"
[[package]] [[package]]
name = "version_check" name = "version_check"
version = "0.9.2" version = "0.9.2"

@ -11,4 +11,4 @@ license="GPL-3.0+"
[dependencies] [dependencies]
clap = "3.0.0-beta.2" clap = "3.0.0-beta.2"
config = "0.9" config = "0.10"

3
package-lock.json generated

@ -0,0 +1,3 @@
{
"lockfileVersion": 1
}

@ -1,6 +1,10 @@
use crate::igloo::{Igloo, IglooEnvInfo, IglooErrType}; use crate::igloo::{Igloo, IglooEnvInfo, IglooErrType};
use crate::igloo_manifest::IglooManifest; use crate::igloo_manifest::IglooManifest;
use std::collections::HashMap; use std::collections::HashMap;
use std::fs::OpenOptions;
use std::fs::File;
use std::io::prelude::*;
use std::os::unix::fs;
// New Project // New Project
// --- Verify location // --- Verify location
// --- Populate base folders // --- Populate base folders
@ -13,13 +17,20 @@ pub struct IglooPrj
{ {
name: String, name: String,
target_bank: Vec<IglooTarget>, target_bank: Vec<IglooTarget>,
project_dir: std::path::PathBuf,
}
pub struct IglooTargetManifest
{
links: HashMap<String, config::Value>,
includes: Vec<config::Value>,
} }
pub struct IglooTarget pub struct IglooTarget
{ {
name: String, name: String,
make_manifest: HashMap<String, config::Value>, make_manifest: HashMap<String, config::Value>,
target_manifest: HashMap<String, config::Value>, target_manifest: IglooTargetManifest,
} }
impl IglooPrj impl IglooPrj
@ -30,6 +41,7 @@ impl IglooPrj
{ {
name: String::from(""), name: String::from(""),
target_bank: Vec::default(), target_bank: Vec::default(),
project_dir: std::path::PathBuf::default(),
} }
} }
@ -75,7 +87,7 @@ impl IglooPrj
let mut temp: Vec<IglooTarget> = Vec::new(); let mut temp: Vec<IglooTarget> = Vec::new();
let targ = IglooTarget::from( let targ = IglooTarget::from(
inst, inst,
targetIn, String::from(targetIn),
&_targ_make_table_name, &_targ_make_table_name,
&_targ_manifest_file_name).unwrap(); &_targ_manifest_file_name).unwrap();
temp.push(targ); temp.push(targ);
@ -84,6 +96,7 @@ impl IglooPrj
{ {
name: String::from(nameIn), name: String::from(nameIn),
target_bank: temp, target_bank: temp,
project_dir: IglooEnvInfo::info().cwd.join(nameIn),
}) })
} }
@ -109,6 +122,15 @@ impl IglooPrj
Err(e) => println!("{:?}", e), Err(e) => println!("{:?}", e),
_ => (), _ => (),
} }
match std::fs::create_dir(
std::path::Path::new(&active_dir)
.join(".igloo/target"))
{
Err(e) => println!("{:?}", e),
_ => (),
}
match std::fs::create_dir( match std::fs::create_dir(
std::path::Path::new(&active_dir) std::path::Path::new(&active_dir)
.join("src")) .join("src"))
@ -138,22 +160,12 @@ impl IglooPrj
_ => (), _ => (),
} }
// load targets
//create symlinks in ESF
match std::os::unix::fs::symlink("", "")
{
Err(e) => println!("{:?}", e),
_ => (),
}
println!("Displaying contents of {:?}", active_dir.display());
for entry in active_dir.read_dir()
.unwrap()
{
let dir = entry.unwrap();
println!("{:?}", dir.file_name());
}
self.debugManifests();
self.gen_targets();
self.gen_igloo_header();
self.gen_igloo_main();
//self.debugManifests();
IglooErrType::IGLOO_ERR_NONE IglooErrType::IGLOO_ERR_NONE
} }
@ -162,7 +174,7 @@ impl IglooPrj
for target in &self.target_bank for target in &self.target_bank
{ {
println!("Target manifest:"); println!("Target manifest:");
for (key, val) in &target.target_manifest for (key, val) in &target.target_manifest.links
{ {
println!("{} = {:?}", key, val); println!("{} = {:?}", key, val);
} }
@ -177,6 +189,805 @@ impl IglooPrj
/// Generates the target directories for all targets /// Generates the target directories for all targets
pub fn gen_targets(&self) -> IglooErrType pub fn gen_targets(&self) -> IglooErrType
{ {
let mut prj_root = self.project_dir.join(".igloo");
for target in &self.target_bank
{
let mut target_root = prj_root.join(&("target/".to_owned() + &target.name));
println!("{:?}", target_root.display());
match std::fs::create_dir(target_root)
{
Err(e) => println!("{:?}", e),
_ => (),
}
let mut prj_esf_dir = self.project_dir.join("ESF");
println!("NEEDED {:?}", prj_esf_dir);
for (sym_dir, loc_in_esf) in &target.target_manifest.links
{
let link_to_dir = IglooEnvInfo::info()
.esfd
.join(&loc_in_esf.clone().into_str().unwrap());
std::os::unix::fs::symlink(link_to_dir, prj_esf_dir.join(sym_dir)).unwrap();
}
self.gen_makefile(&target);
}
IglooErrType::IGLOO_ERR_NONE
}
/// Generates a makefile for a target
pub fn gen_makefile(&self, target: &IglooTarget) -> IglooErrType
{
let mut prj_root = self.project_dir.join(".igloo/target");
let mut target_root = prj_root.join(&target.name);
// If the Makefile already exists, trash it
if target_root.join("Makefile").exists()
{
std::fs::remove_file("Makefile");
}
// Make our Makefile, set it to append mode
std::fs::File::create(target_root.join("Makefile")).unwrap();
let mut app_file = OpenOptions::new()
.write(true)
.append(true)
.open(target_root.join("Makefile"))
.unwrap();
//
writeln!(app_file, "# ePenguin Generated Variables").unwrap();
// Get our knowns out of the way
match target.make_manifest.get("PROJECT_NAME")
{
None =>
{
println!("PROJECT_NAME not found");
}
Some(v) =>
{
write!(app_file, "PROJECT_NAME=").unwrap();
writeln!(app_file, "{}", v.to_string()).unwrap();
},
}
match target.make_manifest.get("TOOLCHAIN")
{
None =>
{
println!("TOOLCHAIN Not found");
}
Some(v) =>
{
write!(app_file, "TOOLCHAIN=").unwrap();
writeln!(app_file, "{}", v.to_string()).unwrap();
},
}
match target.make_manifest.get("CC")
{
None =>
{
println!("CC Not found");
}
Some(v) =>
{
write!(app_file, "CC=").unwrap();
writeln!(app_file, "{}", v.to_string()).unwrap();
},
}
match target.make_manifest.get("CXX")
{
None =>
{
println!("CXX Not found");
}
Some(v) =>
{
write!(app_file, "CXX=").unwrap();
writeln!(app_file, "{}", v.to_string()).unwrap();
},
}
match target.make_manifest.get("OBJCOPY")
{
None =>
{
println!("OBJCOPY Not found");
}
Some(v) =>
{
write!(app_file, "OBJCOPY=").unwrap();
writeln!(app_file, "{}", v.to_string()).unwrap();
},
}
match target.make_manifest.get("OBJDUMP")
{
None =>
{
println!("OBJDUMP Not found");
}
Some(v) =>
{
write!(app_file, "OBJDUMP=").unwrap();
writeln!(app_file, "{}", v.to_string()).unwrap();
},
}
match target.make_manifest.get("GDB")
{
None =>
{
println!("GDB Not found");
}
Some(v) =>
{
write!(app_file, "GDB=").unwrap();
writeln!(app_file, "{}", v.to_string()).unwrap();
},
}
match target.make_manifest.get("SIZE")
{
None =>
{
println!("SIZE Not found");
}
Some(v) =>
{
write!(app_file, "SIZE=").unwrap();
writeln!(app_file, "{}", v.to_string()).unwrap();
},
}
match target.make_manifest.get("AS")
{
None =>
{
println!("AS Not found");
}
Some(v) =>
{
write!(app_file, "AS=").unwrap();
writeln!(app_file, "{}", v.to_string()).unwrap();
},
}
writeln!(app_file, "\n").unwrap();
// MCU Specifics now
match target.make_manifest.get("MCPU")
{
None =>
{
println!("MCPU Not found");
}
Some(v) =>
{
write!(app_file, "MCPU=").unwrap();
writeln!(app_file, "{}", v.to_string()).unwrap();
},
}
match target.make_manifest.get("MCU")
{
None =>
{
println!("MCU Not found");
}
Some(v) =>
{
write!(app_file, "MCU=").unwrap();
writeln!(app_file, "{}", v.to_string()).unwrap();
},
}
match target.make_manifest.get("LD_PATH")
{
None =>
{
println!("LD_PATH Not found");
}
Some(v) =>
{
write!(app_file, "LD_PATH=").unwrap();
writeln!(app_file, "{}", v.to_string()).unwrap();
},
}
match target.make_manifest.get("LD_SCRIPT")
{
None =>
{
println!("LD_SCRIPT Not found");
}
Some(v) =>
{
write!(app_file, "LD_SCRIPT=").unwrap();
writeln!(app_file, "{}", v.to_string()).unwrap();
},
}
writeln!(app_file, "\n").unwrap();
// CFLAGS
match target.make_manifest.get("CFLAGS")
{
None =>
{
println!("CFLAGS Not found");
}
Some(v) =>
{
write!(app_file, "CFLAGS=").unwrap();
for cflag in v.clone().into_array().unwrap()
{
writeln!(app_file, " \\").unwrap();
write!(app_file, "{}", cflag).unwrap();
}
},
}
writeln!(app_file, "\n").unwrap();
// ELF FLAGS
match target.make_manifest.get("ELF_FLAGS")
{
None =>
{
println!("ELF_FLAGS Not found");
}
Some(v) =>
{
write!(app_file, "ELF_FLAGS=").unwrap();
for cflag in v.clone().into_array().unwrap()
{
writeln!(app_file, " \\").unwrap();
write!(app_file, "{}", cflag).unwrap();
}
},
}
writeln!(app_file, "\n").unwrap();
// HEX FLAGS
match target.make_manifest.get("HEX_FLAGS")
{
None =>
{
println!("HEX_FLAGS Not found");
}
Some(v) =>
{
write!(app_file, "HEX_FLAGS=").unwrap();
for cflag in v.clone().into_array().unwrap()
{
writeln!(app_file, " \\").unwrap();
write!(app_file, "{}", cflag).unwrap();
}
},
}
writeln!(app_file, "\n").unwrap();
match target.make_manifest.get("EEP_FLAGS")
{
None =>
{
println!("EEP_FLAGS Not found");
}
Some(v) =>
{
write!(app_file, "EEP_FLAGS=").unwrap();
for cflag in v.clone().into_array().unwrap()
{
writeln!(app_file, " \\").unwrap();
write!(app_file, "{}", cflag).unwrap();
}
},
}
writeln!(app_file, "\n").unwrap();
// Write SystemRoot config stuff for cross compatibility
let sysroot: String = String::from("
ifdef SystemRoot
SHELL = cmd.exe
MK_DIR = mkdir
else
ifeq ($(shell uname), Linux)
MK_DIR = mkdir -p
endif
ifeq ($(shell uname | cut -d _ -f 1), CYGWIN)
MK_DIR = mkdir -p
endif
ifeq ($(shell uname | cut -d _ -f 1), MINGW32)
MK_DIR = mkdir -p
endif
ifeq ($(shell uname | cut -d _ -f 1), MINGW64)
MK_DIR = mkdir -p
endif
ifeq ($(shell uname | cut -d _ -f 1), DARWIN)
MK_DIR = mkdir -p
endif
endif");
writeln!(app_file, "{}", sysroot).unwrap();
match target.make_manifest.get("SUB_DIRS")
{
None =>
{
println!("SUB_DIRS Not found");
}
Some(v) =>
{
write!(app_file, "SUB_DIRS+=").unwrap();
for cflag in v.clone().into_array().unwrap()
{
writeln!(app_file, " \\").unwrap();
write!(app_file, "{}", cflag).unwrap();
}
},
}
writeln!(app_file, "\n").unwrap();
match target.make_manifest.get("OBJS")
{
None =>
{
println!("OBJS Not found");
}
Some(v) =>
{
write!(app_file, "OBJS+=").unwrap();
for cflag in v.clone().into_array().unwrap()
{
writeln!(app_file, " \\").unwrap();
write!(app_file, "{}", cflag).unwrap();
}
},
}
writeln!(app_file, "\n").unwrap();
match target.make_manifest.get("OBJS_AS_ARGS")
{
None =>
{
println!("OBJS_AS_ARGS Not found");
}
Some(v) =>
{
write!(app_file, "OBJS_AS_ARGS+=").unwrap();
for cflag in v.clone().into_array().unwrap()
{
writeln!(app_file, " \\").unwrap();
write!(app_file, "{}", cflag).unwrap();
}
},
}
writeln!(app_file, "\n").unwrap();
match target.make_manifest.get("DIR_INCLUDES")
{
None =>
{
println!("DIR_INCLUDES Not found");
}
Some(v) =>
{
write!(app_file, "DIR_INCLUDES+=").unwrap();
for cflag in v.clone().into_array().unwrap()
{
writeln!(app_file, " \\").unwrap();
write!(app_file, "{}", cflag).unwrap();
}
},
}
write!(app_file, "\n\n").unwrap();
match target.make_manifest.get("DEPS")
{
None =>
{
println!("DEPS Not found");
}
Some(v) =>
{
write!(app_file, "DEPS:=").unwrap();
writeln!(app_file, "{}", v.to_string()).unwrap();
},
}
write!(app_file, "\n").unwrap();
match target.make_manifest.get("DEPS_AS_ARGS")
{
None =>
{
println!("DEPS_AS_ARGS Not found");
}
Some(v) =>
{
write!(app_file, "DEPS_AS_ARGS:=").unwrap();
writeln!(app_file, "{}", v.to_string()).unwrap();
},
}
writeln!(app_file, "\nvpath %.c ../../../").unwrap();
writeln!(app_file, "vpath %.s ../../../").unwrap();
writeln!(app_file, "vpath %.S ../../../\n").unwrap();
writeln!(app_file, ".PHONY: debug clean\n").unwrap();
match target.make_manifest.get("ALL_PREREQS")
{
None =>
{
println!("ALL_PREREQS Not found");
}
Some(v) =>
{
write!(app_file, "all:").unwrap();
for cflag in v.clone().into_array().unwrap()
{
writeln!(app_file, "\\").unwrap();
write!(app_file, "{}", cflag).unwrap();
}
},
}
match target.make_manifest.get("ALL_CMDS")
{
None =>
{
println!("ALL_CMDS Not found");
}
Some(v) =>
{
write!(app_file, "\n\t").unwrap();
for cflag in v.clone().into_array().unwrap()
{
writeln!(app_file, "\\").unwrap();
write!(app_file, "\t{}", cflag).unwrap();
}
},
}
write!(app_file, "\n\n").unwrap();
match target.make_manifest.get("ELF_TARGET_PREREQS")
{
None =>
{
println!("ELF_TARGET_PREREQS Not found");
}
Some(v) =>
{
write!(app_file, "$(PROJECT_NAME).elf:").unwrap();
for cflag in v.clone().into_array().unwrap()
{
writeln!(app_file, "\\").unwrap();
write!(app_file, "{}", cflag).unwrap();
}
},
}
match target.make_manifest.get("ELF_TARGET_CMDS")
{
None =>
{
println!("ELF_TARGET_CMDS Not found");
}
Some(v) =>
{
write!(app_file, "\n\t").unwrap();
for cflag in v.clone().into_array().unwrap()
{
writeln!(app_file, "\\").unwrap();
write!(app_file, "\t{}", cflag).unwrap();
}
},
}
write!(app_file, "\n\n").unwrap();
match target.make_manifest.get("BIN_TARGET_PREREQS")
{
None =>
{
println!("BIN_TARGET_PREREQS Not found");
}
Some(v) =>
{
write!(app_file, "$(PROJECT_NAME).bin:").unwrap();
for cflag in v.clone().into_array().unwrap()
{
writeln!(app_file, "\\").unwrap();
write!(app_file, "{}", cflag).unwrap();
}
},
}
match target.make_manifest.get("BIN_TARGET_CMDS")
{
None =>
{
println!("BIN_TARGET_CMDS Not found");
}
Some(v) =>
{
write!(app_file, "\n\t").unwrap();
for cflag in v.clone().into_array().unwrap()
{
writeln!(app_file, "\\").unwrap();
write!(app_file, "\t{}", cflag).unwrap();
}
},
}
write!(app_file, "\n\n").unwrap();
match target.make_manifest.get("HEX_TARGET_PREREQS")
{
None =>
{
println!("HEX_TARGET_PREREQS Not found");
}
Some(v) =>
{
write!(app_file, "$(PROJECT_NAME).hex:").unwrap();
for cflag in v.clone().into_array().unwrap()
{
writeln!(app_file, "\\").unwrap();
write!(app_file, "{}", cflag).unwrap();
}
},
}
match target.make_manifest.get("HEX_TARGET_CMDS")
{
None =>
{
println!("HEX_TARGET_CMDS Not found");
}
Some(v) =>
{
write!(app_file, "\n\t").unwrap();
for cflag in v.clone().into_array().unwrap()
{
writeln!(app_file, "\\").unwrap();
write!(app_file, "\t{}", cflag).unwrap();
}
},
}
write!(app_file, "\n\n").unwrap();
match target.make_manifest.get("EEP_TARGET_PREREQS")
{
None =>
{
println!("EEP_TARGET_PREREQS Not found");
}
Some(v) =>
{
write!(app_file, "$(PROJECT_NAME).eep:").unwrap();
for cflag in v.clone().into_array().unwrap()
{
writeln!(app_file, "\\").unwrap();
write!(app_file, "{}", cflag).unwrap();
}
},
}
match target.make_manifest.get("EEP_TARGET_CMDS")
{
None =>
{
println!("EEP_TARGET_CMDS Not found");
}
Some(v) =>
{
write!(app_file, "\n\t").unwrap();
for cflag in v.clone().into_array().unwrap()
{
writeln!(app_file, "\\").unwrap();
write!(app_file, "\t{}", cflag).unwrap();
}
},
}
write!(app_file, "\n\n").unwrap();
match target.make_manifest.get("LSS_TARGET_PREREQS")
{
None =>
{
println!("LSS_TARGET_PREREQS Not found");
}
Some(v) =>
{
write!(app_file, "$(PROJECT_NAME).lss:").unwrap();
for cflag in v.clone().into_array().unwrap()
{
writeln!(app_file, "\\").unwrap();
write!(app_file, "{}", cflag).unwrap();
}
},
}
match target.make_manifest.get("LSS_TARGET_CMDS")
{
None =>
{
println!("LSS_TARGET_CMDS Not found");
}
Some(v) =>
{
write!(app_file, "\n\t").unwrap();
for cflag in v.clone().into_array().unwrap()
{
writeln!(app_file, "\\").unwrap();
write!(app_file, "\t{}", cflag).unwrap();
}
},
}
// Compiler Targets
writeln!(app_file, "").unwrap();
writeln!(app_file, "
# Compiler targets
%.o: %.c
@echo Building file: $<
@echo ARM/GNU C Compiler
$(QUOTE)$(CC)$(QUOTE) $(CFLAGS) -o $(QUOTE)$@$(QUOTE) $(QUOTE)$<$(QUOTE)
@echo Finished building: $<").unwrap();
writeln!(app_file, "
%.o: %.s
@echo Building file: $<
@echo ARM/GNU Assembler
$(QUOTE)$(AS)$(QUOTE) $(CFLAGS) -o $(QUOTE)$@$(QUOTE) $(QUOTE)$<$(QUOTE)
@echo Finished building: $<").unwrap();
writeln!(app_file, "
%.o: %.S
@echo Building file: $<
@echo ARM/GNU Preprocessing Assembler
$(QUOTE)$(CC)$(QUOTE) $(CFLAGS) -o $(QUOTE)$@$(QUOTE) $(QUOTE)$<$(QUOTE)
@echo Finished building: $<").unwrap();
writeln!(app_file, "\n").unwrap();
writeln!(app_file, "$(SUB_DIRS):\n\t$(MK_DIR) $(QUOTE)$@$(QUOTE)").unwrap();
writeln!(app_file, "
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(strip $(DEPS)),)
-include $(DEPS)
endif
endif\n").unwrap();
match target.make_manifest.get("CLEAN_PREREQS")
{
None =>
{
println!("CLEAN_TARGET_PREREQS Not found");
}
Some(v) =>
{
write!(app_file, "clean:").unwrap();
for cflag in v.clone().into_array().unwrap()
{
if !cflag.to_string().is_empty()
{
writeln!(app_file, "\\").unwrap();
write!(app_file, "{}", cflag).unwrap()
}
}
},
}
match target.make_manifest.get("CLEAN_CMDS")
{
None =>
{
println!("CLEAN_CMDS Not found");
}
Some(v) =>
{
write!(app_file, "\n\t").unwrap();
for cflag in v.clone().into_array().unwrap()
{
if !cflag.to_string().is_empty()
{
writeln!(app_file, " \\").unwrap();
write!(app_file, "\t{}", cflag).unwrap()
}
}
},
}
writeln!(app_file, "\n").unwrap();
match target.make_manifest.get("DEBUG_PREREQS")
{
None =>
{
println!("DEBUG_TARGET_PREREQS Not found");
}
Some(v) =>
{
write!(app_file, "debug:").unwrap();
for cflag in v.clone().into_array().unwrap()
{
if !cflag.to_string().is_empty()
{
writeln!(app_file, "\\").unwrap();
write!(app_file, "{}", cflag).unwrap()
}
}
},
}
match target.make_manifest.get("DEBUG_CMDS")
{
None =>
{
println!("DEBUG_CMDS Not found");
}
Some(v) =>
{
write!(app_file, "\n\t").unwrap();
for cflag in v.clone().into_array().unwrap()
{
if !cflag.to_string().is_empty()
{
writeln!(app_file, " \\").unwrap();
write!(app_file, "\t{}", cflag).unwrap()
}
}
},
}
writeln!(app_file, "\n\nQUOTE:=\"").unwrap();
IglooErrType::IGLOO_ERR_NONE
}
pub fn gen_igloo_header(&self) -> IglooErrType
{
let mut inc_dir = self.project_dir.join("inc");
if inc_dir.join("igloo.h").exists()
{
std::fs::remove_file(inc_dir.join("igloo.h")).unwrap();
}
File::create(inc_dir.join("igloo.h")).unwrap();
let mut igloo_h_file = OpenOptions::new()
.write(true)
.append(true)
.open(inc_dir.join("igloo.h"))
.unwrap();
for target in &self.target_bank
{
match &target.make_manifest.get("MCU")
{
None =>
{
println!("MCU definition not found in make manifest.\
\nCould not generate igloo.h");
return IglooErrType::IGLOO_ERR_UNKNOWN
}
Some(v) =>
{
writeln!(igloo_h_file, "#ifdef {}",
v.to_string()).unwrap();
}
}
for inc_file in &target.target_manifest.includes
{
writeln!(igloo_h_file, "\t#include \"{}\"", inc_file).unwrap();
}
writeln!(igloo_h_file, "#endif").unwrap();
}
IglooErrType::IGLOO_ERR_NONE
}
pub fn gen_igloo_main(&self) -> IglooErrType
{
let mut src_dir = self.project_dir.join("src");
if src_dir.join("main.c").exists()
{
std::fs::remove_file(src_dir.join("main.c")).unwrap();
}
File::create(src_dir.join("main.c")).unwrap();
let mut igloo_main_c_file = OpenOptions::new()
.write(true)
.append(true)
.open(src_dir.join("main.c"))
.unwrap();
writeln!(igloo_main_c_file, "#include \"igloo.h\"").unwrap();
writeln!(igloo_main_c_file, "\n\nint main()\n{{\n\treturn 0;\n}}").unwrap();
IglooErrType::IGLOO_ERR_NONE IglooErrType::IGLOO_ERR_NONE
} }
@ -190,26 +1001,19 @@ impl IglooTarget
{ {
name: String::from(""), name: String::from(""),
make_manifest: HashMap::default(), make_manifest: HashMap::default(),
target_manifest: HashMap::default(), target_manifest: IglooTargetManifest::default(),
} }
} }
pub fn from(inst: &Igloo, name_in: &str, pub fn from(inst: &Igloo, name_in: String,
target_make_loc: &str, target_make_loc: &str,
target_man_loc: &str) -> Result<IglooTarget, IglooErrType> target_man_loc: &str) -> Result<IglooTarget, IglooErrType>
{ {
// target man first
let mut target_man = config::Config::new();
target_man.merge(
config::File::with_name(
IglooEnvInfo::info().esfd.join(target_man_loc)
.to_str().unwrap()))
.unwrap();
// now make man // now make man
let mut makefile: HashMap<String, config::Value> = HashMap::new(); let mut makefile: HashMap<String, config::Value> = HashMap::new();
let mut make_table_head = &target_make_loc[0..target_make_loc.len()]; let mut make_table_head = &target_make_loc[0..target_make_loc.len()];
println!("{}", make_table_head);
let mut b_quit: bool = false; let mut b_quit: bool = false;
loop loop
{ {
@ -250,11 +1054,45 @@ impl IglooTarget
{ {
name: String::from(name_in), name: String::from(name_in),
make_manifest: makefile, make_manifest: makefile,
target_manifest: target_man.get_table("esf.links").unwrap(), target_manifest: IglooTargetManifest::from(target_man_loc),
}) })
} }
} }
impl IglooTargetManifest
{
pub fn default() -> IglooTargetManifest
{
IglooTargetManifest
{
links: HashMap::default(),
includes: Vec::default(),
}
}
pub fn from(target_man_loc: &str) -> IglooTargetManifest
{
// target man first
let mut target_man = config::Config::new();
target_man.merge(
config::File::with_name(
IglooEnvInfo::info().esfd.join(target_man_loc)
.to_str().unwrap()))
.unwrap();
IglooTargetManifest
{
links: target_man.get_table("esf.links").unwrap(),
includes: target_man.get_table("esf.includes")
.unwrap()
.get("IGLOO_INCLUDES")
.unwrap()
.clone()
.into_array()
.unwrap(),
}
}
}

Loading…
Cancel
Save