1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-21 07:05:58 +02:00

Bug 486724 - Fixes for SparkFun Arduino boards.

The SparkFun package json file is a bit different. Need to merge
packages.

Also fix a couple of NPEs.

Change-Id: Ida495af0b497ba3cd6dbd3e95045c8923f8e9bc8
This commit is contained in:
Doug Schaefer 2016-06-25 19:52:41 -05:00
parent ee7f9a49da
commit 857afa3a80
7 changed files with 85 additions and 30 deletions

View file

@ -33,7 +33,6 @@ import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job; import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.remote.core.IRemoteConnection; import org.eclipse.remote.core.IRemoteConnection;
@ -66,9 +65,11 @@ public class FullIntegration {
URL[] urls = new URL[] { URL[] urls = new URL[] {
new URL("http://downloads.arduino.cc/packages/package_index.json"), new URL("http://downloads.arduino.cc/packages/package_index.json"),
new URL("https://adafruit.github.io/arduino-board-index/package_adafruit_index.json"), new URL("https://adafruit.github.io/arduino-board-index/package_adafruit_index.json"),
new URL("http://arduino.esp8266.com/stable/package_esp8266com_index.json"),
new URL("http://drazzy.com/package_drazzy.com_index.json"), new URL("http://drazzy.com/package_drazzy.com_index.json"),
new URL("https://github.com/chipKIT32/chipKIT-core/raw/master/package_chipkit_index.json"), new URL("https://github.com/chipKIT32/chipKIT-core/raw/master/package_chipkit_index.json"),
// esp8266com and sparkfun overlap with the esp8266 package.
new URL("http://arduino.esp8266.com/stable/package_esp8266com_index.json"),
//new URL("https://raw.githubusercontent.com/sparkfun/Arduino_Boards/master/IDE_Board_Manager/package_sparkfun_index.json"),
}; };
ArduinoPreferences.setBoardUrlList(urls); ArduinoPreferences.setBoardUrlList(urls);

View file

@ -304,8 +304,13 @@ public class ArduinoManager {
try (Reader reader = new FileReader(path.toFile())) { try (Reader reader = new FileReader(path.toFile())) {
PackageIndex index = new Gson().fromJson(reader, PackageIndex.class); PackageIndex index = new Gson().fromJson(reader, PackageIndex.class);
for (ArduinoPackage pkg : index.getPackages()) { for (ArduinoPackage pkg : index.getPackages()) {
ArduinoPackage p = packages.get(pkg.getName());
if (p == null) {
pkg.init(); pkg.init();
packages.put(pkg.getName(), pkg); packages.put(pkg.getName(), pkg);
} else {
p.merge(pkg);
}
} }
} catch (IOException e) { } catch (IOException e) {
Activator.log(e); Activator.log(e);

View file

@ -31,6 +31,7 @@ public class ArduinoPackage {
// end JSON fields // end JSON fields
private Map<String, ArduinoPlatform> installedPlatforms; private Map<String, ArduinoPlatform> installedPlatforms;
private Map<String, ArduinoTool> latestTools;
public String getName() { public String getName() {
return name; return name;
@ -65,6 +66,34 @@ public class ArduinoPackage {
} }
} }
void merge(ArduinoPackage other) {
// Redo calculated fields
installedPlatforms = null;
latestTools = null;
if (other.platforms != null) {
if (platforms != null) {
platforms.addAll(other.platforms);
} else {
platforms = other.platforms;
}
for (ArduinoPlatform platform : other.platforms) {
platform.init(this);
}
}
if (other.tools != null) {
if (tools != null) {
tools.addAll(other.tools);
} else {
tools = other.tools;
}
for (ArduinoTool tool : other.tools) {
tool.init(this);
}
}
}
public ArduinoPlatform getPlatform(String architecture, String version) { public ArduinoPlatform getPlatform(String architecture, String version) {
if (platforms != null) { if (platforms != null) {
for (ArduinoPlatform plat : platforms) { for (ArduinoPlatform plat : platforms) {
@ -129,9 +158,9 @@ public class ArduinoPackage {
Map<String, ArduinoPlatform> platformMap = new HashMap<>(); Map<String, ArduinoPlatform> platformMap = new HashMap<>();
for (ArduinoPlatform platform : platforms) { for (ArduinoPlatform platform : platforms) {
if (!installedPlatforms.containsKey(platform.getArchitecture())) { if (!installedPlatforms.containsKey(platform.getArchitecture())) {
ArduinoPlatform p = platformMap.get(platform.getName()); ArduinoPlatform p = platformMap.get(platform.getArchitecture());
if (p == null || ArduinoManager.compareVersions(platform.getVersion(), p.getVersion()) > 0) { if (p == null || ArduinoManager.compareVersions(platform.getVersion(), p.getVersion()) > 0) {
platformMap.put(platform.getName(), platform); platformMap.put(platform.getArchitecture(), platform);
} }
} }
} }
@ -151,29 +180,40 @@ public class ArduinoPackage {
return null; return null;
} }
public ArduinoTool getLatestTool(String toolName) { private void initLatestTools() {
ArduinoTool latest = null; if (latestTools == null) {
latestTools = new HashMap<>();
for (ArduinoTool tool : tools) { for (ArduinoTool tool : tools) {
if (tool.getName().equals(toolName) && tool.isInstalled()) { ArduinoTool current = latestTools.get(tool.getName());
if (latest == null || ArduinoManager.compareVersions(tool.getVersion(), latest.getVersion()) > 0) { if (current == null || ArduinoManager.compareVersions(tool.getVersion(), current.getVersion()) > 0) {
latest = tool; latestTools.put(tool.getName(), tool);
} }
} }
} }
return latest; }
public ArduinoTool getLatestTool(String toolName) {
initLatestTools();
return latestTools.get(toolName);
}
public Collection<ArduinoTool> getLatestTools() {
initLatestTools();
return latestTools.values();
} }
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj instanceof ArduinoPackage) { if (obj instanceof ArduinoPackage) {
return ((ArduinoPackage) obj).getName().equals(name); return ((ArduinoPackage) obj).getName().equals(getName());
} }
return super.equals(obj); return super.equals(obj);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return name.hashCode(); return getName().hashCode();
} }
} }

View file

@ -231,15 +231,16 @@ public class ArduinoBuildConfiguration extends CBuildConfiguration implements Te
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 and avrdude tools // Everyone seems to want to use arduino package tools
ArduinoPackage arduinoPackage = manager.getPackage("arduino"); //$NON-NLS-1$ ArduinoPackage arduinoPackage = manager.getPackage("arduino"); //$NON-NLS-1$
ArduinoTool avrgcc = arduinoPackage.getLatestTool("avr-gcc"); //$NON-NLS-1$ if (arduinoPackage != null) {
if (avrgcc != null) { for (ArduinoTool tool : arduinoPackage.getLatestTools()) {
properties.put("runtime.tools.avr-gcc.path", avrgcc.getInstallPath().toString()); //$NON-NLS-1$ properties.put("runtime.tools." + tool.getName() + ".path", tool.getInstallPath().toString()); //$NON-NLS-1$ //$NON-NLS-2$
}
for (ArduinoTool tool : arduinoPackage.getTools()) {
properties.put("runtime.tools." + tool.getName() + '-' + tool.getVersion() + ".path", //$NON-NLS-1$ //$NON-NLS-2$
tool.getInstallPath().toString());
} }
ArduinoTool avrdude = arduinoPackage.getLatestTool("avrdude"); //$NON-NLS-1$
if (avrdude != null) {
properties.put("runtime.tools.avrdude.path", avrdude.getInstallPath().toString()); //$NON-NLS-1$
} }
// Super Platform // Super Platform

View file

@ -23,10 +23,12 @@ public class ArduinoLaunchConfigurationProvider extends ProjectLaunchConfigProvi
@Override @Override
public boolean supports(ILaunchDescriptor descriptor, ILaunchTarget target) throws CoreException { public boolean supports(ILaunchDescriptor descriptor, ILaunchTarget target) throws CoreException {
if (target != null) {
IRemoteConnection connection = target.getAdapter(IRemoteConnection.class); IRemoteConnection connection = target.getAdapter(IRemoteConnection.class);
if (connection != null) { if (connection != null) {
return connection.getConnectionType().getId().equals(ArduinoRemoteConnection.TYPE_ID); return connection.getConnectionType().getId().equals(ArduinoRemoteConnection.TYPE_ID);
} }
}
return false; return false;
} }

View file

@ -19,6 +19,7 @@ import org.eclipse.swt.events.FocusAdapter;
import org.eclipse.swt.events.FocusEvent; import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
public class ArduinoDownloadsManager extends WizardDialog { public class ArduinoDownloadsManager extends WizardDialog {
@ -83,8 +84,11 @@ public class ArduinoDownloadsManager extends WizardDialog {
@Override @Override
protected void createButtonsForButtonBar(Composite parent) { protected void createButtonsForButtonBar(Composite parent) {
super.createButtonsForButtonBar(parent); super.createButtonsForButtonBar(parent);
getButton(IDialogConstants.CANCEL_ID).dispose(); getButton(IDialogConstants.CANCEL_ID).setVisible(false);
getButton(IDialogConstants.FINISH_ID).setText("Done"); Button finishButton = getButton(IDialogConstants.FINISH_ID);
finishButton.setText("Done");
// make sure it's far right
finishButton.moveBelow(null);
} }
} }

View file

@ -192,8 +192,10 @@ public class BoardPropertyControl extends Composite {
control.dispose(); control.dispose();
} }
menuControls.clear(); menuControls.clear();
if (programmerLabel != null) {
programmerLabel.dispose(); programmerLabel.dispose();
programmerCombo.dispose(); programmerCombo.dispose();
}
board = newBoard; board = newBoard;
updateBoardMenu(); updateBoardMenu();