mirror of
https://github.com/esp8266/Arduino.git
synced 2025-08-11 09:43:08 +03:00
Tools path are now always available through preferences
The preference key is: {runtime.tools.TOOLNAME.path} {runtime.tools.TOOLNAME-VERSION.path} For example the tool "avrdude" is now available through {runtime.tools.avrdude.path} or if a specific version is needed: {runtime.tools.avrdude-5.11.path}
This commit is contained in:
committed by
Federico Fissore
parent
2c941d424e
commit
b1e0249a4f
@@ -28,16 +28,11 @@
|
||||
*/
|
||||
package cc.arduino.packages.contributions;
|
||||
|
||||
import static processing.app.I18n._;
|
||||
import static processing.app.I18n.format;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Set;
|
||||
|
||||
import processing.app.debug.LegacyTargetPlatform;
|
||||
import processing.app.debug.TargetPackage;
|
||||
import processing.app.debug.TargetPlatformException;
|
||||
import processing.app.helpers.PreferencesMap;
|
||||
|
||||
public class ContributedTargetPlatform extends LegacyTargetPlatform {
|
||||
|
||||
@@ -46,35 +41,5 @@ public class ContributedTargetPlatform extends LegacyTargetPlatform {
|
||||
ContributionsIndex index)
|
||||
throws TargetPlatformException {
|
||||
super(_name, _folder, parent);
|
||||
|
||||
// Populate tools
|
||||
PreferencesMap toolsPrefs = preferences.subTree("tools");
|
||||
Set<String> names = toolsPrefs.firstLevelMap().keySet();
|
||||
for (String name : names) {
|
||||
String version = toolsPrefs.get(name + ".version");
|
||||
if (version == null) {
|
||||
throw new TargetPlatformException(
|
||||
format(_("Tool {0} must define a version property ({1})"), //
|
||||
name, "tools." + name + ".version"));
|
||||
}
|
||||
|
||||
String packageName = getContainerPackage().getId();
|
||||
ContributedTool tool = index.findTool(packageName, name, version);
|
||||
if (tool == null) {
|
||||
throw new TargetPlatformException(
|
||||
format(_("Tool {0} not found in package {1}"),
|
||||
name + ":" + version, packageName));
|
||||
}
|
||||
|
||||
DownloadableContribution download = tool.getDownloadableContribution();
|
||||
if (!download.isInstalled()) {
|
||||
throw new TargetPlatformException(
|
||||
format(_("Tool {0} is required but it's not installed."), //
|
||||
name + ":" + version));
|
||||
}
|
||||
preferences.put("tools." + name + ".path", //
|
||||
download.getInstalledFolder().getAbsolutePath());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -35,7 +35,9 @@ import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import processing.app.debug.TargetPackage;
|
||||
import processing.app.debug.TargetPlatform;
|
||||
@@ -221,6 +223,20 @@ public class ContributionsIndexer {
|
||||
return false;
|
||||
}
|
||||
|
||||
public Set<ContributedTool> getInstalledTools() {
|
||||
Set<ContributedTool> tools = new HashSet<ContributedTool>();
|
||||
for (ContributedPackage pack : index.getPackages()) {
|
||||
for (ContributedPlatform platform : pack.getPlatforms()) {
|
||||
if (!platform.isInstalled())
|
||||
continue;
|
||||
for (ContributedTool tool : platform.getResolvedTools()) {
|
||||
tools.add(tool);
|
||||
}
|
||||
}
|
||||
}
|
||||
return tools;
|
||||
}
|
||||
|
||||
public ContributionsIndex getIndex() {
|
||||
return index;
|
||||
}
|
||||
|
Reference in New Issue
Block a user