mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-25 18:05:33 +02:00
Some cleanup for Arduino CDT.
Change-Id: Ib2384053c1bf40d65c9e6e72c3146a3264abbf33
This commit is contained in:
parent
8d2489c8ac
commit
7571170de6
7 changed files with 49 additions and 36 deletions
|
@ -84,9 +84,9 @@ public class ArduinoProjectGenerator {
|
|||
info.setManagedProject(mProj);
|
||||
|
||||
// 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$
|
||||
String boardName = "Arduino Uno"; //$NON-NLS-1$
|
||||
String platformName = "Arduino AVR Boards"; //$NON-NLS-1$
|
||||
String packageName = "arduino"; //$NON-NLS-1$
|
||||
|
||||
IRemoteServicesManager remoteManager = Activator.getService(IRemoteServicesManager.class);
|
||||
IRemoteConnectionType connectionType = remoteManager.getConnectionType(ArduinoRemoteConnection.TYPE_ID);
|
||||
|
@ -94,12 +94,12 @@ public class ArduinoProjectGenerator {
|
|||
if (!connections.isEmpty()) {
|
||||
IRemoteConnection firstConnection = connections.iterator().next();
|
||||
IArduinoRemoteConnection firstArduino = firstConnection.getService(IArduinoRemoteConnection.class);
|
||||
boardId = firstArduino.getBoardId();
|
||||
platformId = firstArduino.getPlatformId();
|
||||
packageId = firstArduino.getPackageId();
|
||||
boardName = firstArduino.getBoardName();
|
||||
platformName = firstArduino.getPlatformName();
|
||||
packageName = firstArduino.getPackageName();
|
||||
}
|
||||
|
||||
ArduinoBoardManager.instance.createBuildConfiguration(cprojDesc, boardId, platformId, packageId);
|
||||
ArduinoBoardManager.instance.createBuildConfiguration(cprojDesc, boardName, platformName, packageName);
|
||||
CCorePlugin.getDefault().setProjectDescription(project, cprojDesc, true, monitor);
|
||||
|
||||
// Generate files
|
||||
|
|
|
@ -33,11 +33,11 @@ public interface IArduinoRemoteConnection extends IRemoteConnection.Service {
|
|||
*/
|
||||
String getPortName();
|
||||
|
||||
String getBoardId();
|
||||
String getBoardName();
|
||||
|
||||
String getPlatformId();
|
||||
String getPlatformName();
|
||||
|
||||
String getPackageId();
|
||||
String getPackageName();
|
||||
|
||||
void pause();
|
||||
|
||||
|
|
|
@ -118,25 +118,24 @@ public class ArduinoBoardManager {
|
|||
return projDesc.createConfiguration(ManagedBuildManager.CFG_DATA_PROVIDER_ID, data);
|
||||
}
|
||||
|
||||
public Board getBoard(String boardId, String platformId, String packageId) throws CoreException {
|
||||
return packageIndex.getPackage(packageId).getPlatform(platformId).getBoard(boardId);
|
||||
public Board getBoard(String boardName, String platformName, String packageName) throws CoreException {
|
||||
return packageIndex.getPackage(packageName).getPlatform(platformName).getBoard(boardName);
|
||||
}
|
||||
|
||||
public Board getBoard(IConfiguration configuration) throws CoreException {
|
||||
try {
|
||||
IToolChain toolChain = configuration.getToolChain();
|
||||
IOption boardOption = toolChain.getOptionBySuperClassId(BOARD_OPTION_ID);
|
||||
String boardId = boardOption.getStringValue();
|
||||
String boardName = boardOption.getStringValue();
|
||||
IOption platformOption = toolChain.getOptionBySuperClassId(PLATFORM_OPTION_ID);
|
||||
String platformId = platformOption.getStringValue();
|
||||
String platformName = platformOption.getStringValue();
|
||||
IOption packageOption = toolChain.getOptionBySuperClassId(PACKAGE_OPTION_ID);
|
||||
String packageId = packageOption.getStringValue();
|
||||
String packageName = packageOption.getStringValue();
|
||||
|
||||
return getBoard(boardId, platformId, packageId);
|
||||
return getBoard(boardName, platformName, packageName);
|
||||
} catch (BuildException e) {
|
||||
throw new CoreException(new Status(IStatus.ERROR, Activator.getId(), e.getLocalizedMessage(), e));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public List<Board> getBoards() throws CoreException {
|
||||
|
@ -149,4 +148,9 @@ public class ArduinoBoardManager {
|
|||
return boards;
|
||||
}
|
||||
|
||||
public Tool getTool(String packageName, String toolName, String version) {
|
||||
BoardPackage pkg = packageIndex.getPackage(packageName);
|
||||
return pkg != null ? pkg.getTool(toolName, version) : null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -137,6 +137,15 @@ public class BoardPackage {
|
|||
return tools;
|
||||
}
|
||||
|
||||
public Tool getTool(String toolName, String version) {
|
||||
for (Tool tool : tools) {
|
||||
if (tool.getName().equals(toolName) && tool.getName().equals(version)) {
|
||||
return tool;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void install(IProgressMonitor monitor) {
|
||||
|
||||
}
|
||||
|
|
|
@ -69,8 +69,8 @@ public class ArduinoLaunchConfigurationDelegate extends LaunchConfigurationDeleg
|
|||
boolean newConfig = false;
|
||||
if (configDesc == null) {
|
||||
IArduinoRemoteConnection arduinoRemote = target.getService(IArduinoRemoteConnection.class);
|
||||
configDesc = ArduinoBoardManager.instance.createBuildConfiguration(projDesc, arduinoRemote.getBoardId(),
|
||||
arduinoRemote.getPlatformId(), arduinoRemote.getPackageId());
|
||||
configDesc = ArduinoBoardManager.instance.createBuildConfiguration(projDesc, arduinoRemote.getBoardName(),
|
||||
arduinoRemote.getPlatformName(), arduinoRemote.getPackageName());
|
||||
newConfig = true;
|
||||
}
|
||||
if (newConfig || !projDesc.getActiveConfiguration().equals(configDesc)) {
|
||||
|
@ -173,26 +173,26 @@ public class ArduinoLaunchConfigurationDelegate extends LaunchConfigurationDeleg
|
|||
*/
|
||||
private ICConfigurationDescription getBuildConfiguration(ICProjectDescription projDesc, IRemoteConnection target)
|
||||
throws CoreException {
|
||||
String boardId;
|
||||
String platformId;
|
||||
String packageId;
|
||||
String boardName;
|
||||
String platformName;
|
||||
String packageName;
|
||||
if (target != null) {
|
||||
IArduinoRemoteConnection arduinoRemote = target.getService(IArduinoRemoteConnection.class);
|
||||
boardId = arduinoRemote.getBoardId();
|
||||
platformId = arduinoRemote.getPlatformId();
|
||||
packageId = arduinoRemote.getPackageId();
|
||||
boardName = arduinoRemote.getBoardName();
|
||||
platformName = arduinoRemote.getPlatformName();
|
||||
packageName = arduinoRemote.getPackageName();
|
||||
} else {
|
||||
// TODO preference for this
|
||||
boardId = "uno"; //$NON-NLS-1$
|
||||
platformId = "avr"; //$NON-NLS-1$
|
||||
packageId = "arduino"; //$NON-NLS-1$
|
||||
// TODO
|
||||
boardName = "Arduino Uno"; //$NON-NLS-1$
|
||||
platformName = "Arduino AVR Boards"; //$NON-NLS-1$
|
||||
packageName = "arduino"; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
for (ICConfigurationDescription configDesc : projDesc.getConfigurations()) {
|
||||
IConfiguration config = ManagedBuildManager.getConfigurationForDescription(configDesc);
|
||||
Board board = ArduinoBoardManager.instance.getBoard(config);
|
||||
if (boardId.equals(board.getId()) && platformId.equals(board.getPlatform().getArchitecture())
|
||||
&& packageId.equals(board.getPlatform().getPackage().getName())) {
|
||||
if (boardName.equals(board.getId()) && platformName.equals(board.getPlatform().getArchitecture())
|
||||
&& packageName.equals(board.getPlatform().getPackage().getName())) {
|
||||
return configDesc;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -87,17 +87,17 @@ public class ArduinoRemoteConnection implements IRemoteConnectionPropertyService
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getBoardId() {
|
||||
public String getBoardName() {
|
||||
return remoteConnection.getAttribute(BOARD_ID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlatformId() {
|
||||
public String getPlatformName() {
|
||||
return remoteConnection.getAttribute(PLATFORM_ID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPackageId() {
|
||||
public String getPackageName() {
|
||||
return remoteConnection.getAttribute(PACKAGE_ID);
|
||||
}
|
||||
|
||||
|
|
|
@ -73,8 +73,8 @@ public class ArduinoTargetPropertyPage extends PropertyPage implements IWorkbenc
|
|||
boardSelector.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||
|
||||
try {
|
||||
Board currentBoard = ArduinoBoardManager.instance.getBoard(arduinoRemote.getBoardId(),
|
||||
arduinoRemote.getPlatformId(), arduinoRemote.getPackageId());
|
||||
Board currentBoard = ArduinoBoardManager.instance.getBoard(arduinoRemote.getBoardName(),
|
||||
arduinoRemote.getPlatformName(), arduinoRemote.getPackageName());
|
||||
Collection<Board> boardList = ArduinoBoardManager.instance.getBoards();
|
||||
boards = new Board[boardList.size()];
|
||||
i = 0;
|
||||
|
|
Loading…
Add table
Reference in a new issue