1
0
mirror of https://github.com/arduino/Arduino.git synced 2024-11-29 10:24:12 +01:00

Allow Pluggable Discovery recipes to use {runtime.platform.path}

This commit is contained in:
PaulStoffregen 2020-01-20 15:39:58 -08:00 committed by Cristian Maglie
parent ff26dd58f8
commit 0f5d22c67c

View File

@ -35,6 +35,7 @@ import static processing.app.I18n.tr;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.io.File;
import cc.arduino.packages.discoverers.PluggableDiscovery; import cc.arduino.packages.discoverers.PluggableDiscovery;
import cc.arduino.packages.discoverers.serial.SerialDiscovery; import cc.arduino.packages.discoverers.serial.SerialDiscovery;
@ -65,6 +66,10 @@ public class DiscoveryManager {
for (TargetPlatform platform: targetPackage.getPlatforms().values()) { for (TargetPlatform platform: targetPackage.getPlatforms().values()) {
//System.out.println("installed: "+platform); //System.out.println("installed: "+platform);
PreferencesMap prefs = platform.getPreferences().subTree("discovery"); PreferencesMap prefs = platform.getPreferences().subTree("discovery");
PreferencesMap pathPrefs = new PreferencesMap();
File platformFolder = platform.getFolder();
pathPrefs.put("runtime.platform.path", platformFolder.getAbsolutePath());
pathPrefs.put("runtime.hardware.path", platformFolder.getParentFile().getAbsolutePath());
for (String discoveryName : prefs.firstLevelMap().keySet()) { for (String discoveryName : prefs.firstLevelMap().keySet()) {
PreferencesMap discoveryPrefs = prefs.subTree(discoveryName); PreferencesMap discoveryPrefs = prefs.subTree(discoveryName);
@ -76,9 +81,11 @@ public class DiscoveryManager {
try { try {
if (PreferencesData.getBoolean("discovery.debug")) { if (PreferencesData.getBoolean("discovery.debug")) {
System.out.println("found discovery: " + discoveryName + " -> " + pattern); System.out.println("found discovery: " + discoveryName + " -> " + pattern);
System.out.println("with pathnames -> " + pathPrefs);
System.out.println("with preferencess -> " + discoveryPrefs); System.out.println("with preferencess -> " + discoveryPrefs);
} }
pattern = StringReplacer.replaceFromMapping(pattern, PreferencesData.getMap()); pattern = StringReplacer.replaceFromMapping(pattern, PreferencesData.getMap());
pattern = StringReplacer.replaceFromMapping(pattern, pathPrefs);
String[] cmd = StringReplacer.formatAndSplit(pattern, discoveryPrefs); String[] cmd = StringReplacer.formatAndSplit(pattern, discoveryPrefs);
discoverers.add(new PluggableDiscovery(discoveryName, cmd)); discoverers.add(new PluggableDiscovery(discoveryName, cmd));
} catch (Exception e) { } catch (Exception e) {