From 6e4b4a79724912a578de713ea2e8b9aa336a443f Mon Sep 17 00:00:00 2001 From: Wes Date: Wed, 23 Apr 2014 23:35:09 -0500 Subject: [PATCH 1/7] Compile for all device types --- app/src/processing/app/debug/Compiler.java | 48 +++++++++++++++++----- 1 file changed, 38 insertions(+), 10 deletions(-) diff --git a/app/src/processing/app/debug/Compiler.java b/app/src/processing/app/debug/Compiler.java index 14a7377c343..2f75a7a34d2 100644 --- a/app/src/processing/app/debug/Compiler.java +++ b/app/src/processing/app/debug/Compiler.java @@ -23,18 +23,26 @@ package processing.app.debug; +import static processing.app.I18n._; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.FilenameFilter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + import processing.app.Base; +import processing.app.I18n; import processing.app.Preferences; import processing.app.Sketch; import processing.app.SketchCode; -import processing.core.*; -import processing.app.I18n; import processing.app.helpers.filefilters.OnlyDirs; -import static processing.app.I18n._; - -import java.io.*; -import java.util.*; -import java.util.zip.*; +import processing.core.PApplet; public class Compiler implements MessageConsumer { @@ -63,20 +71,40 @@ public Compiler() { } * @throws RunnerException Only if there's a problem. Only then. */ public boolean compile(Sketch sketch, + String buildPath, + String primaryClassName, + boolean verbose) throws RunnerException { + Map boardPreferences = Base.getBoardPreferences(); + + if (!Base.getTarget().getName().equals("buildall")) { + return compileForBoard(sketch, buildPath, primaryClassName, verbose, boardPreferences); + } + + Base.getTarget().getBoards(); + for (Entry> board : Base.getTarget().getBoards().entrySet()) { + if (compileForBoard(sketch, buildPath, primaryClassName, verbose, board.getValue())) + return false; + } + + return true; + } + + private boolean compileForBoard(Sketch sketch, String buildPath, String primaryClassName, - boolean verbose) throws RunnerException { + boolean verbose, + Map boardPreferences) throws RunnerException { this.sketch = sketch; this.buildPath = buildPath; this.primaryClassName = primaryClassName; this.verbose = verbose; this.sketchIsCompiled = false; - + // the pms object isn't used for anything but storage MessageStream pms = new MessageStream(this); String avrBasePath = Base.getAvrBasePath(); - Map boardPreferences = Base.getBoardPreferences(); + String core = boardPreferences.get("build.core"); if (core == null) { RunnerException re = new RunnerException(_("No board selected; please choose a board from the Tools > Board menu.")); From b5253c1c0ff50358240a96084845591b9c5005de Mon Sep 17 00:00:00 2001 From: Wes Date: Thu, 24 Apr 2014 00:00:34 -0500 Subject: [PATCH 2/7] Need to add and entry for compiling all boards --- hardware/arduino/boards.txt | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/hardware/arduino/boards.txt b/hardware/arduino/boards.txt index fc29ee4f9db..8d22d2b5f0f 100644 --- a/hardware/arduino/boards.txt +++ b/hardware/arduino/boards.txt @@ -2,6 +2,25 @@ ############################################################## +buildall.name=Build all boards/Upload as Mega 2560 +buildall.upload.protocol=arduino +buildall.upload.protocol=wiring +buildall.upload.maximum_size=258048 +buildall.upload.speed=115200 +buildall.bootloader.low_fuses=0xFF +buildall.bootloader.high_fuses=0xD8 +buildall.bootloader.extended_fuses=0xFD +buildall.bootloader.path=stk500v2 +buildall.bootloader.file=stk500boot_v2_mega2560.hex +buildall.bootloader.unlock_bits=0x3F +buildall.bootloader.lock_bits=0x0F +buildall.build.mcu=atmega2560 +buildall.build.f_cpu=16000000L +buildall.build.core=arduino +buildall.build.variant=mega + +############################################################## + uno.name=Arduino Uno uno.upload.protocol=arduino uno.upload.maximum_size=32256 From fcd4228d5b190996d384a5552a1cae84225d1237 Mon Sep 17 00:00:00 2001 From: Wes Date: Thu, 24 Apr 2014 00:23:57 -0500 Subject: [PATCH 3/7] Allow building all known boards at once --- hardware/arduino/boards.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hardware/arduino/boards.txt b/hardware/arduino/boards.txt index 8d22d2b5f0f..613d2f02851 100644 --- a/hardware/arduino/boards.txt +++ b/hardware/arduino/boards.txt @@ -1,6 +1,6 @@ # See: http://code.google.com/p/arduino/wiki/Platforms -############################################################## +############################################################# buildall.name=Build all boards/Upload as Mega 2560 buildall.upload.protocol=arduino From 82f1120f20af0d309187cca033afb8f339679b0f Mon Sep 17 00:00:00 2001 From: Wes Date: Thu, 24 Apr 2014 00:41:49 -0500 Subject: [PATCH 4/7] Don't stop all compiles if one fails --- app/src/processing/app/debug/Compiler.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/src/processing/app/debug/Compiler.java b/app/src/processing/app/debug/Compiler.java index 2f75a7a34d2..6eed611355c 100644 --- a/app/src/processing/app/debug/Compiler.java +++ b/app/src/processing/app/debug/Compiler.java @@ -81,12 +81,14 @@ public boolean compile(Sketch sketch, } Base.getTarget().getBoards(); + boolean compileOk = true; for (Entry> board : Base.getTarget().getBoards().entrySet()) { - if (compileForBoard(sketch, buildPath, primaryClassName, verbose, board.getValue())) - return false; + if (!compileForBoard(sketch, buildPath, primaryClassName, verbose, board.getValue())) { + compileOk = false; + } } - return true; + return compileOk; } private boolean compileForBoard(Sketch sketch, From 0e544e99c56be397e1576bd5cc9c48dc987988d4 Mon Sep 17 00:00:00 2001 From: Wes Date: Thu, 24 Apr 2014 00:44:31 -0500 Subject: [PATCH 5/7] Clean up --- app/src/processing/app/debug/Compiler.java | 1 - 1 file changed, 1 deletion(-) diff --git a/app/src/processing/app/debug/Compiler.java b/app/src/processing/app/debug/Compiler.java index 6eed611355c..52208c56b52 100644 --- a/app/src/processing/app/debug/Compiler.java +++ b/app/src/processing/app/debug/Compiler.java @@ -80,7 +80,6 @@ public boolean compile(Sketch sketch, return compileForBoard(sketch, buildPath, primaryClassName, verbose, boardPreferences); } - Base.getTarget().getBoards(); boolean compileOk = true; for (Entry> board : Base.getTarget().getBoards().entrySet()) { if (!compileForBoard(sketch, buildPath, primaryClassName, verbose, board.getValue())) { From 198909c9ce3f42070a95931cef1f69aa88d0a6de Mon Sep 17 00:00:00 2001 From: Wes Date: Thu, 24 Apr 2014 21:56:24 -0500 Subject: [PATCH 6/7] Helps if you use the right preference --- app/src/processing/app/debug/Compiler.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/processing/app/debug/Compiler.java b/app/src/processing/app/debug/Compiler.java index 52208c56b52..9fab13b5481 100644 --- a/app/src/processing/app/debug/Compiler.java +++ b/app/src/processing/app/debug/Compiler.java @@ -75,8 +75,8 @@ public boolean compile(Sketch sketch, String primaryClassName, boolean verbose) throws RunnerException { Map boardPreferences = Base.getBoardPreferences(); - - if (!Base.getTarget().getName().equals("buildall")) { + + if (!Preferences.get("board").equals("buildall")) { return compileForBoard(sketch, buildPath, primaryClassName, verbose, boardPreferences); } From 3894a76da23b1c6c698943264bd5fbe6f5dd7375 Mon Sep 17 00:00:00 2001 From: Wes Date: Sun, 6 Jul 2014 15:49:49 -0500 Subject: [PATCH 7/7] use board name for hex filename --- app/src/processing/app/debug/Compiler.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/src/processing/app/debug/Compiler.java b/app/src/processing/app/debug/Compiler.java index 9fab13b5481..4eb10599008 100644 --- a/app/src/processing/app/debug/Compiler.java +++ b/app/src/processing/app/debug/Compiler.java @@ -77,12 +77,12 @@ public boolean compile(Sketch sketch, Map boardPreferences = Base.getBoardPreferences(); if (!Preferences.get("board").equals("buildall")) { - return compileForBoard(sketch, buildPath, primaryClassName, verbose, boardPreferences); + return compileForBoard(sketch, buildPath, primaryClassName, verbose, primaryClassName, boardPreferences); } boolean compileOk = true; for (Entry> board : Base.getTarget().getBoards().entrySet()) { - if (!compileForBoard(sketch, buildPath, primaryClassName, verbose, board.getValue())) { + if (!compileForBoard(sketch, buildPath, primaryClassName, verbose, board.getKey(), board.getValue())) { compileOk = false; } } @@ -94,6 +94,7 @@ private boolean compileForBoard(Sketch sketch, String buildPath, String primaryClassName, boolean verbose, + String nameOfHex, Map boardPreferences) throws RunnerException { this.sketch = sketch; this.buildPath = buildPath; @@ -297,7 +298,8 @@ private boolean compileForBoard(Sketch sketch, commandObjcopy.add(2, "ihex"); commandObjcopy.add(".eeprom"); // remove eeprom data commandObjcopy.add(buildPath + File.separator + primaryClassName + ".elf"); - commandObjcopy.add(buildPath + File.separator + primaryClassName + ".hex"); + commandObjcopy.add(buildPath + File.separator + nameOfHex + ".hex"); + execAsynchronously(commandObjcopy); sketch.setCompilingProgress(90);