From ee9d80a80b4e0dc0db6a57e30afb59824e0d57ed Mon Sep 17 00:00:00 2001 From: penguin Date: Wed, 14 Oct 2020 18:43:28 -0500 Subject: [PATCH] testing igloo new function --- D21ExampleMakefile | 166 +++++++++++++++++++++++++++++++++++++ README.md | 6 +- src/igloo.rs | 7 +- src/main.rs | 10 ++- testdir/.igloo/Makefile | 166 +++++++++++++++++++++++++++++++++++++ testdir/.igloo/testdir.yml | 0 testdir/ESF/cfg | 1 + testdir/ESF/hdi | 1 + testdir/ESF/inc | 1 + testdir/ESF/src | 1 + 10 files changed, 349 insertions(+), 10 deletions(-) create mode 100644 D21ExampleMakefile create mode 100644 testdir/.igloo/Makefile create mode 100644 testdir/.igloo/testdir.yml create mode 120000 testdir/ESF/cfg create mode 120000 testdir/ESF/hdi create mode 120000 testdir/ESF/inc create mode 120000 testdir/ESF/src diff --git a/D21ExampleMakefile b/D21ExampleMakefile new file mode 100644 index 0000000..e79a845 --- /dev/null +++ b/D21ExampleMakefile @@ -0,0 +1,166 @@ +# Generated Variables +PROJECT_NAME=testdir +CC=arm-none-eabi-gcc +CCX=arm-none-eabi-g++ +OBJCOPY=arm-none-eabi-objcopy +OBJDUMP=arm-none-eabi-objdump +SIZE=arm-none-eabi-size +GDB=arm-none-eabi-gdb +AS=arm-none-eabi-as + +MCPU=cortex-m0plus +MCU=__SAMD21J18A__ + +LD_PATH=../ld +LD_SCRIPT=$(LD_PATH)/flash.ld + +# Generated Flags +CFLAGS=-x c \ +-DDEBUG \ +-Os \ +-ffunction-sections \ +-mlong-calls \ +-g3 \ +-Wall \ +-std=gnu99 \ +-D$(MCU) \ +-mcpu=$(MCPU) \ +$(DIR_INCLUDES) \ +-MD -MP \ +-MF$(QUOTE)$(@:%.o=%.d)$(QUOTE) \ +-MT$(QUOTE)$(@:%.o=%.d)$(QUOTE) \ +-MT$(QUOTE)$(@:%.o=%.o)$(QUOTE) + +ELF_FLAGS=-Wl,--start-group -l m -Wl,--end-group -mthumb \ +-Wl,-Map=$(QUOTE)$(PROJECT_NAME).map$(QUOTE) --specs=nano.specs -Wl,--gc-sections -mcpu=$(MCPU) \ +-T$(QUOTE)$(LD_SCRIPT)$(QUOTE) \ +-L$(QUOTE)$(LD_PATH)$(QUOTE) + +HEX_FLAGS=-R .eeprom \ +-R .fuse \ +-R .lock \ +-R .signature + +EEP_FLAGS=-j .eeprom --set-section-flags=.eeprom=alloc,load --change-section-lma \ +.eeprom=0 --no-change-warnings + +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 + +# List the subdirectories for creating object files +SUB_DIRS= +# List the object files + +OBJS_AS_ARGS += \ + +# List the directories containing header files +DIR_INCLUDES += \ + +# List the dependency files +DEPS := $(OBJS:%.o=%.d) + +DEPS_AS_ARGS += \ + +vpath %.c ../ +vpath %.s ../ +vpath %.S ../ +# All Target +all: $(SUB_DIRS) $(PROJECT_NAME).elf \ +$(PROJECT_NAME).bin \ +$(PROJECT_NAME).hex \ +$(PROJECT_NAME).eep \ +$(PROJECT_NAME).lss + +# Linker target +# Make ELF +$(PROJECT_NAME).elf: $(OBJS) + @echo Building target: $@ + @echo Invoking: ARM/GNU Linker + $(QUOTE)$(CC)$(QUOTE) -o $@ $(OBJS_AS_ARGS) $(ELF_FLAGS) + + @echo Finished building target: $@ + $(QUOTE)$(SIZE)$(QUOTE) $(QUOTE)$@$(QUOTE) + +# Make BIN +$(PROJECT_NAME).bin: $(PROJECT_NAME).elf + @echo Producing $@ + $(QUOTE)$(OBJCOPY)$(QUOTE) -O binary $(QUOTE)$<$(QUOTE) $(QUOTE)$@$(QUOTE) + +# Make HEX +$(PROJECT_NAME).hex: $(PROJECT_NAME).elf + @echo Producing $@ + $(QUOTE)$(OBJCOPY)$(QUOTE) -O ihex $(HEX_FLAGS) $(QUOTE)$<$(QUOTE) $(QUOTE)$@$(QUOTE) + +# Make EEP +$(PROJECT_NAME).eep: $(PROJECT_NAME).elf + @echo Producing $@ + $(QUOTE)$(OBJCOPY)$(QUOTE) $(EEP_FLAGS) -O binary $(QUOTE)$<$(QUOTE) \ + $(QUOTE)$@$(QUOTE) || exit 0 + +# Make LSS +$(PROJECT_NAME).lss: $(PROJECT_NAME).elf + $(QUOTE)$(OBJDUMP)$(QUOTE) -h -S $(QUOTE)$<$(QUOTE) + + +# Compiler targets +%.o: %.c + @echo Building file: $< + @echo ARM/GNU C Compiler + $(QUOTE)$(CC)$(QUOTE) $(CFLAGS) -o $(QUOTE)$@$(QUOTE) $(QUOTE)$<$(QUOTE) + @echo Finished building: $< + +%.o: %.s + @echo Building file: $< + @echo ARM/GNU Assembler + $(QUOTE)$(AS)$(QUOTE) $(CFLAGS) -o $(QUOTE)$@$(QUOTE) $(QUOTE)$<$(QUOTE) + @echo Finished building: $< + +%.o: %.S + @echo Building file: $< + @echo ARM/GNU Preprocessing Assembler + $(QUOTE)$(CC)$(QUOTE) $(CFLAGS) -o $(QUOTE)$@$(QUOTE) $(QUOTE)$<$(QUOTE) + @echo Finished building: $< + +# Detect changes in the dependent files and recompile the respective object files. +ifneq ($(MAKECMDGOALS),clean) +ifneq ($(strip $(DEPS)),) +-include $(DEPS) +endif +endif + +$(SUB_DIRS): + $(MK_DIR) "$@" + +clean: + rm -f $(OBJS_AS_ARGS) + rm -f $(OUTPUT_FILE_PATH) + rm -f $(DEPS_AS_ARGS) + rm -f $(OUTPUT_FILE_NAME).a $(OUTPUT_FILE_NAME).hex $(OUTPUT_FILE_NAME).bin \ + $(OUTPUT_FILE_NAME).lss $(OUTPUT_FILE_NAME).eep $(OUTPUT_FILE_NAME).map \ + $(OUTPUT_FILE_NAME).srec + +debug: $(OUTPUT_FILE_NAME).elf + $(QUOTE)arm-none-eabi-gdb$(QUOTE) -iex $(QUOTE)target extended-remote localhost:3333$(QUOTE) $(OUTPUT_FILE_NAME).elf +QUOTE := " diff --git a/README.md b/README.md index a337956..3eba879 100644 --- a/README.md +++ b/README.md @@ -32,9 +32,7 @@ This tool allows you to create projects for supported mcus instantly. As long as | Windows | :exclamation: | | Linux | :exclamation: | | MacOS | :exclamation: | - ### Installation -- TBD - -### Usage -- TBD - +### Usage -- TBklfjdslkfjlksdjflksdjflkjfi ### How to contribute -- TBD +fhdhejslenfghuyehggjhk diff --git a/src/igloo.rs b/src/igloo.rs index fc301c4..edd5771 100644 --- a/src/igloo.rs +++ b/src/igloo.rs @@ -240,14 +240,17 @@ impl Igloo Err(e) => println!("{:?}", e), _ => (), } + match std::fs::create_dir(std::path::Path::new(&active_dir).join("ESF")) + { + 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()); } - - } else { diff --git a/src/main.rs b/src/main.rs index 1b49161..dcab2e9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,21 +6,23 @@ use clap::{crate_version, crate_description, crate_authors, App, Arg, AppSetting use config::*; use std::collections::HashMap; use std::path::{Path, PathBuf}; + +#[allow(unused_variables)] +#[allow(unused_imports)] fn main() { let ig = igloo::Igloo::New(); - match ig.start() + let start_ret = match ig.start() { Ok(it) => { match ig.run(it) { - Ok(s) => println!("{}", s), + Ok(rt) => println!("{:?}", rt), Err(e) => println!("Run Error: {:?}", e), } } Err(e) => println!("Error: {:?}", e), - } - + }; } diff --git a/testdir/.igloo/Makefile b/testdir/.igloo/Makefile new file mode 100644 index 0000000..e79a845 --- /dev/null +++ b/testdir/.igloo/Makefile @@ -0,0 +1,166 @@ +# Generated Variables +PROJECT_NAME=testdir +CC=arm-none-eabi-gcc +CCX=arm-none-eabi-g++ +OBJCOPY=arm-none-eabi-objcopy +OBJDUMP=arm-none-eabi-objdump +SIZE=arm-none-eabi-size +GDB=arm-none-eabi-gdb +AS=arm-none-eabi-as + +MCPU=cortex-m0plus +MCU=__SAMD21J18A__ + +LD_PATH=../ld +LD_SCRIPT=$(LD_PATH)/flash.ld + +# Generated Flags +CFLAGS=-x c \ +-DDEBUG \ +-Os \ +-ffunction-sections \ +-mlong-calls \ +-g3 \ +-Wall \ +-std=gnu99 \ +-D$(MCU) \ +-mcpu=$(MCPU) \ +$(DIR_INCLUDES) \ +-MD -MP \ +-MF$(QUOTE)$(@:%.o=%.d)$(QUOTE) \ +-MT$(QUOTE)$(@:%.o=%.d)$(QUOTE) \ +-MT$(QUOTE)$(@:%.o=%.o)$(QUOTE) + +ELF_FLAGS=-Wl,--start-group -l m -Wl,--end-group -mthumb \ +-Wl,-Map=$(QUOTE)$(PROJECT_NAME).map$(QUOTE) --specs=nano.specs -Wl,--gc-sections -mcpu=$(MCPU) \ +-T$(QUOTE)$(LD_SCRIPT)$(QUOTE) \ +-L$(QUOTE)$(LD_PATH)$(QUOTE) + +HEX_FLAGS=-R .eeprom \ +-R .fuse \ +-R .lock \ +-R .signature + +EEP_FLAGS=-j .eeprom --set-section-flags=.eeprom=alloc,load --change-section-lma \ +.eeprom=0 --no-change-warnings + +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 + +# List the subdirectories for creating object files +SUB_DIRS= +# List the object files + +OBJS_AS_ARGS += \ + +# List the directories containing header files +DIR_INCLUDES += \ + +# List the dependency files +DEPS := $(OBJS:%.o=%.d) + +DEPS_AS_ARGS += \ + +vpath %.c ../ +vpath %.s ../ +vpath %.S ../ +# All Target +all: $(SUB_DIRS) $(PROJECT_NAME).elf \ +$(PROJECT_NAME).bin \ +$(PROJECT_NAME).hex \ +$(PROJECT_NAME).eep \ +$(PROJECT_NAME).lss + +# Linker target +# Make ELF +$(PROJECT_NAME).elf: $(OBJS) + @echo Building target: $@ + @echo Invoking: ARM/GNU Linker + $(QUOTE)$(CC)$(QUOTE) -o $@ $(OBJS_AS_ARGS) $(ELF_FLAGS) + + @echo Finished building target: $@ + $(QUOTE)$(SIZE)$(QUOTE) $(QUOTE)$@$(QUOTE) + +# Make BIN +$(PROJECT_NAME).bin: $(PROJECT_NAME).elf + @echo Producing $@ + $(QUOTE)$(OBJCOPY)$(QUOTE) -O binary $(QUOTE)$<$(QUOTE) $(QUOTE)$@$(QUOTE) + +# Make HEX +$(PROJECT_NAME).hex: $(PROJECT_NAME).elf + @echo Producing $@ + $(QUOTE)$(OBJCOPY)$(QUOTE) -O ihex $(HEX_FLAGS) $(QUOTE)$<$(QUOTE) $(QUOTE)$@$(QUOTE) + +# Make EEP +$(PROJECT_NAME).eep: $(PROJECT_NAME).elf + @echo Producing $@ + $(QUOTE)$(OBJCOPY)$(QUOTE) $(EEP_FLAGS) -O binary $(QUOTE)$<$(QUOTE) \ + $(QUOTE)$@$(QUOTE) || exit 0 + +# Make LSS +$(PROJECT_NAME).lss: $(PROJECT_NAME).elf + $(QUOTE)$(OBJDUMP)$(QUOTE) -h -S $(QUOTE)$<$(QUOTE) + + +# Compiler targets +%.o: %.c + @echo Building file: $< + @echo ARM/GNU C Compiler + $(QUOTE)$(CC)$(QUOTE) $(CFLAGS) -o $(QUOTE)$@$(QUOTE) $(QUOTE)$<$(QUOTE) + @echo Finished building: $< + +%.o: %.s + @echo Building file: $< + @echo ARM/GNU Assembler + $(QUOTE)$(AS)$(QUOTE) $(CFLAGS) -o $(QUOTE)$@$(QUOTE) $(QUOTE)$<$(QUOTE) + @echo Finished building: $< + +%.o: %.S + @echo Building file: $< + @echo ARM/GNU Preprocessing Assembler + $(QUOTE)$(CC)$(QUOTE) $(CFLAGS) -o $(QUOTE)$@$(QUOTE) $(QUOTE)$<$(QUOTE) + @echo Finished building: $< + +# Detect changes in the dependent files and recompile the respective object files. +ifneq ($(MAKECMDGOALS),clean) +ifneq ($(strip $(DEPS)),) +-include $(DEPS) +endif +endif + +$(SUB_DIRS): + $(MK_DIR) "$@" + +clean: + rm -f $(OBJS_AS_ARGS) + rm -f $(OUTPUT_FILE_PATH) + rm -f $(DEPS_AS_ARGS) + rm -f $(OUTPUT_FILE_NAME).a $(OUTPUT_FILE_NAME).hex $(OUTPUT_FILE_NAME).bin \ + $(OUTPUT_FILE_NAME).lss $(OUTPUT_FILE_NAME).eep $(OUTPUT_FILE_NAME).map \ + $(OUTPUT_FILE_NAME).srec + +debug: $(OUTPUT_FILE_NAME).elf + $(QUOTE)arm-none-eabi-gdb$(QUOTE) -iex $(QUOTE)target extended-remote localhost:3333$(QUOTE) $(OUTPUT_FILE_NAME).elf +QUOTE := " diff --git a/testdir/.igloo/testdir.yml b/testdir/.igloo/testdir.yml new file mode 100644 index 0000000..e69de29 diff --git a/testdir/ESF/cfg b/testdir/ESF/cfg new file mode 120000 index 0000000..359fa3e --- /dev/null +++ b/testdir/ESF/cfg @@ -0,0 +1 @@ +/storage/Shared/Documents/Projects/ePenguin/ePenguin-Software-Framework/arch/arm/SAM_D2X/cfg \ No newline at end of file diff --git a/testdir/ESF/hdi b/testdir/ESF/hdi new file mode 120000 index 0000000..2f42b0a --- /dev/null +++ b/testdir/ESF/hdi @@ -0,0 +1 @@ +/storage/Shared/Documents/Projects/ePenguin/ePenguin-Software-Framework/arch/arm/SAM_D2X/hdi \ No newline at end of file diff --git a/testdir/ESF/inc b/testdir/ESF/inc new file mode 120000 index 0000000..b0353f6 --- /dev/null +++ b/testdir/ESF/inc @@ -0,0 +1 @@ +/storage/Shared/Documents/Projects/ePenguin/ePenguin-Software-Framework/arch/arm/SAM_D2X/inc \ No newline at end of file diff --git a/testdir/ESF/src b/testdir/ESF/src new file mode 120000 index 0000000..209d0ff --- /dev/null +++ b/testdir/ESF/src @@ -0,0 +1 @@ +/storage/Shared/Documents/Projects/ePenguin/ePenguin-Software-Framework/arch/arm/SAM_D2X/src \ No newline at end of file