Bug 480115 - Pick a board any board
authorDoug Schaefer <dschaefer@qnx.com>
Thu, 22 Oct 2015 00:06:29 +0000 (20:06 -0400)
committerGerrit Code Review @ Eclipse.org <gerrit@eclipse.org>
Thu, 22 Oct 2015 02:01:20 +0000 (22:01 -0400)
If Uno isn't installed, pick the first board in the installed board
list instead so we have something and don't NPE.

Change-Id: I691c1a743d374a1950d00c084e74ff8a174efdc0

toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/ArduinoProjectGenerator.java

index 05c24cc..0cdf16f 100644 (file)
@@ -11,6 +11,7 @@
 package org.eclipse.cdt.arduino.core.internal;
 
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 import org.eclipse.cdt.arduino.core.internal.board.ArduinoBoard;
@@ -64,7 +65,16 @@ public class ArduinoProjectGenerator {
                IBuildConfiguration config = project.getBuildConfig("uno"); //$NON-NLS-1$
                ArduinoBuildConfiguration arduinoConfig = config.getAdapter(ArduinoBuildConfiguration.class);
                ArduinoBoard board = ArduinoManager.instance.getBoard("Arduino/Genuino Uno", "Arduino AVR Boards", "arduino"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-               arduinoConfig.setBoard(board);
+               if (board == null) {
+                       // Just find one
+                       List<ArduinoBoard> boards = ArduinoManager.instance.getInstalledBoards();
+                       if (!boards.isEmpty()) {
+                               board = boards.get(0);
+                       }
+               }
+               if (board != null) {
+                       arduinoConfig.setBoard(board);
+               }
 
                // Generate files
                ArduinoTemplateGenerator templateGen = new ArduinoTemplateGenerator();