mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-22 14:12:10 +02:00
Start restructuring Arduino CDT to use index files.
Change-Id: Ibfa9b1e679d737c53b28700341e91d0dcacaba0f
This commit is contained in:
parent
f047a404b0
commit
05a2939d54
26 changed files with 580 additions and 349 deletions
|
@ -2,26 +2,14 @@ package org.eclipse.cdt.arduino.core.tests;
|
|||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import java.util.concurrent.Semaphore;
|
||||
|
||||
import org.eclipse.cdt.arduino.core.IArduinoBoardManager.Handler;
|
||||
import org.eclipse.cdt.arduino.core.internal.board.ArduinoBoardManager;
|
||||
import org.eclipse.cdt.arduino.core.internal.board.PackageIndex;
|
||||
import org.eclipse.cdt.arduino.core.board.ArduinoBoardManager;
|
||||
import org.junit.Test;
|
||||
|
||||
public class BoardManagerTests {
|
||||
|
||||
@Test
|
||||
public void loadPackagesTest() throws Exception {
|
||||
Semaphore semaphore = new Semaphore(0);
|
||||
new ArduinoBoardManager().getPackageIndex(new Handler<PackageIndex>() {
|
||||
@Override
|
||||
public void handle(PackageIndex result) {
|
||||
assertNotNull(result);
|
||||
semaphore.release();
|
||||
}
|
||||
});
|
||||
semaphore.acquire();
|
||||
assertNotNull(ArduinoBoardManager.instance.getPackageIndex());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -22,5 +22,6 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.7
|
|||
Bundle-ActivationPolicy: lazy
|
||||
Bundle-ClassPath: libs/freemarker-2.3.22.jar,
|
||||
.
|
||||
Export-Package: org.eclipse.cdt.arduino.core
|
||||
Export-Package: org.eclipse.cdt.arduino.core,
|
||||
org.eclipse.cdt.arduino.core.board
|
||||
Bundle-Localization: plugin
|
||||
|
|
|
@ -49,6 +49,22 @@
|
|||
resourceFilter="all"
|
||||
valueType="string">
|
||||
</option>
|
||||
<option
|
||||
category="org.eclipse.cdt.arduino.optionCategory.board"
|
||||
id="org.eclipse.cdt.arduino.option.platform"
|
||||
isAbstract="false"
|
||||
name="Board Platform"
|
||||
resourceFilter="all"
|
||||
valueType="string">
|
||||
</option>
|
||||
<option
|
||||
category="org.eclipse.cdt.arduino.optionCategory.board"
|
||||
id="org.eclipse.cdt.arduino.option.package"
|
||||
isAbstract="false"
|
||||
name="Board Package"
|
||||
resourceFilter="all"
|
||||
valueType="string">
|
||||
</option>
|
||||
<optionCategory
|
||||
id="org.eclipse.cdt.arduino.optionCategory.board"
|
||||
name="Board Type">
|
||||
|
|
|
@ -22,22 +22,16 @@ import java.util.Collection;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.cdt.arduino.core.board.ArduinoBoardManager;
|
||||
import org.eclipse.cdt.arduino.core.internal.Activator;
|
||||
import org.eclipse.cdt.arduino.core.internal.ArduinoProjectNature;
|
||||
import org.eclipse.cdt.arduino.core.internal.Messages;
|
||||
import org.eclipse.cdt.arduino.core.internal.remote.ArduinoRemoteConnection;
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
||||
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
|
||||
import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
|
||||
import org.eclipse.cdt.managedbuilder.core.BuildException;
|
||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||
import org.eclipse.cdt.managedbuilder.core.IOption;
|
||||
import org.eclipse.cdt.managedbuilder.core.IToolChain;
|
||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||
import org.eclipse.cdt.managedbuilder.internal.core.ManagedBuildInfo;
|
||||
import org.eclipse.cdt.managedbuilder.internal.core.ManagedProject;
|
||||
import org.eclipse.cdt.managedbuilder.internal.core.ToolChain;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IProjectDescription;
|
||||
|
@ -60,9 +54,6 @@ import freemarker.template.TemplateException;
|
|||
@SuppressWarnings("restriction")
|
||||
public class ArduinoProjectGenerator {
|
||||
|
||||
public static final String BOARD_OPTION_ID = "org.eclipse.cdt.arduino.option.board"; //$NON-NLS-1$
|
||||
public static final String AVR_TOOLCHAIN_ID = "org.eclipse.cdt.arduino.toolChain.avr"; //$NON-NLS-1$
|
||||
|
||||
private final IProject project;
|
||||
private IFile sourceFile;
|
||||
|
||||
|
@ -87,22 +78,23 @@ public class ArduinoProjectGenerator {
|
|||
ManagedProject mProj = new ManagedProject(cprojDesc);
|
||||
info.setManagedProject(mProj);
|
||||
|
||||
Board board = null;
|
||||
// TODO make this a preference, the default board
|
||||
String boardId = "uno"; //$NON-NLS-1$
|
||||
String platformId = "avr"; //$NON-NLS-1$
|
||||
String packageId = "arduino"; //$NON-NLS-1$
|
||||
|
||||
IRemoteServicesManager remoteManager = Activator.getService(IRemoteServicesManager.class);
|
||||
IRemoteConnectionType connectionType = remoteManager.getConnectionType(ArduinoRemoteConnection.TYPE_ID);
|
||||
Collection<IRemoteConnection> connections = connectionType.getConnections();
|
||||
if (!connections.isEmpty()) {
|
||||
IRemoteConnection firstConnection = connections.iterator().next();
|
||||
IArduinoRemoteConnection firstArduino = firstConnection.getService(IArduinoRemoteConnection.class);
|
||||
board = firstArduino.getBoard();
|
||||
boardId = firstArduino.getBoardId();
|
||||
platformId = firstArduino.getPlatformId();
|
||||
packageId = firstArduino.getPackageId();
|
||||
}
|
||||
|
||||
if (board == null) {
|
||||
IArduinoBoardManager boardManager = Activator.getService(IArduinoBoardManager.class);
|
||||
board = boardManager.getBoard("uno"); // the default //$NON-NLS-1$
|
||||
}
|
||||
|
||||
createBuildConfiguration(cprojDesc, board);
|
||||
ArduinoBoardManager.instance.createBuildConfiguration(cprojDesc, boardId, platformId, packageId);
|
||||
CCorePlugin.getDefault().setProjectDescription(project, cprojDesc, true, monitor);
|
||||
|
||||
// Generate files
|
||||
|
@ -160,39 +152,6 @@ public class ArduinoProjectGenerator {
|
|||
throw new CoreException(status);
|
||||
}
|
||||
|
||||
public static ICConfigurationDescription createBuildConfiguration(ICProjectDescription projDesc, Board board)
|
||||
throws CoreException {
|
||||
ManagedProject managedProject = new ManagedProject(projDesc);
|
||||
String configId = ManagedBuildManager.calculateChildId(AVR_TOOLCHAIN_ID, null);
|
||||
IToolChain avrToolChain = ManagedBuildManager.getExtensionToolChain(AVR_TOOLCHAIN_ID);
|
||||
org.eclipse.cdt.managedbuilder.internal.core.Configuration newConfig = new org.eclipse.cdt.managedbuilder.internal.core.Configuration(
|
||||
managedProject, (ToolChain) avrToolChain, configId, board.getId());
|
||||
IToolChain newToolChain = newConfig.getToolChain();
|
||||
IOption newOption = newToolChain.getOptionBySuperClassId(BOARD_OPTION_ID);
|
||||
ManagedBuildManager.setOption(newConfig, newToolChain, newOption, board.getId());
|
||||
|
||||
CConfigurationData data = newConfig.getConfigurationData();
|
||||
return projDesc.createConfiguration(ManagedBuildManager.CFG_DATA_PROVIDER_ID, data);
|
||||
}
|
||||
|
||||
public static Board getBoard(IConfiguration configuration) throws CoreException {
|
||||
try {
|
||||
IToolChain toolChain = configuration.getToolChain();
|
||||
IOption boardOption = toolChain.getOptionBySuperClassId(BOARD_OPTION_ID);
|
||||
String boardId = boardOption.getStringValue();
|
||||
|
||||
IArduinoBoardManager boardManager = Activator.getService(IArduinoBoardManager.class);
|
||||
Board board = boardManager.getBoard(boardId);
|
||||
if (board == null) {
|
||||
board = boardManager.getBoard("uno"); //$NON-NLS-1$
|
||||
}
|
||||
return board;
|
||||
} catch (BuildException e) {
|
||||
throw new CoreException(new Status(IStatus.ERROR, Activator.getId(), e.getLocalizedMessage(), e));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public IFile getSourceFile() {
|
||||
return sourceFile;
|
||||
}
|
||||
|
|
|
@ -1,41 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015 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
|
||||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.arduino.core;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
public class Board {
|
||||
|
||||
private final String id;
|
||||
private final Properties properties;
|
||||
|
||||
public Board(String key, Properties properties) {
|
||||
this.id = key;
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getProperty(String localKey) {
|
||||
return properties.getProperty(id + '.' + localKey);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return getProperty("name"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public String getMCU() {
|
||||
return getProperty("build.mcu"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015 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
|
||||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.arduino.core;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* Interface into the board package data.
|
||||
*/
|
||||
public interface IArduinoBoardManager {
|
||||
|
||||
/**
|
||||
* Many of the calls into the board manager require reaching out to the web.
|
||||
* In order to not block UI, these calls are asynchronous. This handler
|
||||
* interface is how the results of the call are returned.
|
||||
*
|
||||
* @param <T>
|
||||
*/
|
||||
public interface Handler<T> {
|
||||
void handle(T result);
|
||||
}
|
||||
|
||||
Board getBoard(String id);
|
||||
|
||||
Collection<Board> getBoards();
|
||||
|
||||
}
|
|
@ -23,6 +23,8 @@ public interface IArduinoRemoteConnection extends IRemoteConnection.Service {
|
|||
final String TYPE_ID = "org.eclipse.cdt.arduino.core.connectionType"; //$NON-NLS-1$
|
||||
final String PORT_NAME = "ardiuno.portname"; //$NON-NLS-1$
|
||||
final String BOARD_ID = "arduino.board"; //$NON-NLS-1$
|
||||
final String PLATFORM_ID = "arduino.platform"; //$NON-NLS-1$
|
||||
final String PACKAGE_ID = "arduino.package"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* Return the serial port name.
|
||||
|
@ -31,13 +33,12 @@ public interface IArduinoRemoteConnection extends IRemoteConnection.Service {
|
|||
*/
|
||||
String getPortName();
|
||||
|
||||
/**
|
||||
* Get the board type at the end of this connection.
|
||||
*
|
||||
* @return Board
|
||||
*/
|
||||
Board getBoard();
|
||||
|
||||
String getBoardId();
|
||||
|
||||
String getPlatformId();
|
||||
|
||||
String getPackageId();
|
||||
|
||||
void pause();
|
||||
|
||||
void resume();
|
||||
|
|
|
@ -0,0 +1,158 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015 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
|
||||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.arduino.core.board;
|
||||
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.eclipse.cdt.arduino.core.internal.Activator;
|
||||
import org.eclipse.cdt.arduino.core.internal.Messages;
|
||||
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
||||
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
|
||||
import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
|
||||
import org.eclipse.cdt.managedbuilder.core.BuildException;
|
||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||
import org.eclipse.cdt.managedbuilder.core.IOption;
|
||||
import org.eclipse.cdt.managedbuilder.core.IToolChain;
|
||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||
import org.eclipse.cdt.managedbuilder.internal.core.ManagedProject;
|
||||
import org.eclipse.cdt.managedbuilder.internal.core.ToolChain;
|
||||
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 com.google.gson.Gson;
|
||||
|
||||
// Closeable isn't API yet but it's recommended.
|
||||
@SuppressWarnings("restriction")
|
||||
public class ArduinoBoardManager {
|
||||
|
||||
public static final ArduinoBoardManager instance = new ArduinoBoardManager();
|
||||
|
||||
// Build tool ids
|
||||
public static final String BOARD_OPTION_ID = "org.eclipse.cdt.arduino.option.board"; //$NON-NLS-1$
|
||||
public static final String PLATFORM_OPTION_ID = "org.eclipse.cdt.arduino.option.platform"; //$NON-NLS-1$
|
||||
public static final String PACKAGE_OPTION_ID = "org.eclipse.cdt.arduino.option.package"; //$NON-NLS-1$
|
||||
public static final String AVR_TOOLCHAIN_ID = "org.eclipse.cdt.arduino.toolChain.avr"; //$NON-NLS-1$
|
||||
|
||||
// TODO make this a preference
|
||||
private Path arduinoHome = Paths.get(System.getProperty("user.home"), ".arduinocdt"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
private Path packageIndexPath;
|
||||
private PackageIndex packageIndex;
|
||||
|
||||
public ArduinoBoardManager() {
|
||||
new Job(Messages.ArduinoBoardManager_0) {
|
||||
protected IStatus run(IProgressMonitor monitor) {
|
||||
try (CloseableHttpClient client = HttpClients.createDefault()) {
|
||||
HttpGet get = new HttpGet("http://downloads.arduino.cc/packages/package_index.json"); //$NON-NLS-1$
|
||||
try (CloseableHttpResponse response = client.execute(get)) {
|
||||
if (response.getStatusLine().getStatusCode() >= 400) {
|
||||
return new Status(IStatus.ERROR, Activator.getId(),
|
||||
response.getStatusLine().getReasonPhrase());
|
||||
} else {
|
||||
HttpEntity entity = response.getEntity();
|
||||
if (entity == null) {
|
||||
return new Status(IStatus.ERROR, Activator.getId(), Messages.ArduinoBoardManager_1);
|
||||
}
|
||||
Files.createDirectories(arduinoHome);
|
||||
packageIndexPath = arduinoHome.resolve("package_index.json"); //$NON-NLS-1$
|
||||
Files.copy(entity.getContent(), packageIndexPath, StandardCopyOption.REPLACE_EXISTING);
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
return new Status(IStatus.ERROR, Activator.getId(), e.getLocalizedMessage(), e);
|
||||
}
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
}.schedule();
|
||||
}
|
||||
|
||||
Path getArduinoHome() {
|
||||
return arduinoHome;
|
||||
}
|
||||
|
||||
public PackageIndex getPackageIndex() throws IOException {
|
||||
if (packageIndex == null) {
|
||||
try (FileReader reader = new FileReader(packageIndexPath.toFile())) {
|
||||
packageIndex = new Gson().fromJson(reader, PackageIndex.class);
|
||||
}
|
||||
}
|
||||
return packageIndex;
|
||||
}
|
||||
|
||||
public ICConfigurationDescription createBuildConfiguration(ICProjectDescription projDesc, String boardId,
|
||||
String platformId, String packageId) throws CoreException {
|
||||
Board board = packageIndex.getPackage(packageId).getPlatform(platformId).getBoard(boardId);
|
||||
ManagedProject managedProject = new ManagedProject(projDesc);
|
||||
// TODO find toolchain based on package (os), platform (arch).
|
||||
String configId = ManagedBuildManager.calculateChildId(ArduinoBoardManager.AVR_TOOLCHAIN_ID, null);
|
||||
IToolChain avrToolChain = ManagedBuildManager.getExtensionToolChain(ArduinoBoardManager.AVR_TOOLCHAIN_ID);
|
||||
|
||||
org.eclipse.cdt.managedbuilder.internal.core.Configuration newConfig = new org.eclipse.cdt.managedbuilder.internal.core.Configuration(
|
||||
managedProject, (ToolChain) avrToolChain, configId, board.getName());
|
||||
|
||||
IToolChain newToolChain = newConfig.getToolChain();
|
||||
IOption boardOption = newToolChain.getOptionBySuperClassId(BOARD_OPTION_ID);
|
||||
ManagedBuildManager.setOption(newConfig, newToolChain, boardOption, boardId);
|
||||
IOption platformOption = newToolChain.getOptionBySuperClassId(PLATFORM_OPTION_ID);
|
||||
ManagedBuildManager.setOption(newConfig, newToolChain, platformOption, platformId);
|
||||
IOption packageOption = newToolChain.getOptionBySuperClassId(PACKAGE_OPTION_ID);
|
||||
ManagedBuildManager.setOption(newConfig, newToolChain, packageOption, packageId);
|
||||
|
||||
CConfigurationData data = newConfig.getConfigurationData();
|
||||
return projDesc.createConfiguration(ManagedBuildManager.CFG_DATA_PROVIDER_ID, data);
|
||||
}
|
||||
|
||||
public Board getBoard(String boardId, String platformId, String packageId) {
|
||||
return packageIndex.getPackage(packageId).getPlatform(platformId).getBoard(boardId);
|
||||
}
|
||||
|
||||
public Board getBoard(IConfiguration configuration) throws CoreException {
|
||||
try {
|
||||
IToolChain toolChain = configuration.getToolChain();
|
||||
IOption boardOption = toolChain.getOptionBySuperClassId(BOARD_OPTION_ID);
|
||||
String boardId = boardOption.getStringValue();
|
||||
IOption platformOption = toolChain.getOptionBySuperClassId(PLATFORM_OPTION_ID);
|
||||
String platformId = platformOption.getStringValue();
|
||||
IOption packageOption = toolChain.getOptionBySuperClassId(PACKAGE_OPTION_ID);
|
||||
String packageId = packageOption.getStringValue();
|
||||
|
||||
return getBoard(boardId, platformId, packageId);
|
||||
} catch (BuildException e) {
|
||||
throw new CoreException(new Status(IStatus.ERROR, Activator.getId(), e.getLocalizedMessage(), e));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public List<Board> getBoards() {
|
||||
List<Board> boards = new ArrayList<>();
|
||||
for (Package pkg : packageIndex.getPackages()) {
|
||||
for (Platform platform : pkg.getPlatforms()) {
|
||||
boards.addAll(platform.getBoards());
|
||||
}
|
||||
}
|
||||
return boards;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
package org.eclipse.cdt.arduino.core.board;
|
||||
|
||||
public class Board {
|
||||
|
||||
private String name;
|
||||
|
||||
private transient String id;
|
||||
private transient Platform platform;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public Board setName(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public Board setId(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Platform getPlatform() {
|
||||
return platform;
|
||||
}
|
||||
|
||||
Board setOwners(Platform platform) {
|
||||
this.platform = platform;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getBuildSetting(String setting) {
|
||||
String key = id + ".build." + setting; //$NON-NLS-1$
|
||||
return platform.getBoardsFile().getProperty(key);
|
||||
}
|
||||
|
||||
public String getPlatformId() {
|
||||
return platform.getArchitecture();
|
||||
}
|
||||
|
||||
public String getPackageId() {
|
||||
return platform.getPackage().getName();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package org.eclipse.cdt.arduino.core.board;
|
||||
|
||||
public class Help {
|
||||
|
||||
private String online;
|
||||
|
||||
public String getOnline() {
|
||||
return online;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
package org.eclipse.cdt.arduino.core.board;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
|
||||
public class Package {
|
||||
|
||||
private String name;
|
||||
private String maintainer;
|
||||
private String websiteURL;
|
||||
private String email;
|
||||
private Help help;
|
||||
private List<Platform> platforms;
|
||||
private List<Tool> tools;
|
||||
|
||||
private transient ArduinoBoardManager manager;
|
||||
|
||||
void setOwners(ArduinoBoardManager manager) {
|
||||
this.manager = manager;
|
||||
for (Platform platform : platforms) {
|
||||
platform.setOwners(this);
|
||||
}
|
||||
}
|
||||
|
||||
ArduinoBoardManager getManager() {
|
||||
return manager;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getMaintainer() {
|
||||
return maintainer;
|
||||
}
|
||||
|
||||
public String getWebsiteURL() {
|
||||
return websiteURL;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public Help getHelp() {
|
||||
return help;
|
||||
}
|
||||
|
||||
public List<Platform> getPlatforms() {
|
||||
return platforms;
|
||||
}
|
||||
|
||||
public Platform getPlatform(String architecture) {
|
||||
for (Platform platform : platforms) {
|
||||
if (platform.getArchitecture().equals(architecture)) {
|
||||
return platform;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<Tool> getTools() {
|
||||
return tools;
|
||||
}
|
||||
|
||||
public void install(IProgressMonitor monitor) {
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -5,8 +5,25 @@
|
|||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.arduino.core.internal.board;
|
||||
package org.eclipse.cdt.arduino.core.board;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PackageIndex {
|
||||
|
||||
private List<Package> packages;
|
||||
|
||||
public List<Package> getPackages() {
|
||||
return packages;
|
||||
}
|
||||
|
||||
public Package getPackage(String packageName) {
|
||||
for (Package pkg : packages) {
|
||||
if (pkg.getName().equals(packageName)) {
|
||||
return pkg;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,111 @@
|
|||
package org.eclipse.cdt.arduino.core.board;
|
||||
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
public class Platform {
|
||||
|
||||
private String name;
|
||||
private String architecture;
|
||||
private String version;
|
||||
private String category;
|
||||
private String url;
|
||||
private String archiveName;
|
||||
private String checksum;
|
||||
private String size;
|
||||
private List<Board> boards;
|
||||
private List<ToolDependency> toolsDependencies;
|
||||
|
||||
private transient Package pkg;
|
||||
private transient Properties boardsFile;
|
||||
|
||||
void setOwners(Package pkg) {
|
||||
this.pkg = pkg;
|
||||
for (Board board : boards) {
|
||||
board.setOwners(this);
|
||||
}
|
||||
}
|
||||
|
||||
public Package getPackage() {
|
||||
return pkg;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getArchitecture() {
|
||||
return architecture;
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public String getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public String getArchiveName() {
|
||||
return archiveName;
|
||||
}
|
||||
|
||||
public String getChecksum() {
|
||||
return checksum;
|
||||
}
|
||||
|
||||
public String getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public List<Board> getBoards() {
|
||||
return boards;
|
||||
}
|
||||
|
||||
public Board getBoard(String boardId) {
|
||||
for (Board board : boards) {
|
||||
if (boardId.equals(board.getId())) {
|
||||
return board;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<ToolDependency> getToolsDependencies() {
|
||||
return toolsDependencies;
|
||||
}
|
||||
|
||||
void install() throws IOException {
|
||||
Path boardPath = pkg.getManager().getArduinoHome().resolve("hardware").resolve(pkg.getName()) //$NON-NLS-1$
|
||||
.resolve(architecture).resolve(version);
|
||||
boardsFile = new Properties();
|
||||
try (Reader reader = new FileReader(boardPath.toFile())) {
|
||||
boardsFile.load(reader);
|
||||
}
|
||||
|
||||
// Replace the boards with a real ones
|
||||
boards = new ArrayList<>();
|
||||
for (Map.Entry<Object, Object> entry : boardsFile.entrySet()) {
|
||||
String key = (String) entry.getKey();
|
||||
String[] fragments = key.split("."); //$NON-NLS-1$
|
||||
if (fragments.length == 2 && "name".equals(fragments[1])) { //$NON-NLS-1$
|
||||
boards.add(new Board().setId(fragments[0]).setName((String) entry.getValue()).setOwners(this));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Properties getBoardsFile() {
|
||||
return boardsFile;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package org.eclipse.cdt.arduino.core.board;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Tool {
|
||||
|
||||
private String name;
|
||||
private String version;
|
||||
private List<ToolSystem> systems;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public List<ToolSystem> getSystems() {
|
||||
return systems;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package org.eclipse.cdt.arduino.core.board;
|
||||
|
||||
public class ToolDependency {
|
||||
|
||||
private String packager;
|
||||
private String name;
|
||||
private String version;
|
||||
|
||||
public String getPackager() {
|
||||
return packager;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package org.eclipse.cdt.arduino.core.board;
|
||||
|
||||
public class ToolSystem {
|
||||
|
||||
private String host;
|
||||
private String archiveFileName;
|
||||
private String url;
|
||||
private String checksum;
|
||||
private String size;
|
||||
|
||||
public String getHost() {
|
||||
return host;
|
||||
}
|
||||
|
||||
public String getArchiveFileName() {
|
||||
return archiveFileName;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public String getChecksum() {
|
||||
return checksum;
|
||||
}
|
||||
|
||||
public String getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
}
|
|
@ -10,8 +10,6 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.arduino.core.internal;
|
||||
|
||||
import org.eclipse.cdt.arduino.core.IArduinoBoardManager;
|
||||
import org.eclipse.cdt.arduino.core.internal.board.ArduinoBoardManager;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Plugin;
|
||||
|
@ -45,7 +43,6 @@ public class Activator extends Plugin {
|
|||
|
||||
public void start(BundleContext bundleContext) throws Exception {
|
||||
plugin = this;
|
||||
bundleContext.registerService(IArduinoBoardManager.class, new ArduinoBoardManager(), null);
|
||||
}
|
||||
|
||||
public void stop(BundleContext bundleContext) throws Exception {
|
||||
|
|
|
@ -14,8 +14,8 @@ import java.io.File;
|
|||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.arduino.core.ArduinoHome;
|
||||
import org.eclipse.cdt.arduino.core.ArduinoProjectGenerator;
|
||||
import org.eclipse.cdt.arduino.core.Board;
|
||||
import org.eclipse.cdt.arduino.core.board.ArduinoBoardManager;
|
||||
import org.eclipse.cdt.arduino.core.board.Board;
|
||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||
import org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector;
|
||||
|
@ -35,8 +35,8 @@ public class AvrLanguageSettingsProvider extends GCCBuiltinSpecsDetector {
|
|||
|
||||
try {
|
||||
IConfiguration config = ManagedBuildManager.getConfigurationForDescription(currentCfgDescription);
|
||||
Board board = ArduinoProjectGenerator.getBoard(config);
|
||||
String mcu = board.getMCU();
|
||||
Board board = ArduinoBoardManager.instance.getBoard(config);
|
||||
String mcu = board.getBuildSetting("mcu"); //$NON-NLS-1$
|
||||
if (mcu != null) {
|
||||
opts += " -mmcu=" + mcu; //$NON-NLS-1$
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ public class AvrLanguageSettingsProvider extends GCCBuiltinSpecsDetector {
|
|||
|
||||
return opts;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected List<String> parseOptions(String line) {
|
||||
if (Platform.getOS().equals(Platform.OS_WIN32)) {
|
||||
|
@ -58,7 +58,7 @@ public class AvrLanguageSettingsProvider extends GCCBuiltinSpecsDetector {
|
|||
|
||||
return super.parseOptions(line);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public AvrLanguageSettingsProvider cloneShallow() throws CloneNotSupportedException {
|
||||
return (AvrLanguageSettingsProvider) super.cloneShallow();
|
||||
|
|
|
@ -15,13 +15,10 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.arduino.core.ArduinoHome;
|
||||
import org.eclipse.cdt.arduino.core.ArduinoProjectGenerator;
|
||||
import org.eclipse.cdt.arduino.core.Board;
|
||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||
import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable;
|
||||
import org.eclipse.cdt.managedbuilder.envvar.IConfigurationEnvironmentVariableSupplier;
|
||||
import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
|
||||
public class EnvVarSupplier implements IConfigurationEnvironmentVariableSupplier {
|
||||
|
@ -31,7 +28,6 @@ public class EnvVarSupplier implements IConfigurationEnvironmentVariableSupplier
|
|||
private EnvVar path;
|
||||
|
||||
private static final String OUTPUT_DIR = "OUTPUT_DIR"; //$NON-NLS-1$
|
||||
private static final String BOARD = "BOARD"; //$NON-NLS-1$
|
||||
|
||||
private static final class EnvVar implements IBuildEnvironmentVariable {
|
||||
String name;
|
||||
|
@ -89,22 +85,6 @@ public class EnvVarSupplier implements IConfigurationEnvironmentVariableSupplier
|
|||
return outputDir;
|
||||
}
|
||||
|
||||
private IBuildEnvironmentVariable getBoard(IConfiguration configuration) {
|
||||
try {
|
||||
Board board = ArduinoProjectGenerator.getBoard(configuration);
|
||||
if (board == null)
|
||||
return null;
|
||||
|
||||
EnvVar boardVar = new EnvVar();
|
||||
boardVar.name = BOARD;
|
||||
boardVar.value = board.getId();
|
||||
return boardVar;
|
||||
} catch (CoreException e) {
|
||||
Activator.getPlugin().getLog().log(e.getStatus());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBuildEnvironmentVariable getVariable(String variableName, IConfiguration configuration,
|
||||
IEnvironmentVariableProvider provider) {
|
||||
|
@ -116,8 +96,6 @@ public class EnvVarSupplier implements IConfigurationEnvironmentVariableSupplier
|
|||
return arduinoLibs;
|
||||
} else if (variableName.equals(OUTPUT_DIR)) {
|
||||
return getOutputDir(configuration);
|
||||
} else if (variableName.equals(BOARD)) {
|
||||
return getBoard(configuration);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -133,10 +111,6 @@ public class EnvVarSupplier implements IConfigurationEnvironmentVariableSupplier
|
|||
|
||||
if (configuration != null) {
|
||||
vars.add(getOutputDir(configuration));
|
||||
|
||||
IBuildEnvironmentVariable boardVar = getBoard(configuration);
|
||||
if (boardVar != null)
|
||||
vars.add(boardVar);
|
||||
}
|
||||
|
||||
return vars.toArray(new IBuildEnvironmentVariable[vars.size()]);
|
||||
|
|
|
@ -14,6 +14,8 @@ import org.eclipse.osgi.util.NLS;
|
|||
|
||||
public class Messages extends NLS {
|
||||
private static final String BUNDLE_NAME = "org.eclipse.cdt.arduino.core.internal.messages"; //$NON-NLS-1$
|
||||
public static String ArduinoBoardManager_0;
|
||||
public static String ArduinoBoardManager_1;
|
||||
public static String ArduinoLaunchConfigurationDelegate_0;
|
||||
public static String ArduinoLaunchConfigurationDelegate_1;
|
||||
public static String ArduinoLaunchConfigurationDelegate_2;
|
||||
|
|
|
@ -1,139 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015 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
|
||||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.arduino.core.internal.board;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.eclipse.cdt.arduino.core.ArduinoHome;
|
||||
import org.eclipse.cdt.arduino.core.Board;
|
||||
import org.eclipse.cdt.arduino.core.IArduinoBoardManager;
|
||||
import org.eclipse.cdt.arduino.core.internal.Activator;
|
||||
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 com.google.gson.Gson;
|
||||
|
||||
public class ArduinoBoardManager implements IArduinoBoardManager {
|
||||
|
||||
private Map<String, Board> boards;
|
||||
|
||||
// TODO make this a preference
|
||||
private Path arduinoHome = Paths.get(System.getProperty("user.home"), ".arduinocdt"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
public void getPackageIndex(final Handler<PackageIndex> handler) {
|
||||
new Job("Fetching package index") {
|
||||
// Closeable isn't API yet but it's recommended.
|
||||
@SuppressWarnings("restriction")
|
||||
protected IStatus run(IProgressMonitor monitor) {
|
||||
try (CloseableHttpClient client = HttpClients.createDefault()) {
|
||||
HttpGet get = new HttpGet("http://downloads.arduino.cc/packages/package_index.json"); //$NON-NLS-1$
|
||||
try (CloseableHttpResponse response = client.execute(get)) {
|
||||
if (response.getStatusLine().getStatusCode() >= 400) {
|
||||
return new Status(IStatus.ERROR, Activator.getId(),
|
||||
response.getStatusLine().getReasonPhrase());
|
||||
} else {
|
||||
HttpEntity entity = response.getEntity();
|
||||
if (entity == null) {
|
||||
return new Status(IStatus.ERROR, Activator.getId(),
|
||||
"Package index missing from response");
|
||||
}
|
||||
Files.createDirectories(arduinoHome);
|
||||
Path indexPath = arduinoHome.resolve("package_index.json"); //$NON-NLS-1$
|
||||
Files.copy(entity.getContent(), indexPath, StandardCopyOption.REPLACE_EXISTING);
|
||||
try (FileReader reader = new FileReader(indexPath.toFile())) {
|
||||
PackageIndex index = new Gson().fromJson(reader, PackageIndex.class);
|
||||
handler.handle(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
return new Status(IStatus.ERROR, Activator.getId(), e.getLocalizedMessage(), e);
|
||||
}
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
}.schedule();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Board getBoard(String id) {
|
||||
init();
|
||||
return boards.get(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Board> getBoards() {
|
||||
init();
|
||||
List<Board> sortedBoards = new ArrayList<Board>(boards.values());
|
||||
Collections.sort(sortedBoards, new Comparator<Board>() {
|
||||
@Override
|
||||
public int compare(Board arg0, Board arg1) {
|
||||
return arg0.getName().compareTo(arg1.getName());
|
||||
}
|
||||
});
|
||||
return sortedBoards;
|
||||
}
|
||||
|
||||
private void init() {
|
||||
if (boards != null)
|
||||
return;
|
||||
boards = new HashMap<>();
|
||||
File home = ArduinoHome.getArduinoHome();
|
||||
if (!home.isDirectory())
|
||||
return;
|
||||
|
||||
File archRoot = new File(home, "hardware/arduino"); //$NON-NLS-1$
|
||||
for (File archDir : archRoot.listFiles()) {
|
||||
File boardFile = new File(archDir, "boards.txt"); //$NON-NLS-1$
|
||||
loadBoardFile(archDir.getName(), boardFile);
|
||||
}
|
||||
}
|
||||
|
||||
private void loadBoardFile(String arch, File boardFile) {
|
||||
try {
|
||||
Properties boardProps = new Properties();
|
||||
boardProps.load(new FileInputStream(boardFile));
|
||||
Enumeration<?> i = boardProps.propertyNames();
|
||||
while (i.hasMoreElements()) {
|
||||
String propertyName = (String) i.nextElement();
|
||||
String[] names = propertyName.split("\\."); //$NON-NLS-1$
|
||||
if (names.length == 2 && names[1].equals("name")) { //$NON-NLS-1$
|
||||
boards.put(names[0], new Board(names[0], boardProps));
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -16,8 +16,9 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.arduino.core.ArduinoLaunchConsoleService;
|
||||
import org.eclipse.cdt.arduino.core.ArduinoProjectGenerator;
|
||||
import org.eclipse.cdt.arduino.core.IArduinoRemoteConnection;
|
||||
import org.eclipse.cdt.arduino.core.board.ArduinoBoardManager;
|
||||
import org.eclipse.cdt.arduino.core.board.Board;
|
||||
import org.eclipse.cdt.arduino.core.internal.Activator;
|
||||
import org.eclipse.cdt.arduino.core.internal.Messages;
|
||||
import org.eclipse.cdt.arduino.core.internal.remote.ArduinoRemoteConnection;
|
||||
|
@ -68,7 +69,8 @@ public class ArduinoLaunchConfigurationDelegate extends LaunchConfigurationDeleg
|
|||
boolean newConfig = false;
|
||||
if (configDesc == null) {
|
||||
IArduinoRemoteConnection arduinoRemote = target.getService(IArduinoRemoteConnection.class);
|
||||
configDesc = ArduinoProjectGenerator.createBuildConfiguration(projDesc, arduinoRemote.getBoard());
|
||||
configDesc = ArduinoBoardManager.instance.createBuildConfiguration(projDesc, arduinoRemote.getBoardId(),
|
||||
arduinoRemote.getPlatformId(), arduinoRemote.getPackageId());
|
||||
newConfig = true;
|
||||
}
|
||||
if (newConfig || !projDesc.getActiveConfiguration().equals(configDesc)) {
|
||||
|
@ -172,17 +174,27 @@ public class ArduinoLaunchConfigurationDelegate extends LaunchConfigurationDeleg
|
|||
private ICConfigurationDescription getBuildConfiguration(ICProjectDescription projDesc, IRemoteConnection target)
|
||||
throws CoreException {
|
||||
String boardId;
|
||||
String platformId;
|
||||
String packageId;
|
||||
if (target != null) {
|
||||
IArduinoRemoteConnection arduinoRemote = target.getService(IArduinoRemoteConnection.class);
|
||||
boardId = arduinoRemote.getBoard().getId();
|
||||
boardId = arduinoRemote.getBoardId();
|
||||
platformId = arduinoRemote.getPlatformId();
|
||||
packageId = arduinoRemote.getPackageId();
|
||||
} else {
|
||||
// TODO preference for this
|
||||
boardId = "uno"; //$NON-NLS-1$
|
||||
platformId = "avr"; //$NON-NLS-1$
|
||||
packageId = "arduino"; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
for (ICConfigurationDescription configDesc : projDesc.getConfigurations()) {
|
||||
IConfiguration config = ManagedBuildManager.getConfigurationForDescription(configDesc);
|
||||
if (ArduinoProjectGenerator.getBoard(config).getId().equals(boardId))
|
||||
Board board = ArduinoBoardManager.instance.getBoard(config);
|
||||
if (boardId.equals(board.getId()) && platformId.equals(board.getPlatform().getArchitecture())
|
||||
&& packageId.equals(board.getPlatform().getPackage().getName())) {
|
||||
return configDesc;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
ArduinoBoardManager_0=Fetching package index
|
||||
ArduinoBoardManager_1=Package index missing from response
|
||||
ArduinoLaunchConfigurationDelegate_1=No active Arduino remote connection.
|
||||
################################################################################
|
||||
# Copyright (c) 2015 QNX Software Systems and others.
|
||||
|
|
|
@ -14,8 +14,6 @@ import java.io.IOException;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.cdt.arduino.core.Board;
|
||||
import org.eclipse.cdt.arduino.core.IArduinoBoardManager;
|
||||
import org.eclipse.cdt.arduino.core.IArduinoRemoteConnection;
|
||||
import org.eclipse.cdt.arduino.core.internal.Activator;
|
||||
import org.eclipse.cdt.serial.SerialPort;
|
||||
|
@ -30,7 +28,6 @@ import org.eclipse.remote.serial.core.SerialPortCommandShell;
|
|||
public class ArduinoRemoteConnection implements IRemoteConnectionPropertyService, IRemoteCommandShellService,
|
||||
IArduinoRemoteConnection, IRemoteConnectionChangeListener {
|
||||
|
||||
private final IArduinoBoardManager boardManager = Activator.getService(IArduinoBoardManager.class);
|
||||
private final IRemoteConnection remoteConnection;
|
||||
private SerialPort serialPort;
|
||||
private SerialPortCommandShell commandShell;
|
||||
|
@ -90,12 +87,18 @@ public class ArduinoRemoteConnection implements IRemoteConnectionPropertyService
|
|||
}
|
||||
|
||||
@Override
|
||||
public Board getBoard() {
|
||||
String boardId = remoteConnection.getAttribute(BOARD_ID);
|
||||
if (boardId == null) {
|
||||
boardId = "uno"; //$NON-NLS-1$
|
||||
}
|
||||
return boardManager.getBoard(boardId);
|
||||
public String getBoardId() {
|
||||
return remoteConnection.getAttribute(BOARD_ID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlatformId() {
|
||||
return remoteConnection.getAttribute(PLATFORM_ID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPackageId() {
|
||||
return remoteConnection.getAttribute(PACKAGE_ID);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,9 +3,9 @@ package org.eclipse.cdt.arduino.ui.internal.remote;
|
|||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.eclipse.cdt.arduino.core.Board;
|
||||
import org.eclipse.cdt.arduino.core.IArduinoBoardManager;
|
||||
import org.eclipse.cdt.arduino.core.IArduinoRemoteConnection;
|
||||
import org.eclipse.cdt.arduino.core.board.ArduinoBoardManager;
|
||||
import org.eclipse.cdt.arduino.core.board.Board;
|
||||
import org.eclipse.cdt.arduino.ui.internal.Activator;
|
||||
import org.eclipse.cdt.arduino.ui.internal.Messages;
|
||||
import org.eclipse.cdt.serial.SerialPort;
|
||||
|
@ -26,7 +26,7 @@ public class ArduinoTargetPropertyPage extends PropertyPage implements IWorkbenc
|
|||
|
||||
private Combo portSelector;
|
||||
private Combo boardSelector;
|
||||
|
||||
|
||||
private Board[] boards;
|
||||
|
||||
@Override
|
||||
|
@ -71,9 +71,9 @@ public class ArduinoTargetPropertyPage extends PropertyPage implements IWorkbenc
|
|||
boardSelector = new Combo(comp, SWT.READ_ONLY);
|
||||
boardSelector.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||
|
||||
Board currentBoard = arduinoRemote.getBoard();
|
||||
IArduinoBoardManager boardManager = Activator.getService(IArduinoBoardManager.class);
|
||||
Collection<Board> boardList = boardManager.getBoards();
|
||||
Board currentBoard = ArduinoBoardManager.instance.getBoard(arduinoRemote.getBoardId(),
|
||||
arduinoRemote.getPlatformId(), arduinoRemote.getPackageId());
|
||||
Collection<Board> boardList = ArduinoBoardManager.instance.getBoards();
|
||||
boards = new Board[boardList.size()];
|
||||
i = 0;
|
||||
int boardSel = 0;
|
||||
|
@ -108,5 +108,5 @@ public class ArduinoTargetPropertyPage extends PropertyPage implements IWorkbenc
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -2,8 +2,8 @@ package org.eclipse.cdt.arduino.ui.internal.remote;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.eclipse.cdt.arduino.core.Board;
|
||||
import org.eclipse.cdt.arduino.core.IArduinoBoardManager;
|
||||
import org.eclipse.cdt.arduino.core.board.ArduinoBoardManager;
|
||||
import org.eclipse.cdt.arduino.core.board.Board;
|
||||
import org.eclipse.cdt.arduino.ui.internal.Activator;
|
||||
import org.eclipse.cdt.arduino.ui.internal.Messages;
|
||||
import org.eclipse.cdt.serial.SerialPort;
|
||||
|
@ -83,14 +83,12 @@ public class NewArduinoTargetWizardPage extends WizardPage {
|
|||
}
|
||||
});
|
||||
|
||||
IArduinoBoardManager boardManager = Activator.getService(IArduinoBoardManager.class);
|
||||
|
||||
Label boardLabel = new Label(comp, SWT.NONE);
|
||||
boardLabel.setText(Messages.NewArduinoTargetWizardPage_5);
|
||||
|
||||
boardCombo = new Combo(comp, SWT.READ_ONLY);
|
||||
boardCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||
boards = boardManager.getBoards().toArray(new Board[0]);
|
||||
boards = ArduinoBoardManager.instance.getBoards().toArray(new Board[0]);
|
||||
for (Board board : boards) {
|
||||
boardCombo.add(board.getName());
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue