1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-13 20:15:22 +02:00

Bug 480392 - add inter-platform references and integration tests.

Now have an integration test that builds an empty project for all
boards we can enter into it. This change fixes a bunch of the bugs
that were found making it.

Change-Id: Id62919abd419ac4fef986d620c32ac328eb2cf40
This commit is contained in:
Doug Schaefer 2016-06-03 15:49:57 -04:00
parent 3d27785ea7
commit 8e5b38f590
15 changed files with 525 additions and 146 deletions

View file

@ -0,0 +1,176 @@
/*******************************************************************************
* Copyright (c) 2015, 2016 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*******************************************************************************/
package org.eclipse.cdt.arduino.core.tests;
import java.net.URL;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;
import org.eclipse.cdt.arduino.core.internal.Activator;
import org.eclipse.cdt.arduino.core.internal.ArduinoPreferences;
import org.eclipse.cdt.arduino.core.internal.ArduinoProjectGenerator;
import org.eclipse.cdt.arduino.core.internal.board.ArduinoBoard;
import org.eclipse.cdt.arduino.core.internal.board.ArduinoManager;
import org.eclipse.cdt.arduino.core.internal.board.ArduinoPlatform;
import org.eclipse.cdt.arduino.core.internal.build.ArduinoBuildConfiguration;
import org.eclipse.cdt.arduino.core.internal.build.ArduinoBuildConfigurationProvider;
import org.eclipse.cdt.arduino.core.internal.remote.ArduinoRemoteConnection;
import org.eclipse.cdt.core.build.ICBuildConfigurationManager;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.remote.core.IRemoteConnection;
import org.eclipse.remote.core.IRemoteConnectionType;
import org.eclipse.remote.core.IRemoteConnectionWorkingCopy;
import org.eclipse.remote.core.IRemoteServicesManager;
import org.junit.Test;
@SuppressWarnings("nls")
public class FullIntegration {
private static final ArduinoManager arduinoManager = Activator.getService(ArduinoManager.class);
private static final IRemoteServicesManager remoteManager = Activator.getService(IRemoteServicesManager.class);
private static final ICBuildConfigurationManager buildConfigManager = Activator
.getService(ICBuildConfigurationManager.class);
private void setBoardUrls() throws Exception {
URL[] urls = new URL[] { new URL("http://downloads.arduino.cc/packages/package_index.json"),
new URL("https://adafruit.github.io/arduino-board-index/package_adafruit_index.json") };
ArduinoPreferences.setBoardUrlList(urls);
}
private Set<ArduinoBoard> getSkipBoards() throws Exception {
Set<ArduinoBoard> boards = new HashSet<ArduinoBoard>();
// Fails in arduino too
boards.add(arduinoManager.getBoard("arduino", "avr", "robotControl"));
boards.add(arduinoManager.getBoard("arduino", "avr", "robotMotor"));
boards.add(arduinoManager.getBoard("adafruit", "avr", "adafruit32u4"));
// TODO Need to add support for menu specific build properties
boards.add(arduinoManager.getBoard("arduino", "avr", "mini"));
boards.add(arduinoManager.getBoard("arduino", "avr", "lilypad"));
boards.add(arduinoManager.getBoard("arduino", "avr", "diecimila"));
boards.add(arduinoManager.getBoard("arduino", "avr", "pro"));
boards.add(arduinoManager.getBoard("arduino", "avr", "atmegang"));
boards.add(arduinoManager.getBoard("arduino", "avr", "bt"));
boards.add(arduinoManager.getBoard("arduino", "avr", "mega"));
boards.add(arduinoManager.getBoard("arduino", "avr", "nano"));
boards.add(arduinoManager.getBoard("TeeOnArdu", "avr", "CirPlayTeensyCore"));
boards.add(arduinoManager.getBoard("TeeOnArdu", "avr", "FloraTeensyCore"));
boards.add(arduinoManager.getBoard("TeeOnArdu", "avr", "TeeOnArdu"));
// TODO build.system.path missing
boards.add(arduinoManager.getBoard("arduino", "sam", "arduino_due_x"));
boards.add(arduinoManager.getBoard("arduino", "sam", "arduino_due_x_dbg"));
boards.add(arduinoManager.getBoard("Intel", "arc32", "arduino_101"));
return boards;
}
@Test
public void runTest() throws Exception {
IProgressMonitor monitor = new SysoutProgressMonitor();
setArduinoHome();
setBoardUrls();
loadPlatforms(monitor);
IProject project = createProject(monitor);
Set<ArduinoBoard> skip = getSkipBoards();
for (ArduinoBoard board : arduinoManager.getInstalledBoards()) {
if (!skip.contains(board)) {
buildBoard(project, board, monitor);
}
}
}
private void setArduinoHome() throws Exception {
Path workspace = Paths.get(ResourcesPlugin.getWorkspace().getRoot().getLocationURI());
ArduinoPreferences.setArduinoHome(workspace.resolve(".arduinocdt"));
}
private void loadPlatforms(IProgressMonitor monitor) throws Exception {
Collection<ArduinoPlatform> plats = arduinoManager.getAvailablePlatforms(monitor);
arduinoManager.installPlatforms(plats, monitor);
}
private IProject createProject(IProgressMonitor monitor) throws Exception {
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
String projectName = "ArduinoTest";
ArduinoProjectGenerator generator = new ArduinoProjectGenerator("templates/cppsketch/manifest.xml"); //$NON-NLS-1$
Job job = new Job("Create") {
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
IProject project = root.getProject(projectName);
if (project.exists()) {
project.delete(true, monitor);
}
generator.setProjectName(projectName);
generator.generate(new HashMap<String, Object>(), monitor);
return Status.OK_STATUS;
} catch (CoreException e) {
return e.getStatus();
}
}
};
job.setRule(root);
job.schedule();
job.join();
return generator.getProject();
}
private void buildBoard(IProject project, ArduinoBoard board, IProgressMonitor monitor) throws Exception {
ArduinoRemoteConnection arduinoTarget = createTarget(board);
ArduinoBuildConfigurationProvider provider = (ArduinoBuildConfigurationProvider) buildConfigManager
.getProvider(ArduinoBuildConfigurationProvider.ID);
ArduinoBuildConfiguration config = provider.createConfiguration(project, arduinoTarget, "run", monitor);
System.out.println(String.format("Building board: %s\n %s - %s", board.getName(), board.getId(),
board.getPlatform().getInstallPath()));
config.generateMakeFile(monitor);
ProcessBuilder processBuilder = new ProcessBuilder().command(config.getBuildCommand())
.directory(config.getBuildDirectory().toFile()).inheritIO();
config.setBuildEnvironment(processBuilder.environment());
Process process = processBuilder.start();
int rc = process.waitFor();
if (rc != 0) {
throw new Exception("Build failed");
}
}
private ArduinoRemoteConnection createTarget(ArduinoBoard board) throws Exception {
IRemoteConnectionType type = remoteManager.getConnectionType(ArduinoRemoteConnection.TYPE_ID);
IRemoteConnection connection = type.getConnection(board.getName());
if (connection != null) {
type.removeConnection(connection);
}
IRemoteConnectionWorkingCopy workingCopy = type.newConnection(board.getName());
ArduinoRemoteConnection.setBoardId(workingCopy, board);
ArduinoRemoteConnection.setPortName(workingCopy, "port1");
connection = workingCopy.save();
return connection.getService(ArduinoRemoteConnection.class);
}
}

View file

@ -0,0 +1,38 @@
/*******************************************************************************
* Copyright (c) 2015, 2016 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*******************************************************************************/
package org.eclipse.cdt.arduino.core.tests;
import org.eclipse.core.runtime.NullProgressMonitor;
public class SysoutProgressMonitor extends NullProgressMonitor {
@Override
public void beginTask(String name, int totalWork) {
if (name.length() > 0) {
System.out.println(name);
System.out.flush();
}
}
@Override
public void subTask(String name) {
if (name.length() > 0) {
System.out.println(name);
System.out.flush();
}
}
@Override
public void setTaskName(String name) {
if (name.length() > 0) {
System.out.println(name);
System.out.flush();
}
}
}

View file

@ -38,11 +38,15 @@ public class ArduinoPreferences {
return Paths.get(getPrefs().get(ARDUINO_HOME, defaultHome)); return Paths.get(getPrefs().get(ARDUINO_HOME, defaultHome));
} }
public static void setArduinoHome(Path home) {
getPrefs().put(ARDUINO_HOME, home.toString());
}
public static String getBoardUrls() { public static String getBoardUrls() {
return getPrefs().get(BOARD_URLS, defaultBoardUrls); return getPrefs().get(BOARD_URLS, defaultBoardUrls);
} }
public static Collection<URL> getBoardUrlList() throws CoreException { public static URL[] getBoardUrlList() throws CoreException {
List<URL> urlList = new ArrayList<>(); List<URL> urlList = new ArrayList<>();
for (String url : getBoardUrls().split("\n")) { //$NON-NLS-1$ for (String url : getBoardUrls().split("\n")) { //$NON-NLS-1$
try { try {
@ -51,7 +55,7 @@ public class ArduinoPreferences {
throw Activator.coreException(e); throw Activator.coreException(e);
} }
} }
return urlList; return urlList.toArray(new URL[urlList.size()]);
} }
public static void setBoardUrls(String boardUrls) { public static void setBoardUrls(String boardUrls) {
@ -64,6 +68,22 @@ public class ArduinoPreferences {
} }
} }
public static void setBoardUrlList(URL[] urls) {
StringBuilder str = new StringBuilder();
for (int i = 0; i < urls.length - 1; ++i) {
str.append(urls[i].toString());
str.append('\n');
}
if (urls.length > 0) {
str.append(urls[urls.length - 1].toString());
}
setBoardUrls(str.toString());
}
public static String getDefaultArduinoHome() {
return defaultHome;
}
public static String getDefaultBoardUrls() { public static String getDefaultBoardUrls() {
return defaultBoardUrls; return defaultBoardUrls;
} }

View file

@ -13,8 +13,6 @@ import org.eclipse.cdt.arduino.core.internal.HierarchicalProperties;
public class ArduinoBoard { public class ArduinoBoard {
public static final String MENU_QUALIFIER = "menu_"; //$NON-NLS-1$
private String name; private String name;
private String id; private String id;

View file

@ -219,12 +219,12 @@ public class ArduinoManager {
return pkg != null ? pkg.getInstalledPlatform(architecture) : null; return pkg != null ? pkg.getInstalledPlatform(architecture) : null;
} }
public Collection<ArduinoPlatform> getAvailablePlatforms(IProgressMonitor monitor) throws CoreException { public synchronized Collection<ArduinoPlatform> getAvailablePlatforms(IProgressMonitor monitor) throws CoreException {
List<ArduinoPlatform> platforms = new ArrayList<>(); List<ArduinoPlatform> platforms = new ArrayList<>();
Collection<URL> urls = ArduinoPreferences.getBoardUrlList(); URL[] urls = ArduinoPreferences.getBoardUrlList();
SubMonitor sub = SubMonitor.convert(monitor, urls.size() + 1); SubMonitor sub = SubMonitor.convert(monitor, urls.length + 1);
sub.beginTask("Downloading package descriptions", urls.size()); //$NON-NLS-1$ sub.beginTask("Downloading package descriptions", urls.length); //$NON-NLS-1$
for (URL url : urls) { for (URL url : urls) {
Path packagePath = ArduinoPreferences.getArduinoHome() Path packagePath = ArduinoPreferences.getArduinoHome()
.resolve(Paths.get(url.getPath()).getFileName()); .resolve(Paths.get(url.getPath()).getFileName());
@ -252,7 +252,7 @@ public class ArduinoManager {
public void installPlatforms(Collection<ArduinoPlatform> platforms, IProgressMonitor monitor) throws CoreException { public void installPlatforms(Collection<ArduinoPlatform> platforms, IProgressMonitor monitor) throws CoreException {
SubMonitor sub = SubMonitor.convert(monitor, platforms.size()); SubMonitor sub = SubMonitor.convert(monitor, platforms.size());
for (ArduinoPlatform platform : platforms) { for (ArduinoPlatform platform : platforms) {
sub.setTaskName(String.format("Installing %s", platform.getName())); //$NON-NLS-1$ sub.setTaskName(String.format("Installing %s %s", platform.getName(), platform.getVersion())); //$NON-NLS-1$
platform.install(sub); platform.install(sub);
sub.worked(1); sub.worked(1);
} }
@ -292,7 +292,7 @@ public class ArduinoManager {
return result; return result;
} }
private void initPackages() throws CoreException { private synchronized void initPackages() throws CoreException {
if (packages == null) { if (packages == null) {
init(); init();
packages = new HashMap<>(); packages = new HashMap<>();
@ -326,7 +326,7 @@ public class ArduinoManager {
packages = null; packages = null;
} }
private ArduinoPackage getPackage(String packageName) throws CoreException { public ArduinoPackage getPackage(String packageName) throws CoreException {
if (packageName == null) { if (packageName == null) {
return null; return null;
} else { } else {

View file

@ -92,24 +92,27 @@ public class ArduinoPackage {
if (Files.isDirectory(getInstallPath())) { if (Files.isDirectory(getInstallPath())) {
Path platformTxt = Paths.get("platform.txt"); //$NON-NLS-1$ Path platformTxt = Paths.get("platform.txt"); //$NON-NLS-1$
try { try {
Files.find(getInstallPath().resolve("hardware"), 2, //$NON-NLS-1$ Path hardware = getInstallPath().resolve("hardware");
(path, attrs) -> path.getFileName().equals(platformTxt)) if (Files.exists(hardware)) {
.forEach(path -> { Files.find(hardware, 2, // $NON-NLS-1$
try (FileReader reader = new FileReader(path.toFile())) { (path, attrs) -> path.getFileName().equals(platformTxt)).forEach(path -> {
Properties platformProperties = new Properties(); try (FileReader reader = new FileReader(path.toFile())) {
platformProperties.load(reader); Properties platformProperties = new Properties();
String arch = path.getName(path.getNameCount() - 2).toString(); platformProperties.load(reader);
String version = platformProperties.getProperty("version"); //$NON-NLS-1$ String arch = path.getName(path.getNameCount() - 2).toString();
String version = platformProperties.getProperty("version"); //$NON-NLS-1$
ArduinoPlatform platform = getPlatform(arch, version); ArduinoPlatform platform = getPlatform(arch, version);
if (platform != null) { if (platform != null) {
platform.setPlatformProperties(platformProperties); platform.setPlatformProperties(platformProperties);
installedPlatforms.put(arch, platform); installedPlatforms.put(arch, platform);
} // TODO manually add it if was removed from index } // TODO manually add it if was removed
} catch (IOException e) { // from index
throw new RuntimeException(e); } catch (IOException e) {
} throw new RuntimeException(e);
}); }
});
}
} catch (IOException e) { } catch (IOException e) {
throw Activator.coreException(e); throw Activator.coreException(e);
} }
@ -166,6 +169,18 @@ public class ArduinoPackage {
return null; return null;
} }
public ArduinoTool getLatestTool(String toolName) {
ArduinoTool latest = null;
for (ArduinoTool tool : tools) {
if (tool.getName().equals(toolName) && tool.isInstalled()) {
if (latest == null || ArduinoManager.compareVersions(tool.getVersion(), latest.getVersion()) > 0) {
latest = tool;
}
}
}
return latest;
}
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj instanceof ArduinoPackage) { if (obj instanceof ArduinoPackage) {

View file

@ -209,39 +209,6 @@ public class ArduinoPlatform {
return getPackage().getInstallPath().resolve("hardware").resolve(architecture); //$NON-NLS-1$ return getPackage().getInstallPath().resolve("hardware").resolve(architecture); //$NON-NLS-1$
} }
public List<Path> getIncludePath() {
Path installPath = getInstallPath();
return Arrays.asList(installPath.resolve("cores/{build.core}"), //$NON-NLS-1$
installPath.resolve("variants/{build.variant}")); //$NON-NLS-1$
}
private void getSources(Collection<String> sources, Path dir, boolean recurse) {
for (File file : dir.toFile().listFiles()) {
if (file.isDirectory()) {
if (recurse) {
getSources(sources, file.toPath(), recurse);
}
} else {
if (ArduinoBuildConfiguration.isSource(file.getName())) {
sources.add(ArduinoBuildConfiguration.pathString(file.toPath()));
}
}
}
}
public Collection<String> getSources(String core, String variant) {
List<String> sources = new ArrayList<>();
Path srcPath = getInstallPath().resolve("cores").resolve(core); //$NON-NLS-1$
if (srcPath.toFile().isDirectory()) {
getSources(sources, srcPath, true);
}
Path variantPath = getInstallPath().resolve("variants").resolve(variant); //$NON-NLS-1$
if (variantPath.toFile().isDirectory()) {
getSources(sources, variantPath, true);
}
return sources;
}
private void initLibraries() throws CoreException { private void initLibraries() throws CoreException {
if (libraries == null) { if (libraries == null) {
libraries = new HashMap<>(); libraries = new HashMap<>();

View file

@ -87,6 +87,7 @@ public class ArduinoTool {
for (ArduinoToolSystem system : systems) { for (ArduinoToolSystem system : systems) {
if (system.isApplicable()) { if (system.isApplicable()) {
system.install(monitor); system.install(monitor);
return;
} }
} }

View file

@ -23,8 +23,10 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties; import java.util.Properties;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -38,6 +40,7 @@ import org.eclipse.cdt.arduino.core.internal.board.ArduinoLibrary;
import org.eclipse.cdt.arduino.core.internal.board.ArduinoManager; import org.eclipse.cdt.arduino.core.internal.board.ArduinoManager;
import org.eclipse.cdt.arduino.core.internal.board.ArduinoPackage; import org.eclipse.cdt.arduino.core.internal.board.ArduinoPackage;
import org.eclipse.cdt.arduino.core.internal.board.ArduinoPlatform; import org.eclipse.cdt.arduino.core.internal.board.ArduinoPlatform;
import org.eclipse.cdt.arduino.core.internal.board.ArduinoTool;
import org.eclipse.cdt.arduino.core.internal.board.ToolDependency; import org.eclipse.cdt.arduino.core.internal.board.ToolDependency;
import org.eclipse.cdt.arduino.core.internal.remote.ArduinoRemoteConnection; import org.eclipse.cdt.arduino.core.internal.remote.ArduinoRemoteConnection;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
@ -79,6 +82,7 @@ public class ArduinoBuildConfiguration extends CBuildConfiguration implements Te
private static final String PACKAGE_NAME = "packageName"; //$NON-NLS-1$ private static final String PACKAGE_NAME = "packageName"; //$NON-NLS-1$
private static final String PLATFORM_NAME = "platformName"; //$NON-NLS-1$ private static final String PLATFORM_NAME = "platformName"; //$NON-NLS-1$
private static final String BOARD_NAME = "boardName"; //$NON-NLS-1$ private static final String BOARD_NAME = "boardName"; //$NON-NLS-1$
private static final String MENU_QUALIFIER = "menu_"; //$NON-NLS-1$
private static ArduinoManager manager = Activator.getService(ArduinoManager.class); private static ArduinoManager manager = Activator.getService(ArduinoManager.class);
@ -117,8 +121,7 @@ public class ArduinoBuildConfiguration extends CBuildConfiguration implements Te
} }
ArduinoBuildConfiguration(IBuildConfiguration config, String name, ArduinoBoard board, String launchMode, ArduinoBuildConfiguration(IBuildConfiguration config, String name, ArduinoBoard board, String launchMode,
IToolChain toolChain) IToolChain toolChain) throws CoreException {
throws CoreException {
super(config, name, toolChain); super(config, name, toolChain);
this.board = board; this.board = board;
this.launchMode = launchMode; this.launchMode = launchMode;
@ -148,10 +151,9 @@ public class ArduinoBuildConfiguration extends CBuildConfiguration implements Te
if (menus != null) { if (menus != null) {
Preferences settings = getSettings(); Preferences settings = getSettings();
for (String id : menus.getChildren().keySet()) { for (String id : menus.getChildren().keySet()) {
String key = ArduinoBoard.MENU_QUALIFIER + id; String value = target.getMenuValue(id);
String value = target.getRemoteConnection().getAttribute(key);
if (value != null) { if (value != null) {
settings.put(key, value); settings.put(MENU_QUALIFIER + id, value);
} }
} }
@ -164,7 +166,9 @@ public class ArduinoBuildConfiguration extends CBuildConfiguration implements Te
} }
static String generateName(ArduinoBoard board, String launchMode) { static String generateName(ArduinoBoard board, String launchMode) {
return "arduino." + board.getId() + '.' + launchMode; //$NON-NLS-1$ ArduinoPlatform platform = board.getPlatform();
ArduinoPackage pkg = platform.getPackage();
return pkg.getName() + '.' + platform.getArchitecture() + '.' + board.getId() + '.' + launchMode;
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@ -190,8 +194,7 @@ public class ArduinoBuildConfiguration extends CBuildConfiguration implements Te
HierarchicalProperties menus = board.getMenus(); HierarchicalProperties menus = board.getMenus();
if (menus != null) { if (menus != null) {
for (String id : menus.getChildren().keySet()) { for (String id : menus.getChildren().keySet()) {
String key = ArduinoBoard.MENU_QUALIFIER + id; if (!settings.get(MENU_QUALIFIER + id, "").equals(target.getMenuValue(id))) { //$NON-NLS-1$
if (!settings.get(key, "").equals(target.getRemoteConnection().getAttribute(key))) { //$NON-NLS-1$
return false; return false;
} }
} }
@ -211,19 +214,39 @@ public class ArduinoBuildConfiguration extends CBuildConfiguration implements Te
// IDE generated properties // IDE generated properties
properties = new Properties(); properties = new Properties();
properties.put("runtime.platform.path", platform.getInstallPath().toString()); //$NON-NLS-1$ properties.put("runtime.platform.path", platform.getInstallPath().toString()); //$NON-NLS-1$
properties.put("runtime.ide.version", "10607"); //$NON-NLS-1$ //$NON-NLS-2$ properties.put("runtime.ide.version", "10608"); //$NON-NLS-1$ //$NON-NLS-2$
properties.put("software", "ARDUINO"); //$NON-NLS-1$ //$NON-NLS-2$ properties.put("software", "ARDUINO"); //$NON-NLS-1$ //$NON-NLS-2$
properties.put("build.arch", platform.getArchitecture().toUpperCase()); //$NON-NLS-1$ properties.put("build.arch", platform.getArchitecture().toUpperCase()); //$NON-NLS-1$
String configName = getBuildConfiguration().getName(); String configName = getBuildConfiguration().getName();
if (configName.equals(IBuildConfiguration.DEFAULT_CONFIG_NAME)) { if (configName.equals(IBuildConfiguration.DEFAULT_CONFIG_NAME)) {
configName = "default"; //$NON-NLS-1$ configName = "default"; //$NON-NLS-1$
} }
properties.put("build.path", configName); //$NON-NLS-1$ properties.put("build.path", "."); //$NON-NLS-1$ //$NON-NLS-2$
properties.put("build.variant.path", //$NON-NLS-1$ properties.put("build.variant.path", //$NON-NLS-1$
platform.getInstallPath().resolve("variants").resolve("{build.variant}").toString()); //$NON-NLS-1$ //$NON-NLS-2$ platform.getInstallPath().resolve("variants").resolve("{build.variant}").toString()); //$NON-NLS-1$ //$NON-NLS-2$
// Everyone seems to want to use the avr-gcc tool.
ArduinoPackage arduinoPackage = manager.getPackage("arduino"); //$NON-NLS-1$
ArduinoTool avrgcc = arduinoPackage.getLatestTool("avr-gcc"); //$NON-NLS-1$
if (avrgcc != null) {
properties.put("runtime.tools.avr-gcc.path", avrgcc.getInstallPath().toString()); //$NON-NLS-1$
}
// Super Platform
String core = board.getBoardProperties().getProperty("build.core"); //$NON-NLS-1$
if (core.contains(":")) { //$NON-NLS-1$
String[] segments = core.split(":"); //$NON-NLS-1$
if (segments.length == 2) {
ArduinoPlatform superPlatform = manager.getInstalledPlatform(segments[0],
platform.getArchitecture());
if (superPlatform != null) {
properties.putAll(superPlatform.getPlatformProperties());
}
}
}
// Platform // Platform
properties.putAll(board.getPlatform().getPlatformProperties()); properties.putAll(platform.getPlatformProperties());
// Tools // Tools
for (ToolDependency toolDep : platform.getToolsDependencies()) { for (ToolDependency toolDep : platform.getToolsDependencies()) {
@ -238,10 +261,18 @@ public class ArduinoBuildConfiguration extends CBuildConfiguration implements Te
Preferences settings = getSettings(); Preferences settings = getSettings();
HierarchicalProperties menus = board.getMenus(); HierarchicalProperties menus = board.getMenus();
if (menus != null) { if (menus != null) {
for (String menuId : menus.getChildren().keySet()) { for (Entry<String, HierarchicalProperties> menuEntry : menus.getChildren().entrySet()) {
String value = settings.get(ArduinoBoard.MENU_QUALIFIER + menuId, ""); //$NON-NLS-1$ String key = menuEntry.getKey();
String defaultValue;
Iterator<HierarchicalProperties> i = menuEntry.getValue().getChildren().values().iterator();
if (i.hasNext()) {
defaultValue = i.next().getValue();
} else {
defaultValue = ""; //$NON-NLS-1$
}
String value = settings.get(MENU_QUALIFIER + key, defaultValue);
if (!value.isEmpty()) { if (!value.isEmpty()) {
properties.putAll(board.getMenuProperties(menuId, value)); properties.putAll(board.getMenuProperties(key, value));
} }
} }
} }
@ -252,13 +283,6 @@ public class ArduinoBuildConfiguration extends CBuildConfiguration implements Te
return properties; return properties;
} }
public IFile getMakeFile() throws CoreException {
IFolder buildFolder = (IFolder) getBuildContainer();
ArduinoBoard board = getBoard();
String makeFileName = board.getId() + ".mk"; //$NON-NLS-1$
return buildFolder.getFile(makeFileName);
}
public Map<String, Object> getBuildModel() throws CoreException { public Map<String, Object> getBuildModel() throws CoreException {
IProject project = getProject(); IProject project = getProject();
ArduinoBoard board = getBoard(); ArduinoBoard board = getBoard();
@ -301,7 +325,7 @@ public class ArduinoBuildConfiguration extends CBuildConfiguration implements Te
buildModel.put("project_name", project.getName()); //$NON-NLS-1$ buildModel.put("project_name", project.getName()); //$NON-NLS-1$
String includes = null; String includes = null;
for (Path include : platform.getIncludePath()) { for (Path include : getIncludePath(platform, properties)) {
if (includes == null) { if (includes == null) {
includes = "-I"; //$NON-NLS-1$ includes = "-I"; //$NON-NLS-1$
} else { } else {
@ -316,10 +340,35 @@ public class ArduinoBuildConfiguration extends CBuildConfiguration implements Te
} }
properties.put("includes", includes); //$NON-NLS-1$ properties.put("includes", includes); //$NON-NLS-1$
Path platformPath = platform.getInstallPath(); ArduinoPlatform corePlatform = platform;
buildModel.put("platform_path", pathString(platformPath).replace("+", "\\+")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ String core = properties.getProperty("build.core"); //$NON-NLS-1$
buildModel.put("platform_srcs", //$NON-NLS-1$ if (core.contains(":")) { //$NON-NLS-1$
platform.getSources(properties.getProperty("build.core"), properties.getProperty("build.variant"))); //$NON-NLS-1$ //$NON-NLS-2$ String[] segments = core.split(":"); //$NON-NLS-1$
if (segments.length == 2) {
corePlatform = manager.getInstalledPlatform(segments[0], platform.getArchitecture());
core = segments[1];
}
}
Path corePath = corePlatform.getInstallPath().resolve("cores").resolve(core); //$NON-NLS-1$
buildModel.put("platform_core_path", pathString(corePath)); //$NON-NLS-1$
List<String> coreSources = new ArrayList<>();
getSources(coreSources, corePath, true);
buildModel.put("platform_core_srcs", coreSources); //$NON-NLS-1$
ArduinoPlatform variantPlatform = platform;
String variant = properties.getProperty("build.variant"); //$NON-NLS-1$
if (variant.contains(":")) { //$NON-NLS-1$
String[] segments = variant.split(":"); //$NON-NLS-1$
if (segments.length == 2) {
variantPlatform = manager.getInstalledPlatform(segments[0], platform.getArchitecture());
variant = segments[1];
}
}
Path variantPath = variantPlatform.getInstallPath().resolve("variants").resolve(variant); //$NON-NLS-1$
buildModel.put("platform_variant_path", pathString(variantPath)); //$NON-NLS-1$
List<String> variantSources = new ArrayList<>();
getSources(variantSources, variantPath, true);
buildModel.put("platform_variant_srcs", variantSources); //$NON-NLS-1$
properties.put("object_file", "$@"); //$NON-NLS-1$ //$NON-NLS-2$ properties.put("object_file", "$@"); //$NON-NLS-1$ //$NON-NLS-2$
properties.put("source_file", "$<"); //$NON-NLS-1$ //$NON-NLS-2$ properties.put("source_file", "$<"); //$NON-NLS-1$ //$NON-NLS-2$
@ -340,13 +389,27 @@ public class ArduinoBuildConfiguration extends CBuildConfiguration implements Te
return buildModel; return buildModel;
} }
private static void getSources(Collection<String> sources, Path dir, boolean recurse) {
for (File file : dir.toFile().listFiles()) {
if (file.isDirectory()) {
if (recurse) {
getSources(sources, file.toPath(), recurse);
}
} else {
if (ArduinoBuildConfiguration.isSource(file.getName())) {
sources.add(ArduinoBuildConfiguration.pathString(file.toPath()));
}
}
}
}
public IFile generateMakeFile(IProgressMonitor monitor) throws CoreException { public IFile generateMakeFile(IProgressMonitor monitor) throws CoreException {
IFolder buildFolder = (IFolder) getBuildContainer(); IFolder buildFolder = (IFolder) getBuildContainer();
if (!buildFolder.exists()) { if (!buildFolder.exists()) {
buildFolder.create(true, true, monitor); buildFolder.create(true, true, monitor);
} }
IFile makefile = getMakeFile(); IFile makefile = buildFolder.getFile("Makefile"); //$NON-NLS-1$
Map<String, Object> buildModel = getBuildModel(); Map<String, Object> buildModel = getBuildModel();
@ -402,7 +465,7 @@ public class ArduinoBuildConfiguration extends CBuildConfiguration implements Te
} }
} }
private String resolvePropertyValue(String value, Properties dict) { private String resolvePropertyValue(String value, Properties dict) throws CoreException {
String last; String last;
do { do {
last = value; last = value;
@ -414,6 +477,8 @@ public class ArduinoBuildConfiguration extends CBuildConfiguration implements Te
String r2 = dict.getProperty(p2); String r2 = dict.getProperty(p2);
if (r2 != null) { if (r2 != null) {
value = value.replace('{' + p2 + '}', r2); value = value.replace('{' + p2 + '}', r2);
} else {
throw Activator.coreException(String.format("Undefined key %s", p2), null);
} }
} }
i = n; i = n;
@ -423,7 +488,7 @@ public class ArduinoBuildConfiguration extends CBuildConfiguration implements Te
return value; return value;
} }
private String resolveProperty(String property, Properties dict) { private String resolveProperty(String property, Properties dict) throws CoreException {
String value = dict.getProperty(property); String value = dict.getProperty(property);
return value != null ? resolvePropertyValue(value, dict) : null; return value != null ? resolvePropertyValue(value, dict) : null;
} }
@ -433,17 +498,17 @@ public class ArduinoBuildConfiguration extends CBuildConfiguration implements Te
} }
public String[] getBuildCommand() throws CoreException { public String[] getBuildCommand() throws CoreException {
return new String[] { getMakeCommand(), "-f", getMakeFile().getName() }; //$NON-NLS-1$ return new String[] { getMakeCommand() };
} }
public String[] getCleanCommand() throws CoreException { public String[] getCleanCommand() throws CoreException {
return new String[] { getMakeCommand(), "-f", getMakeFile().getName(), "clean" }; //$NON-NLS-1$ //$NON-NLS-2$ return new String[] { getMakeCommand(), "clean" }; //$NON-NLS-1$
} }
public String[] getSizeCommand() throws CoreException { public String[] getSizeCommand() throws CoreException {
// TODO this shouldn't be in the makefile // TODO this shouldn't be in the makefile
// should be like the upload command // should be like the upload command
return new String[] { getMakeCommand(), "-f", getMakeFile().getName(), "size" }; //$NON-NLS-1$ //$NON-NLS-2$ return new String[] { getMakeCommand(), "size" }; //$NON-NLS-1$
} }
public String getCodeSizeRegex() throws CoreException { public String getCodeSizeRegex() throws CoreException {
@ -508,6 +573,31 @@ public class ArduinoBuildConfiguration extends CBuildConfiguration implements Te
} }
} }
private Collection<Path> getIncludePath(ArduinoPlatform platform, Properties properties) throws CoreException {
ArduinoPlatform corePlatform = platform;
String core = properties.getProperty("build.core"); //$NON-NLS-1$
if (core.contains(":")) { //$NON-NLS-1$
String[] segments = core.split(":"); //$NON-NLS-1$
if (segments.length == 2) {
corePlatform = manager.getInstalledPlatform(segments[0], platform.getArchitecture());
core = segments[1];
}
}
ArduinoPlatform variantPlatform = platform;
String variant = properties.getProperty("build.variant"); //$NON-NLS-1$
if (variant.contains(":")) { //$NON-NLS-1$
String[] segments = variant.split(":"); //$NON-NLS-1$
if (segments.length == 2) {
variantPlatform = manager.getInstalledPlatform(segments[0], platform.getArchitecture());
variant = segments[1];
}
}
return Arrays.asList(corePlatform.getInstallPath().resolve("cores").resolve(core), //$NON-NLS-1$
variantPlatform.getInstallPath().resolve("variants").resolve(variant)); //$NON-NLS-1$
}
// Scanner Info Cache // Scanner Info Cache
private String[] cachedIncludePath; private String[] cachedIncludePath;
private String cachedInfoCommand; private String cachedInfoCommand;
@ -537,14 +627,27 @@ public class ArduinoBuildConfiguration extends CBuildConfiguration implements Te
String commandString = resolveProperty(recipe, properties); String commandString = resolveProperty(recipe, properties);
List<Path> includePath = new ArrayList<>(); List<Path> includePath = new ArrayList<>();
includePath.addAll(platform.getIncludePath()); includePath.addAll(getIncludePath(platform, properties));
Collection<ArduinoLibrary> libs = manager.getLibraries(getProject()); Collection<ArduinoLibrary> libs = manager.getLibraries(getProject());
for (ArduinoLibrary lib : libs) { for (ArduinoLibrary lib : libs) {
includePath.addAll(lib.getIncludePath()); includePath.addAll(lib.getIncludePath());
} }
String[] includes = includePath.stream() String[] includes = null;
.map(path -> resolvePropertyValue(path.toString(), properties)).collect(Collectors.toList()) try {
.toArray(new String[includePath.size()]); includes = includePath.stream().map(path -> {
try {
return resolvePropertyValue(path.toString(), properties);
} catch (CoreException e) {
throw new RuntimeException(e);
}
}).collect(Collectors.toList()).toArray(new String[includePath.size()]);
} catch (RuntimeException e) {
if (e.getCause() != null && e.getCause() instanceof CoreException) {
throw (CoreException) e.getCause();
} else {
throw e;
}
}
// Use cache if we can // Use cache if we can
if (cachedScannerInfo != null && cachedInfoCommand.equals(commandString) if (cachedScannerInfo != null && cachedInfoCommand.equals(commandString)

View file

@ -55,7 +55,7 @@ public class ArduinoBuildConfigurationProvider implements ICBuildConfigurationPr
IToolChain toolChain = new ArduinoToolChain(provider, config); IToolChain toolChain = new ArduinoToolChain(provider, config);
toolChainManager.addToolChain(toolChain); toolChainManager.addToolChain(toolChain);
return new ArduinoBuildConfiguration(config, name, board, "run", toolChain); return new ArduinoBuildConfiguration(config, name, board, "run", toolChain); //$NON-NLS-1$
} }
return null; return null;
} else { } else {

View file

@ -17,12 +17,15 @@ import java.util.Map;
import org.eclipse.cdt.arduino.core.internal.Activator; import org.eclipse.cdt.arduino.core.internal.Activator;
import org.eclipse.cdt.arduino.core.internal.board.ArduinoBoard; import org.eclipse.cdt.arduino.core.internal.board.ArduinoBoard;
import org.eclipse.cdt.arduino.core.internal.board.ArduinoManager; import org.eclipse.cdt.arduino.core.internal.board.ArduinoManager;
import org.eclipse.cdt.arduino.core.internal.board.ArduinoPackage;
import org.eclipse.cdt.arduino.core.internal.board.ArduinoPlatform;
import org.eclipse.cdt.serial.SerialPort; import org.eclipse.cdt.serial.SerialPort;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.remote.core.IRemoteCommandShellService; import org.eclipse.remote.core.IRemoteCommandShellService;
import org.eclipse.remote.core.IRemoteConnection; import org.eclipse.remote.core.IRemoteConnection;
import org.eclipse.remote.core.IRemoteConnectionChangeListener; import org.eclipse.remote.core.IRemoteConnectionChangeListener;
import org.eclipse.remote.core.IRemoteConnectionPropertyService; import org.eclipse.remote.core.IRemoteConnectionPropertyService;
import org.eclipse.remote.core.IRemoteConnectionWorkingCopy;
import org.eclipse.remote.core.IRemoteProcess; import org.eclipse.remote.core.IRemoteProcess;
import org.eclipse.remote.core.RemoteConnectionChangeEvent; import org.eclipse.remote.core.RemoteConnectionChangeEvent;
import org.eclipse.remote.serial.core.SerialPortCommandShell; import org.eclipse.remote.serial.core.SerialPortCommandShell;
@ -31,10 +34,12 @@ public class ArduinoRemoteConnection
implements IRemoteConnectionPropertyService, IRemoteCommandShellService, IRemoteConnectionChangeListener { implements IRemoteConnectionPropertyService, IRemoteCommandShellService, IRemoteConnectionChangeListener {
public static final String TYPE_ID = "org.eclipse.cdt.arduino.core.connectionType"; //$NON-NLS-1$ public static final String TYPE_ID = "org.eclipse.cdt.arduino.core.connectionType"; //$NON-NLS-1$
public static final String PORT_NAME = "arduinoPortName"; //$NON-NLS-1$
public static final String PACKAGE_NAME = "arduinoPackageName"; //$NON-NLS-1$ private static final String PORT_NAME = "arduinoPortName"; //$NON-NLS-1$
public static final String PLATFORM_NAME = "arduinoPlatformName"; //$NON-NLS-1$ private static final String PACKAGE_NAME = "arduinoPackageName"; //$NON-NLS-1$
public static final String BOARD_NAME = "arduinoBoardName"; //$NON-NLS-1$ private static final String PLATFORM_NAME = "arduinoPlatformName"; //$NON-NLS-1$
private static final String BOARD_NAME = "arduinoBoardName"; //$NON-NLS-1$
private static final String MENU_QUALIFIER = "menu_"; //$NON-NLS-1$
private final IRemoteConnection remoteConnection; private final IRemoteConnection remoteConnection;
private SerialPort serialPort; private SerialPort serialPort;
@ -47,6 +52,28 @@ public class ArduinoRemoteConnection
remoteConnection.addConnectionChangeListener(this); remoteConnection.addConnectionChangeListener(this);
} }
public static void setBoardId(IRemoteConnectionWorkingCopy workingCopy, ArduinoBoard board) {
workingCopy.setAttribute(BOARD_NAME, board.getId());
ArduinoPlatform platform = board.getPlatform();
workingCopy.setAttribute(PLATFORM_NAME, platform.getArchitecture());
ArduinoPackage pkg = platform.getPackage();
workingCopy.setAttribute(PACKAGE_NAME, pkg.getName());
}
public static void setPortName(IRemoteConnectionWorkingCopy workingCopy, String portName) {
workingCopy.setAttribute(PORT_NAME, portName);
}
public static void setMenuValue(IRemoteConnectionWorkingCopy workingCopy, String key, String value) {
workingCopy.setAttribute(MENU_QUALIFIER + key, value);
}
public String getMenuValue(String key) {
return remoteConnection.getAttribute(MENU_QUALIFIER + key);
}
@Override @Override
public void connectionChanged(RemoteConnectionChangeEvent event) { public void connectionChanged(RemoteConnectionChangeEvent event) {
if (event.getType() == RemoteConnectionChangeEvent.CONNECTION_REMOVED) { if (event.getType() == RemoteConnectionChangeEvent.CONNECTION_REMOVED) {

View file

@ -15,19 +15,35 @@ PROJECT_OBJS = \
</#if> </#if>
</#list> </#list>
PLATFORM_OBJS = \ PLATFORM_CORE_OBJS = \
<#list platform_srcs as file> <#list platform_core_srcs as file>
<#assign cpp = file?matches("${platform_path}/(.*)\\.cpp")> <#assign cpp = file?matches("${platform_core_path}/(.*)\\.cpp")>
<#if cpp> <#if cpp>
${build_path}/platform/${cpp?groups[1]}.cpp.o \ ${build_path}/core/${cpp?groups[1]}.cpp.o \
</#if> </#if>
<#assign c = file?matches("${platform_path}/(.*)\\.c")> <#assign c = file?matches("${platform_core_path}/(.*)\\.c")>
<#if c> <#if c>
${build_path}/platform/${c?groups[1]}.c.o \ ${build_path}/core/${c?groups[1]}.c.o \
</#if> </#if>
<#assign S = file?matches("${platform_path}/(.*)\\.S")> <#assign S = file?matches("${platform_core_path}/(.*)\\.S")>
<#if S> <#if S>
${build_path}/platform/${S?groups[1]}.S.o \ ${build_path}/core/${S?groups[1]}.S.o \
</#if>
</#list>
PLATFORM_VARIANT_OBJS = \
<#list platform_variant_srcs as file>
<#assign cpp = file?matches("${platform_variant_path}/(.*)\\.cpp")>
<#if cpp>
${build_path}/variant/${cpp?groups[1]}.cpp.o \
</#if>
<#assign c = file?matches("${platform_variant_path}/(.*)\\.c")>
<#if c>
${build_path}/variant/${c?groups[1]}.c.o \
</#if>
<#assign S = file?matches("${platform_variant_path}/(.*)\\.S")>
<#if S>
${build_path}/variant/${S?groups[1]}.S.o \
</#if> </#if>
</#list> </#list>
@ -80,7 +96,7 @@ ${build_path}/${project_name}.bin: ${build_path}/${project_name}.elf
${build_path}/${project_name}.elf: $(PROJECT_OBJS) $(LIBRARIES_OBJS) ${build_path}/core.a ${build_path}/${project_name}.elf: $(PROJECT_OBJS) $(LIBRARIES_OBJS) ${build_path}/core.a
${recipe_c_combine_pattern} ${recipe_c_combine_pattern}
${build_path}/core.a: $(PLATFORM_OBJS) ${build_path}/core.a: $(PLATFORM_CORE_OBJS) $(PLATFORM_VARIANT_OBJS)
clean: clean:
$(RMDIR) ${build_path} $(RMDIR) ${build_path}
@ -102,34 +118,69 @@ ${build_path}/project/${cpp?groups[1]}.cpp.d: ;
</#if> </#if>
</#list> </#list>
<#list platform_srcs as file> <#list platform_core_srcs as file>
<#assign cpp = file?matches("${platform_path}/(.*)\\.cpp")> <#assign cpp = file?matches("${platform_core_path}/(.*)\\.cpp")>
<#if cpp> <#if cpp>
${build_path}/platform/${cpp?groups[1]}.cpp.o: ${file} ${build_path}/platform/${cpp?groups[1]}.cpp.d ${build_path}/core/${cpp?groups[1]}.cpp.o: ${file} ${build_path}/core/${cpp?groups[1]}.cpp.d
@$(call mymkdir,$(dir $@)) @$(call mymkdir,$(dir $@))
${recipe_cpp_o_pattern} ${recipe_cpp_o_pattern}
${recipe_ar_pattern} ${recipe_ar_pattern}
${build_path}/platform/${cpp?groups[1]}.cpp.d: ; ${build_path}/core/${cpp?groups[1]}.cpp.d: ;
-include ${build_path}/platform/${cpp?groups[1]}.cpp.d -include ${build_path}/core/${cpp?groups[1]}.cpp.d
</#if> </#if>
<#assign c = file?matches("${platform_path}/(.*)\\.c")> <#assign c = file?matches("${platform_core_path}/(.*)\\.c")>
<#if c> <#if c>
${build_path}/platform/${c?groups[1]}.c.o: ${file} ${build_path}/platform/${c?groups[1]}.c.d ${build_path}/core/${c?groups[1]}.c.o: ${file} ${build_path}/core/${c?groups[1]}.c.d
@$(call mymkdir,$(dir $@)) @$(call mymkdir,$(dir $@))
${recipe_c_o_pattern} ${recipe_c_o_pattern}
${recipe_ar_pattern} ${recipe_ar_pattern}
${build_path}/platform/${c?groups[1]}.c.d: ; ${build_path}/core/${c?groups[1]}.c.d: ;
-include ${build_path}/platform/${c?groups[1]}.c.d -include ${build_path}/core/${c?groups[1]}.c.d
</#if> </#if>
<#assign S = file?matches("${platform_path}/(.*)\\.S")> <#assign S = file?matches("${platform_core_path}/(.*)\\.S")>
<#if S> <#if S>
${build_path}/platform/${S?groups[1]}.S.o: ${file} ${build_path}/core/${S?groups[1]}.S.o: ${file}
@$(call mymkdir,$(dir $@))
${recipe_S_o_pattern}
${recipe_ar_pattern}
</#if>
</#list>
<#list platform_variant_srcs as file>
<#assign cpp = file?matches("${platform_variant_path}/(.*)\\.cpp")>
<#if cpp>
${build_path}/variant/${cpp?groups[1]}.cpp.o: ${file} ${build_path}/variant/${cpp?groups[1]}.cpp.d
@$(call mymkdir,$(dir $@))
${recipe_cpp_o_pattern}
${recipe_ar_pattern}
${build_path}/variant/${cpp?groups[1]}.cpp.d: ;
-include ${build_path}/variant/${cpp?groups[1]}.cpp.d
</#if>
<#assign c = file?matches("${platform_variant_path}/(.*)\\.c")>
<#if c>
${build_path}/variant/${c?groups[1]}.c.o: ${file} ${build_path}/variant/${c?groups[1]}.c.d
@$(call mymkdir,$(dir $@))
${recipe_c_o_pattern}
${recipe_ar_pattern}
${build_path}/variant/${c?groups[1]}.c.d: ;
-include ${build_path}/variant/${c?groups[1]}.c.d
</#if>
<#assign S = file?matches("${platform_variant_path}/(.*)\\.S")>
<#if S>
${build_path}/variant/${S?groups[1]}.S.o: ${file}
@$(call mymkdir,$(dir $@)) @$(call mymkdir,$(dir $@))
${recipe_S_o_pattern} ${recipe_S_o_pattern}
${recipe_ar_pattern} ${recipe_ar_pattern}

View file

@ -86,12 +86,6 @@
id="org.eclipse.cdt.arduino.preference.page" id="org.eclipse.cdt.arduino.preference.page"
name="%preferencePage.name"> name="%preferencePage.name">
</page> </page>
<page
category="org.eclipse.cdt.arduino.preference.page"
class="org.eclipse.cdt.arduino.ui.internal.preferences.ArduinoPlatformsPreferencePage"
id="org.eclipse.cdt.arduino.ui.page.platforms"
name="Platforms">
</page>
</extension> </extension>
<extension <extension
point="org.eclipse.ui.perspectiveExtensions"> point="org.eclipse.ui.perspectiveExtensions">

View file

@ -96,15 +96,11 @@ public class ArduinoTargetPropertyPage extends PropertyPage implements IWorkbenc
IRemoteConnection remoteConnection = getElement().getAdapter(IRemoteConnection.class); IRemoteConnection remoteConnection = getElement().getAdapter(IRemoteConnection.class);
IRemoteConnectionWorkingCopy workingCopy = remoteConnection.getWorkingCopy(); IRemoteConnectionWorkingCopy workingCopy = remoteConnection.getWorkingCopy();
String portName = portSelector.getItem(portSelector.getSelectionIndex());
workingCopy.setAttribute(ArduinoRemoteConnection.PORT_NAME, portName);
ArduinoBoard board = boards[boardSelector.getSelectionIndex()]; ArduinoBoard board = boards[boardSelector.getSelectionIndex()];
workingCopy.setAttribute(ArduinoRemoteConnection.BOARD_NAME, board.getId()); ArduinoRemoteConnection.setBoardId(workingCopy, board);
ArduinoPlatform platform = board.getPlatform();
workingCopy.setAttribute(ArduinoRemoteConnection.PLATFORM_NAME, platform.getArchitecture()); String portName = portSelector.getItem(portSelector.getSelectionIndex());
ArduinoPackage pkg = platform.getPackage(); ArduinoRemoteConnection.setPortName(workingCopy, portName);
workingCopy.setAttribute(ArduinoRemoteConnection.PACKAGE_NAME, pkg.getName());
try { try {
workingCopy.save(); workingCopy.save();

View file

@ -188,15 +188,8 @@ public class BoardPropertyControl extends Composite {
} }
public void apply(IRemoteConnectionWorkingCopy workingCopy) { public void apply(IRemoteConnectionWorkingCopy workingCopy) {
workingCopy.setAttribute(ArduinoRemoteConnection.PORT_NAME, portName); ArduinoRemoteConnection.setBoardId(workingCopy, board);
ArduinoRemoteConnection.setPortName(workingCopy, portName);
workingCopy.setAttribute(ArduinoRemoteConnection.BOARD_NAME, board.getId());
ArduinoPlatform platform = board.getPlatform();
workingCopy.setAttribute(ArduinoRemoteConnection.PLATFORM_NAME, platform.getArchitecture());
ArduinoPackage pkg = platform.getPackage();
workingCopy.setAttribute(ArduinoRemoteConnection.PACKAGE_NAME, pkg.getName());
String key = null; String key = null;
for (Control control : menuControls) { for (Control control : menuControls) {
@ -208,7 +201,7 @@ public class BoardPropertyControl extends Composite {
String value = ((List<String>) combo.getData()).get(combo.getSelectionIndex()); String value = ((List<String>) combo.getData()).get(combo.getSelectionIndex());
if (key != null) { if (key != null) {
workingCopy.setAttribute(ArduinoBoard.MENU_QUALIFIER + key, value); ArduinoRemoteConnection.setMenuValue(workingCopy, key, value);
} }
} }
} }