Skip to content

Commit

Permalink
#1339 all kind of fixes to try to make it work
Browse files Browse the repository at this point in the history
  • Loading branch information
jantje committed Nov 25, 2021
1 parent 23ac555 commit 1da8e7a
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 19 deletions.
28 changes: 12 additions & 16 deletions io.sloeber.core/src/io/sloeber/core/api/BoardDescription.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.InstanceScope;

import io.sloeber.core.api.Json.ArduinoPackage;
import io.sloeber.core.api.Json.ArduinoPlatform;
import io.sloeber.core.api.Json.ArduinoPlatformTool;
import io.sloeber.core.api.Json.ArduinoPlatformToolVersion;
import io.sloeber.core.api.Json.ArduinoPlatformTooldDependency;
import io.sloeber.core.api.Json.ArduinoPlatformVersion;
import io.sloeber.core.common.Common;
Expand Down Expand Up @@ -859,7 +856,8 @@ private Map<String, String> getEnVarPlatformInfo() {

if (myReferencedPlatformCore == null) {
//there is no referenced core so no need to do smart stuff
return getEnvVarPlatformFileTools(referencingPlatform);
ret.putAll(getEnvVarPlatformFileTools(referencingPlatform));
return ret;
}

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

/**
* This method only returns environment variables without the version number
* The environment variables with version number are "global" and as sutch are
* understood to exists
* This method only returns environment variables with and without version
* number
* These are purely based on the tool dependencies
*
* @param platformVersion
* @return environment variables pointing to the tools used by the platform
*/
private static Map<String, String> getEnvVarPlatformFileTools(ArduinoPlatformVersion platformVersion) {
HashMap<String, String> vars = new HashMap<>();
if (platformVersion.getToolsDependencies() == null) {
return vars;
}
ArduinoPackage pkg = platformVersion.getParent().getParent();
for (ArduinoPlatformTooldDependency tool : platformVersion.getToolsDependencies()) {
ArduinoPlatformTool theTool = pkg.getTool(tool.getName());
ArduinoPlatformToolVersion theNewestTool = theTool.getNewestInstalled();
if (theNewestTool != null) {
vars.putAll(theNewestTool.getEnvVars(false));
}
String installPath = tool.getInstallPath().toOSString();
String keyString = RUNTIME_TOOLS + tool.getName() + tool.getVersion() + DOT_PATH;
vars.put(keyString, installPath);
keyString = RUNTIME_TOOLS + tool.getName() + '-' + tool.getVersion() + DOT_PATH;
vars.put(keyString, installPath);
keyString = RUNTIME_TOOLS + tool.getName() + DOT_PATH;
vars.put(keyString, installPath);
}
return vars;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
package io.sloeber.core.api.Json;

import static io.sloeber.core.Gson.GsonConverter.*;
import static io.sloeber.core.common.Const.*;

import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.TreeMap;

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

public class ArduinoPlatformTool extends Node {

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

Expand Down Expand Up @@ -108,4 +109,17 @@ public Collection<ArduinoPlatformToolVersion> getVersions() {
return myVersions.values();
}

public HashMap<String, String> getEnvVars(VersionNumber defaultVersionNumber) {

HashMap<String, String> vars = new HashMap<>();
for (ArduinoPlatformToolVersion curToolVersion : myVersions.values()) {
if (curToolVersion.isInstalled()) {
boolean skipdefault = (defaultVersionNumber == null)
|| (curToolVersion.getVersion().compareTo(defaultVersionNumber) != 0);
vars.putAll(curToolVersion.getEnvVars(skipdefault));
}
}
return vars;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
import io.sloeber.core.api.VersionNumber;

public class ArduinoPlatformToolVersion extends Node {
static final private String RUNTIME_TOOLS = RUNTIME + DOT + TOOLS + DOT;
static final private String DOT_PATH = DOT + PATH;

private VersionNumber myVersion;
private List<ArduinpPlatformToolSystem> mySystems = new ArrayList<>();
Expand Down
3 changes: 3 additions & 0 deletions io.sloeber.core/src/io/sloeber/core/common/Const.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ public class Const {

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

public static final String RUNTIME_TOOLS = RUNTIME + DOT + TOOLS + DOT;
public static final String DOT_PATH = DOT + PATH;

public static final String AVR = "avr";
public static final String SAM = "sam";
public static final String SAMD = "samd";
Expand Down

0 comments on commit 1da8e7a

Please sign in to comment.