Skip to content

Commit 1da8e7a

Browse files
author
jantje
committed
#1339 all kind of fixes to try to make it work
1 parent 23ac555 commit 1da8e7a

File tree

4 files changed

+30
-19
lines changed

4 files changed

+30
-19
lines changed

io.sloeber.core/src/io/sloeber/core/api/BoardDescription.java

+12-16
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,7 @@
2222
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
2323
import org.eclipse.core.runtime.preferences.InstanceScope;
2424

25-
import io.sloeber.core.api.Json.ArduinoPackage;
2625
import io.sloeber.core.api.Json.ArduinoPlatform;
27-
import io.sloeber.core.api.Json.ArduinoPlatformTool;
28-
import io.sloeber.core.api.Json.ArduinoPlatformToolVersion;
2926
import io.sloeber.core.api.Json.ArduinoPlatformTooldDependency;
3027
import io.sloeber.core.api.Json.ArduinoPlatformVersion;
3128
import io.sloeber.core.common.Common;
@@ -859,7 +856,8 @@ private Map<String, String> getEnVarPlatformInfo() {
859856

860857
if (myReferencedPlatformCore == null) {
861858
//there is no referenced core so no need to do smart stuff
862-
return getEnvVarPlatformFileTools(referencingPlatform);
859+
ret.putAll(getEnvVarPlatformFileTools(referencingPlatform));
860+
return ret;
863861
}
864862

865863
boolean jsonBasedPlatformManagement = !Preferences.getUseArduinoToolSelection();
@@ -877,25 +875,23 @@ private Map<String, String> getEnVarPlatformInfo() {
877875
}
878876

879877
/**
880-
* This method only returns environment variables without the version number
881-
* The environment variables with version number are "global" and as sutch are
882-
* understood to exists
878+
* This method only returns environment variables with and without version
879+
* number
880+
* These are purely based on the tool dependencies
883881
*
884882
* @param platformVersion
885883
* @return environment variables pointing to the tools used by the platform
886884
*/
887885
private static Map<String, String> getEnvVarPlatformFileTools(ArduinoPlatformVersion platformVersion) {
888886
HashMap<String, String> vars = new HashMap<>();
889-
if (platformVersion.getToolsDependencies() == null) {
890-
return vars;
891-
}
892-
ArduinoPackage pkg = platformVersion.getParent().getParent();
893887
for (ArduinoPlatformTooldDependency tool : platformVersion.getToolsDependencies()) {
894-
ArduinoPlatformTool theTool = pkg.getTool(tool.getName());
895-
ArduinoPlatformToolVersion theNewestTool = theTool.getNewestInstalled();
896-
if (theNewestTool != null) {
897-
vars.putAll(theNewestTool.getEnvVars(false));
898-
}
888+
String installPath = tool.getInstallPath().toOSString();
889+
String keyString = RUNTIME_TOOLS + tool.getName() + tool.getVersion() + DOT_PATH;
890+
vars.put(keyString, installPath);
891+
keyString = RUNTIME_TOOLS + tool.getName() + '-' + tool.getVersion() + DOT_PATH;
892+
vars.put(keyString, installPath);
893+
keyString = RUNTIME_TOOLS + tool.getName() + DOT_PATH;
894+
vars.put(keyString, installPath);
899895
}
900896
return vars;
901897
}

io.sloeber.core/src/io/sloeber/core/api/Json/ArduinoPlatformTool.java

+15-1
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88
package io.sloeber.core.api.Json;
99

1010
import static io.sloeber.core.Gson.GsonConverter.*;
11+
import static io.sloeber.core.common.Const.*;
1112

1213
import java.util.Collection;
1314
import java.util.Collections;
15+
import java.util.HashMap;
1416
import java.util.TreeMap;
1517

1618
import org.eclipse.core.runtime.IPath;
@@ -23,7 +25,6 @@
2325

2426
public class ArduinoPlatformTool extends Node {
2527

26-
private static final String TOOLS = "tools"; //$NON-NLS-1$
2728
private String myName;
2829
private TreeMap<VersionNumber, ArduinoPlatformToolVersion> myVersions = new TreeMap<>(Collections.reverseOrder());
2930

@@ -108,4 +109,17 @@ public Collection<ArduinoPlatformToolVersion> getVersions() {
108109
return myVersions.values();
109110
}
110111

112+
public HashMap<String, String> getEnvVars(VersionNumber defaultVersionNumber) {
113+
114+
HashMap<String, String> vars = new HashMap<>();
115+
for (ArduinoPlatformToolVersion curToolVersion : myVersions.values()) {
116+
if (curToolVersion.isInstalled()) {
117+
boolean skipdefault = (defaultVersionNumber == null)
118+
|| (curToolVersion.getVersion().compareTo(defaultVersionNumber) != 0);
119+
vars.putAll(curToolVersion.getEnvVars(skipdefault));
120+
}
121+
}
122+
return vars;
123+
}
124+
111125
}

io.sloeber.core/src/io/sloeber/core/api/Json/ArduinoPlatformToolVersion.java

-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
import io.sloeber.core.api.VersionNumber;
2424

2525
public class ArduinoPlatformToolVersion extends Node {
26-
static final private String RUNTIME_TOOLS = RUNTIME + DOT + TOOLS + DOT;
27-
static final private String DOT_PATH = DOT + PATH;
2826

2927
private VersionNumber myVersion;
3028
private List<ArduinpPlatformToolSystem> mySystems = new ArrayList<>();

io.sloeber.core/src/io/sloeber/core/common/Const.java

+3
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ public class Const {
116116

117117
public static final String SLOEBER_OBJCOPY = ENV_KEY_SLOEBER_START + "objcopy";
118118

119+
public static final String RUNTIME_TOOLS = RUNTIME + DOT + TOOLS + DOT;
120+
public static final String DOT_PATH = DOT + PATH;
121+
119122
public static final String AVR = "avr";
120123
public static final String SAM = "sam";
121124
public static final String SAMD = "samd";

0 commit comments

Comments
 (0)