From 3681035869a803ccc3605fd2f3a002cd18ef809b Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Fri, 23 Sep 2011 04:47:41 +0200 Subject: [PATCH] IDE: various refactoring to make sam hardware compiling. --- app/src/processing/app/Editor.java | 4 +- app/src/processing/app/Sketch.java | 58 +++- app/src/processing/app/debug/Compiler.java | 304 ++++++++------------- app/src/processing/app/debug/Sizer.java | 93 ++++--- hardware/sam/platforms.txt | 9 +- 5 files changed, 214 insertions(+), 254 deletions(-) diff --git a/app/src/processing/app/Editor.java b/app/src/processing/app/Editor.java index 95c531640..964361407 100644 --- a/app/src/processing/app/Editor.java +++ b/app/src/processing/app/Editor.java @@ -1841,7 +1841,7 @@ public class Editor extends JFrame implements RunnerListener { public void run() { try { sketch.prepare(); - String appletClassName = sketch.build(false); + sketch.build(false); statusNotice("Done compiling."); } catch (Exception e) { statusError(e); @@ -1856,7 +1856,7 @@ public class Editor extends JFrame implements RunnerListener { public void run() { try { sketch.prepare(); - String appletClassName = sketch.build(true); + sketch.build(true); statusNotice("Done compiling."); } catch (Exception e) { statusError(e); diff --git a/app/src/processing/app/Sketch.java b/app/src/processing/app/Sketch.java index 499b655a9..9147043d7 100644 --- a/app/src/processing/app/Sketch.java +++ b/app/src/processing/app/Sketch.java @@ -32,15 +32,11 @@ import processing.app.preproc.*; import processing.core.*; import java.awt.*; -import java.awt.event.*; -import java.beans.*; import java.io.*; +import java.text.MessageFormat; import java.util.*; -import java.util.zip.*; import javax.swing.*; -import javax.swing.border.EmptyBorder; -import javax.swing.border.TitledBorder; /** @@ -1512,17 +1508,50 @@ public class Sketch { // run the preprocessor String primaryClassName = preprocess(buildPath); + Map config = new HashMap(); + mergeMapsAndRemoveNulls(Preferences.getMap(), config); + Map boardPrefs = Base.getBoardPreferences(); + // Check for null platform, and use system default if not found + String platform = boardPrefs.get("platform"); + if (platform == null) + mergeMapsAndRemoveNulls(Base.getPlatformPreferences(), config); + else + mergeMapsAndRemoveNulls(Base.getPlatformPreferences(platform), config); + mergeMapsAndRemoveNulls(boardPrefs, config); + + String toolchainPath = config.get("compiler.path"); + if (toolchainPath == null) { + toolchainPath = Base.getAvrBasePath(); + } else { + // Put in the system path in the compiler path if available + String basePath = System.getProperty("user.dir"); + if (Base.isMacOS()) + basePath += "/Arduino.app/Contents/Resources/Java"; + Object[] args = { basePath }; + toolchainPath = new MessageFormat(toolchainPath).format(args); + } + config.put("compiler.path", toolchainPath); + // compile the program. errors will happen as a RunnerException // that will bubble up to whomever called build(). - Compiler compiler = new Compiler(); + Compiler compiler = new Compiler(config); if (compiler.compile(this, buildPath, primaryClassName, verbose)) { - size(buildPath, primaryClassName); + size(buildPath, primaryClassName, config); return primaryClassName; } return null; + } + + private void mergeMapsAndRemoveNulls(Map src, + Map dst) { + for (String k : src.keySet()) { + String v = src.get(k); + if (v == null) + v = ""; + dst.put(k, v); + } } - - + protected boolean exportApplet(boolean usingProgrammer) throws Exception { return exportApplet(tempBuildFolder.getAbsolutePath(), usingProgrammer); } @@ -1574,13 +1603,14 @@ public class Sketch { } - protected void size(String buildPath, String suggestedClassName) - throws RunnerException { + protected void size(String buildPath, String suggestedClassName, + Map prefs) throws RunnerException { long size = 0; - String maxsizeString = Base.getBoardPreferences().get("upload.maximum_size"); - if (maxsizeString == null) return; + String maxsizeString = prefs.get("upload.maximum_size"); + if (maxsizeString == null) + return; long maxsize = Integer.parseInt(maxsizeString); - Sizer sizer = new Sizer(buildPath, suggestedClassName); + Sizer sizer = new Sizer(buildPath, suggestedClassName, prefs); try { size = sizer.computeSize(); System.out.println("Binary sketch size: " + size + " bytes (of a " + diff --git a/app/src/processing/app/debug/Compiler.java b/app/src/processing/app/debug/Compiler.java index e2b1abdc7..10c474087 100644 --- a/app/src/processing/app/debug/Compiler.java +++ b/app/src/processing/app/debug/Compiler.java @@ -28,14 +28,10 @@ import java.io.FilenameFilter; import java.io.IOException; import java.text.MessageFormat; import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Iterator; import java.util.List; import java.util.Map; import processing.app.Base; -import processing.app.Preferences; import processing.app.Sketch; import processing.app.SketchCode; import processing.core.PApplet; @@ -62,15 +58,15 @@ public class Compiler implements MessageConsumer { Map configPreferences; - Map boardPreferences; - - Map platformPreferences; - String avrBasePath; List objectFiles; - public Compiler() { + public Compiler(Map preferences) { + // Merge all the preferences file in the correct order of precedence + // into a new map. + configPreferences = preferences; + avrBasePath = configPreferences.get("compiler.path"); } /** @@ -95,40 +91,8 @@ public class Compiler implements MessageConsumer { this.verbose = verbose; objectFiles = new ArrayList(); - // the pms object isn't used for anything but storage - // MessageStream pms = new MessageStream(this); - Map boardPreferences = Base.getBoardPreferences(); + // System.out.println("-> compiler.java is doing stuff"); - // Check for null platform, and use system default if not found - platform = boardPreferences.get("platform"); - if (platform == null) - platformPreferences = new HashMap(Base.getPlatformPreferences()); - else - platformPreferences = new HashMap(Base.getPlatformPreferences(platform)); - - System.out.println("-> compiler.java is doing stuff"); - // Put all the global preference configuration into one Master - // configpreferences - configPreferences = mergePreferences(Preferences.getMap(), - platformPreferences, boardPreferences); - - avrBasePath = configPreferences.get("compiler.path"); - if (avrBasePath == null) { - avrBasePath = Base.getAvrBasePath(); - // System.out.println("avrBasePath: " + avrBasePath); - } else { - // System.out.println("avrBasePath:exists: " + avrBasePath); - - // Put in the system path in the compiler path if available - String basePath = System.getProperty("user.dir"); - if (Base.isMacOS()) { - // logger.debug("basePath: " + basePath); - basePath += "/Arduino.app/Contents/Resources/Java"; - } - Object[] Args = { basePath }; - avrBasePath = new MessageFormat(avrBasePath).format(Args); - // System.out.println("avrBasePath:new: " + avrBasePath); - } board = configPreferences.get("board"); if (board == "") board = "_UNKNOWN"; @@ -148,7 +112,6 @@ public class Compiler implements MessageConsumer { target = Base.getTarget(); coreFolder = new File(new File(target.getFolder(), "cores"), core); corePath = coreFolder.getAbsolutePath(); - systemPath = new File(target.getFolder(), "system").getAbsolutePath(); } else { target = Base.targetsTable.get(core.substring(0, core.indexOf(':'))); @@ -501,20 +464,24 @@ public class Compiler implements MessageConsumer { String objectName, Map configPreferences) { System.out.println("getCommandCompilerS: start"); - String baseCommandString = configPreferences.get("recipe.cpp.o.pattern"); - MessageFormat compileFormat = new MessageFormat(baseCommandString); + String recipe = configPreferences.get("recipe.cpp.o.pattern"); + MessageFormat compileFormat = new MessageFormat(recipe); // getIncludes to String - String includes = preparePaths(includePaths); - Object[] Args = { avrBasePath, configPreferences.get("compiler.cpp.cmd"), - configPreferences.get("compiler.S.flags"), - configPreferences.get("compiler.cpudef"), - configPreferences.get("build.mcu"), - configPreferences.get("build.f_cpu"), - configPreferences.get("software"), Base.REVISION, includes, sourceName, - objectName }; + String args[] = new String[11]; + args[0] = avrBasePath; + args[1] = configPreferences.get("compiler.cpp.cmd"); + args[2] = configPreferences.get("compiler.S.flags"); + args[3] = configPreferences.get("compiler.cpudef"); + args[4] = configPreferences.get("build.mcu"); + args[5] = configPreferences.get("build.f_cpu"); + args[6] = configPreferences.get("software"); + args[7] = "" + Base.REVISION; + args[8] = preparePaths(includePaths); + args[9] = sourceName; + args[10] = objectName; - String command = compileFormat.format(Args); + String command = compileFormat.format(args); String[] commandArray = command.split("\\|"); return commandArray; } @@ -553,21 +520,21 @@ public class Compiler implements MessageConsumer { // getIncludes to String String includes = preparePaths(includePaths); - Object[] Args = { avrBasePath, // 0 - configPreferences.get("compiler.c.cmd"), // 1 - configPreferences.get("compiler.c.flags"), // 2 - configPreferences.get("compiler.cpudef"), // 3 - configPreferences.get("build.mcu"), // 4 - configPreferences.get("build.f_cpu"), // 5 - configPreferences.get("software"), // 6 - Base.REVISION, // 7 - includes, // 8 - sourceName, // 9 - objectName, // 10 - configPreferences.get("build.extra_flags") // 11 - }; + String[] args = new String[12]; + args[0] = avrBasePath; + args[1] = configPreferences.get("compiler.c.cmd"); + args[2] = configPreferences.get("compiler.c.flags"); + args[3] = configPreferences.get("compiler.cpudef"); + args[4] = configPreferences.get("build.mcu"); + args[5] = configPreferences.get("build.f_cpu"); + args[6] = configPreferences.get("software"); + args[7] = "" + Base.REVISION; + args[8] = includes; + args[9] = sourceName; + args[10] = objectName; + args[11] = configPreferences.get("build.extra_flags"); - String command = compileFormat.format(Args); + String command = compileFormat.format(args); String[] commandArray = command.split("\\|"); return commandArray; } @@ -607,21 +574,21 @@ public class Compiler implements MessageConsumer { // getIncludes to String String includes = preparePaths(includePaths); - Object[] Args = { avrBasePath, // 0 - configPreferences.get("compiler.cpp.cmd"), // 1 - configPreferences.get("compiler.cpp.flags"), // 2 - configPreferences.get("compiler.cpudef"), // 3 - configPreferences.get("build.mcu"), // 4 - configPreferences.get("build.f_cpu"), // 5 - configPreferences.get("software"), // 6 - Base.REVISION, // 7 - includes, // 8 - sourceName, // 9 - objectName, // 10 - configPreferences.get("build.extra_flags") // 11 - }; + String[] args = new String[12]; + args[0] = avrBasePath; + args[1] = configPreferences.get("compiler.cpp.cmd"); + args[2] = configPreferences.get("compiler.cpp.flags"); + args[3] = configPreferences.get("compiler.cpudef"); + args[4] = configPreferences.get("build.mcu"); + args[5] = configPreferences.get("build.f_cpu"); + args[6] = configPreferences.get("software"); + args[7] = "" + Base.REVISION; + args[8] = includes; + args[9] = sourceName; + args[10] = objectName; + args[11] = configPreferences.get("build.extra_flags"); - String command = compileFormat.format(Args); + String command = compileFormat.format(args); String[] commandArray = command.split("\\|"); // System.out.println("command:" + command); @@ -658,7 +625,7 @@ public class Compiler implements MessageConsumer { static public ArrayList findFilesInPath(String path, String extension, boolean recurse) { - System.out.println("findFilesInPath: " + path); + // System.out.println("findFilesInPath: " + path); return findFilesInFolder(new File(path), extension, recurse); } @@ -690,11 +657,10 @@ public class Compiler implements MessageConsumer { List includePaths, Map configPreferences) throws RunnerException { - System.out.println("compileSketch: start"); - System.out.println("includePaths: "); - for (int i = 0; i < includePaths.size(); i++) { - System.out.println("-I" + (String) includePaths.get(i)); - } + // System.out.println("compileSketch: start"); + // System.out.println("includePaths: "); + // for (int i = 0; i < includePaths.size(); i++) + // System.out.println("-I" + (String) includePaths.get(i)); // logger.debug("compileSketch: start"); objectFiles.addAll(compileFiles(avrBasePath, buildPath, includePaths, @@ -732,7 +698,7 @@ public class Compiler implements MessageConsumer { false), findFilesInFolder(libraryFolder, "cpp", false), - boardPreferences)); + configPreferences)); outputFolder = new File(outputFolder, "utility"); createFolder(outputFolder); objectFiles.addAll(compileFiles(avrBasePath, outputFolder @@ -742,7 +708,7 @@ public class Compiler implements MessageConsumer { false), findFilesInFolder(utilityFolder, "cpp", false), - boardPreferences)); + configPreferences)); // other libraries should not see this library's utility/ folder includePaths.remove(includePaths.size() - 1); } @@ -762,7 +728,6 @@ public class Compiler implements MessageConsumer { // for (int i = 0; i < includePaths.size(); i++) // System.out.println("-I" + includePaths.get(i)); - String commandString = ""; // System.out.println("corePath: " + corePath); List srcDirs = new ArrayList(); srcDirs.add(corePath); @@ -771,32 +736,29 @@ public class Compiler implements MessageConsumer { srcDirs.addAll(variantExtraSrc); List objects = new ArrayList(); - - for (String dir : srcDirs) { + for (String dir : srcDirs) objects.addAll(compileFiles(avrBasePath, buildPath, includePaths, findFilesInPath(dir, "S", false), findFilesInPath(dir, "c", false), findFilesInPath(dir, "cpp", false), configPreferences)); - } for (File file : objects) { // List commandAR = new ArrayList(baseCommandAR); // commandAR = commandAR + file.getAbsolutePath(); - Object[] Args = { avrBasePath, // 0 - configPreferences.get("compiler.ar.cmd"), // 1 - configPreferences.get("compiler.ar.flags"), // 2 - // corePath, - buildPath + File.separator, "core.a", // 3 - // objectName - file.getAbsolutePath() // 4 - }; + String[] args = new String[6]; + args[0] = avrBasePath; + args[1] = configPreferences.get("compiler.ar.cmd"); + args[2] = configPreferences.get("compiler.ar.flags"); + args[3] = buildPath + File.separator; + args[4] = "core.a"; + args[5] = file.getAbsolutePath(); // System.out.println("compileCore(...) substitute"); String baseCommandString = configPreferences.get("recipe.ar.pattern"); MessageFormat compileFormat = new MessageFormat(baseCommandString); - commandString = compileFormat.format(Args); + String commandString = compileFormat.format(args); String[] commandArray = commandString.split("\\|"); execAsynchronously(commandArray); @@ -808,32 +770,31 @@ public class Compiler implements MessageConsumer { List includePaths, String pinsPath, Map configPreferences) throws RunnerException { - System.out.println("compileLink: start"); - String baseCommandString = configPreferences - .get("recipe.c.combine.pattern"); - String commandString = ""; - MessageFormat compileFormat = new MessageFormat(baseCommandString); - String objectFileList = ""; + // System.out.println("compileLink: start"); + String recipe = configPreferences.get("recipe.c.combine.pattern"); + MessageFormat compileFormat = new MessageFormat(recipe); - for (File file : objectFiles) { + String objectFileList = ""; + for (File file : objectFiles) objectFileList = objectFileList + file.getAbsolutePath() + "|"; - } System.out.println("objectFileList: " + objectFileList); - Object[] Args = { avrBasePath, // 0 - configPreferences.get("compiler.c.elf.cmd"), // 1 - configPreferences.get("compiler.c.elf.flags"), // 2 - configPreferences.get("compiler.cpudef"), // 3 - configPreferences.get("build.mcu"), // 4 - buildPath + File.separator, // 5 - primaryClassName, // 6 - objectFileList, // 7 - buildPath + File.separator + "core.a", // 8 - buildPath, // 9 - corePath, // 10 - pinsPath + File.separator + configPreferences.get("build.ldscript") // 11 - }; - commandString = compileFormat.format(Args); + String args[] = new String[12]; + args[0] = avrBasePath; + args[1] = configPreferences.get("compiler.c.elf.cmd"); + args[2] = configPreferences.get("compiler.c.elf.flags"); + args[3] = configPreferences.get("compiler.cpudef"); + args[4] = configPreferences.get("build.mcu"); + args[5] = buildPath + File.separator; + args[6] = primaryClassName; + args[7] = objectFileList; + args[8] = buildPath + File.separator + "core.a"; + args[9] = buildPath; + args[10] = corePath; + args[11] = pinsPath + File.separator + + configPreferences.get("build.ldscript"); + + String commandString = compileFormat.format(args); String[] commandArray = commandString.split("\\|"); execAsynchronously(commandArray); } @@ -843,18 +804,19 @@ public class Compiler implements MessageConsumer { List includePaths, Map configPreferences) throws RunnerException { // logger.debug("compileEep: start"); - String baseCommandString = configPreferences - .get("recipe.objcopy.eep.pattern"); - String commandString = ""; - MessageFormat compileFormat = new MessageFormat(baseCommandString); - String objectFileList = ""; + String recipe = configPreferences.get("recipe.objcopy.eep.pattern"); + if (recipe.trim().isEmpty()) + return; + MessageFormat compileFormat = new MessageFormat(recipe); - Object[] Args = { avrBasePath, - configPreferences.get("compiler.objcopy.cmd"), - configPreferences.get("compiler.objcopy.eep.flags"), - buildPath + File.separator + primaryClassName, - buildPath + File.separator + primaryClassName }; - commandString = compileFormat.format(Args); + String[] args = new String[5]; + args[0] = avrBasePath; + args[1] = configPreferences.get("compiler.objcopy.cmd"); + args[2] = configPreferences.get("compiler.objcopy.eep.flags"); + args[3] = buildPath + File.separator + primaryClassName; + args[4] = buildPath + File.separator + primaryClassName; + + String commandString = compileFormat.format(args); String[] commandArray = commandString.split("\\|"); execAsynchronously(commandArray); } @@ -864,71 +826,21 @@ public class Compiler implements MessageConsumer { List includePaths, Map configPreferences) throws RunnerException { // logger.debug("compileHex: start"); - String baseCommandString = configPreferences - .get("recipe.objcopy.hex.pattern"); - String commandString = ""; - MessageFormat compileFormat = new MessageFormat(baseCommandString); - String objectFileList = ""; + String recipe = configPreferences.get("recipe.objcopy.hex.pattern"); + MessageFormat compileFormat = new MessageFormat(recipe); - Object[] Args = { avrBasePath, - configPreferences.get("compiler.elf2hex.cmd"), - configPreferences.get("compiler.elf2hex.flags"), - buildPath + File.separator + primaryClassName, - buildPath + File.separator + primaryClassName }; - commandString = compileFormat.format(Args); + String[] args = new String[5]; + args[0] = avrBasePath; + args[1] = configPreferences.get("compiler.elf2hex.cmd"); + args[2] = configPreferences.get("compiler.elf2hex.flags"); + args[3] = buildPath + File.separator + primaryClassName; + args[4] = buildPath + File.separator + primaryClassName; + + String commandString = compileFormat.format(args); String[] commandArray = commandString.split("\\|"); execAsynchronously(commandArray); } - // merge all the preferences file in the correct order of precedence - HashMap mergePreferences(Map Preferences, Map platformPreferences, - Map boardPreferences) { - HashMap _map = new HashMap(); - - Iterator iterator = Preferences.entrySet().iterator(); - - while (iterator.hasNext()) { - Map.Entry pair = (Map.Entry) iterator.next(); - if (pair.getValue() == null) { - _map.put(pair.getKey(), ""); - } else { - _map.put(pair.getKey(), pair.getValue()); - } - } - - // logger.debug("Done: Preferences"); - - iterator = platformPreferences.entrySet().iterator(); - - while (iterator.hasNext()) { - Map.Entry pair = (Map.Entry) iterator.next(); - - if (pair.getValue() == null) { - _map.put(pair.getKey(), ""); - } else { - _map.put(pair.getKey(), pair.getValue()); - } - // System.out.println(pair.getKey() + " = " + pair.getValue()); - } - - // System.out.println("Done: platformPreferences"); - iterator = boardPreferences.entrySet().iterator(); - - while (iterator.hasNext()) { - Map.Entry pair = (Map.Entry) iterator.next(); - - if (pair.getValue() == null) { - _map.put(pair.getKey(), ""); - } else { - _map.put(pair.getKey(), pair.getValue()); - } - // System.out.println(pair.getKey() + " = " + pair.getValue()); - } - // System.out.println("Done: boardPreferences"); - - return _map; - } - // getIncludes to String private static String preparePaths(List includePaths) { String includes = ""; diff --git a/app/src/processing/app/debug/Sizer.java b/app/src/processing/app/debug/Sizer.java index d67728a3c..2b4dfd80f 100644 --- a/app/src/processing/app/debug/Sizer.java +++ b/app/src/processing/app/debug/Sizer.java @@ -1,67 +1,77 @@ /* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */ /* - Sizer - computes the size of a .hex file - Part of the Arduino project - http://www.arduino.cc/ + Sizer - computes the size of a .hex file + Part of the Arduino project - http://www.arduino.cc/ - Copyright (c) 2006 David A. Mellis + Copyright (c) 2006 David A. Mellis - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - $Id$ -*/ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + $Id$ + */ package processing.app.debug; -import processing.app.Base; - -import java.io.*; -import java.util.*; +import java.io.File; +import java.text.MessageFormat; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.StringTokenizer; public class Sizer implements MessageConsumer { private String buildPath, sketchName; + private String firstLine; + private long size; + private RunnerException exception; - public Sizer(String buildPath, String sketchName) { + private Map prefs; + + public Sizer(String buildPath, String sketchName, + Map prefs) { this.buildPath = buildPath; this.sketchName = sketchName; + this.prefs = prefs; } - + public long computeSize() throws RunnerException { - String avrBasePath = Base.getAvrBasePath(); - String commandSize[] = new String[] { - avrBasePath + "avr-size", - " " - }; - - commandSize[1] = buildPath + File.separator + sketchName + ".hex"; + String args[] = new String[3]; + args[0] = prefs.get("compiler.path"); + args[1] = prefs.get("compiler.size.cmd"); + args[2] = buildPath + File.separator + sketchName; + + String recipe = prefs.get("recipe.size.pattern"); + MessageFormat compileFormat = new MessageFormat(recipe); + String command = compileFormat.format(args); + String[] commandArray = command.split("\\|"); int r = 0; try { exception = null; size = -1; firstLine = null; - Process process = Runtime.getRuntime().exec(commandSize); + Process process = Runtime.getRuntime().exec(commandArray); MessageSiphon in = new MessageSiphon(process.getInputStream(), this); MessageSiphon err = new MessageSiphon(process.getErrorStream(), this); boolean running = true; - while(running) { + while (running) { try { if (in.thread != null) in.thread.join(); @@ -69,25 +79,28 @@ public class Sizer implements MessageConsumer { err.thread.join(); r = process.waitFor(); running = false; - } catch (InterruptedException intExc) { } + } catch (InterruptedException intExc) { + } } } catch (Exception e) { // The default Throwable.toString() never returns null, but apparently // some sub-class has overridden it to do so, thus we need to check for - // it. See: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1166589459 - exception = new RunnerException( - (e.toString() == null) ? e.getClass().getName() + r : e.toString() + r); + // it. See: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1166589459 + if (e.toString() == null) + exception = new RunnerException(e.getClass().getName() + r); + else + exception = new RunnerException(e.toString() + r); } - + if (exception != null) throw exception; - + if (size == -1) throw new RunnerException(firstLine); - + return size; } - + public void message(String s) { if (firstLine == null) firstLine = s; diff --git a/hardware/sam/platforms.txt b/hardware/sam/platforms.txt index b3a1f812e..e940f8143 100755 --- a/hardware/sam/platforms.txt +++ b/hardware/sam/platforms.txt @@ -29,13 +29,17 @@ sam.recipe.c.combine.pattern={0}{1}|{2}|{3}{4}|-T{11}|-Wl,-Map,{5}{6}.map|-o|{5} ##create eeprom #sam.recipe.objcopy.eep.pattern={0=compiler.path}{1=compiler.objcopy.cmd}{2=compiler.objcopy.eep.flags} {3=BUILD_PATH}{4=SOURCE_NAME}.elf {5=BUILD_PATH}{6=SOURCE_NAME}.eep -sam.recipe.objcopy.eep.pattern={0}{1}|{2}|{3}.elf|{4}.eep +#sam.recipe.objcopy.eep.pattern={0}{1}|{2}|{3}.elf|{4}.eep +sam.recipe.objcopy.eep.pattern= ##create hex #sam.recipe.objcopy.hex.pattern={0=compiler.path}{1=compiler.objcopy.cmd}{2=compiler.objcopy.elf.flags} {3=BUILD_PATH}{4=SOURCE_NAME}.elf {5=BUILD_PATH}{6=SOURCE_NAME}.hex -sam.recipe.objcopy.hex.pattern={0}{1}|{2}|{3}.elf|{4}.hex +sam.recipe.objcopy.hex.pattern={0}{1}|{2}|{3}.elf|{4}.bin +##compute size +sam.recipe.size.pattern={0}{1}|{2}.elf + ######################################################## sam.name=Atmel SAM @@ -56,6 +60,7 @@ sam.compiler.elf2hex.flags=|-O|binary sam.compiler.elf2hex.cmd=arm-none-eabi-objcopy sam.compiler.ldflags= sam.compiler.cpudef=-mcpu= +sam.compiler.size.cmd=arm-none-eabi-size sam.compiler.upload.cmd= sam.compiler.upload.flags= sam.compiler.define=-DARDUINO=