From a39364193f614b9e711d4cb861b7eb6e16ef5b98 Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Mon, 16 Feb 2015 14:06:20 +0100 Subject: [PATCH] "objcopy" recipes are no more tied to "hex" extension This allow to define specific recipes for every platform but keeps backward compatibility. See #2614 --- .../src/processing/app/debug/Compiler.java | 19 ++++++++++++------- hardware/arduino/avr/platform.txt | 6 ++---- hardware/arduino/sam/platform.txt | 7 ++----- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/arduino-core/src/processing/app/debug/Compiler.java b/arduino-core/src/processing/app/debug/Compiler.java index a23836a0e..e84ba4eda 100644 --- a/arduino-core/src/processing/app/debug/Compiler.java +++ b/arduino-core/src/processing/app/debug/Compiler.java @@ -34,6 +34,7 @@ import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -399,13 +400,17 @@ public class Compiler implements MessageConsumer { progressListener.progress(60); compileLink(); - // 5. extract EEPROM data (from EEMEM directive) to .eep file. - progressListener.progress(70); - runRecipe("recipe.objcopy.eep.pattern"); - - // 6. build the .hex file - progressListener.progress(80); - runRecipe("recipe.objcopy.output.pattern"); + // 5. run objcopy to generate output files + progressListener.progress(75); + List objcopyPatterns = new ArrayList(); + for (String key : prefs.keySet()) { + if (key.startsWith("recipe.objcopy.") && key.endsWith(".pattern")) + objcopyPatterns.add(key); + } + Collections.sort(objcopyPatterns); + for (String recipe : objcopyPatterns) { + runRecipe(recipe); + } progressListener.progress(90); return true; diff --git a/hardware/arduino/avr/platform.txt b/hardware/arduino/avr/platform.txt index 04499b097..051bd013b 100644 --- a/hardware/arduino/avr/platform.txt +++ b/hardware/arduino/avr/platform.txt @@ -61,11 +61,9 @@ recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compil ## Combine gc-sections, archives, and objects recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" {compiler.c.elf.flags} -mmcu={build.mcu} {compiler.c.elf.extra_flags} -o "{build.path}/{build.project_name}.elf" {object_files} "{build.path}/{archive_file}" "-L{build.path}" -lm -## Create eeprom +## Create output files (.eep and .hex) recipe.objcopy.eep.pattern="{compiler.path}{compiler.objcopy.cmd}" {compiler.objcopy.eep.flags} {compiler.objcopy.eep.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.eep" - -## Create hex -recipe.objcopy.output.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex" +recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex" ## Compute size recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf" diff --git a/hardware/arduino/sam/platform.txt b/hardware/arduino/sam/platform.txt index ce95c886a..41d10efe8 100644 --- a/hardware/arduino/sam/platform.txt +++ b/hardware/arduino/sam/platform.txt @@ -65,11 +65,8 @@ recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compil ## Combine gc-sections, archives, and objects recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" {compiler.c.elf.flags} -mcpu={build.mcu} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" {compiler.c.elf.extra_flags} -o "{build.path}/{build.project_name}.elf" "-L{build.path}" -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--entry=Reset_Handler -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align -Wl,--warn-unresolved-symbols -Wl,--start-group "{build.path}/syscalls_sam3.c.o" {object_files} "{build.variant.path}/{build.variant_system_lib}" "{build.path}/{archive_file}" -Wl,--end-group -lm -gcc -## Create eeprom -recipe.objcopy.eep.pattern= - -## Create hex -recipe.objcopy.output.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin" +## Create output (.bin file) +recipe.objcopy.bin.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin" ## Compute size recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf"