Skip to content

Commit

Permalink
#1339 merged the 2 version implementations
Browse files Browse the repository at this point in the history
Also used the versionNumber class to store versions
  • Loading branch information
jantje committed Nov 7, 2021
1 parent 6708628 commit deb3175
Show file tree
Hide file tree
Showing 15 changed files with 218 additions and 263 deletions.
36 changes: 12 additions & 24 deletions io.sloeber.core/src/io/sloeber/core/api/BoardDescription.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ public class BoardDescription {
private String myBoardID = EMPTY;
private Map<String, String> myOptions = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);


/*
* Stuff to make things work
*/
Expand All @@ -94,7 +93,6 @@ public class BoardDescription {
private final String KEY_SLOEBER_UPLOAD_PORT = "UPLOAD.PORT"; //$NON-NLS-1$
private final String KEY_SLOEBER_MENU_SELECTION = "BOARD.MENU"; //$NON-NLS-1$


@Override
public String toString() {
return getReferencingBoardsFile() + " \"" + getBoardName() + "\" " + getUploadPort(); //$NON-NLS-1$//$NON-NLS-2$
Expand Down Expand Up @@ -207,7 +205,7 @@ private void ParseSection() {
} else if (valueSplit.length == 4) {
String refVendor = valueSplit[0];
String refArchitecture = valueSplit[1];
String refVersion = valueSplit[2];
VersionNumber refVersion = new VersionNumber(valueSplit[2]);
String actualValue = valueSplit[3];
myBoardsCore = actualValue;
myReferencedCorePlatformPath = InternalPackageManager.getPlatformInstallPath(refVendor, refArchitecture,
Expand Down Expand Up @@ -241,7 +239,7 @@ private void ParseSection() {
} else if (valueSplit.length == 4) {
String refVendor = valueSplit[0];
String refArchitecture = valueSplit[1];
String refVersion = valueSplit[2];
VersionNumber refVersion = new VersionNumber(valueSplit[2]);
String actualValue = valueSplit[3];
this.myBoardsVariant = actualValue;
if ("*".equals(refVersion)) { //$NON-NLS-1$
Expand Down Expand Up @@ -280,7 +278,7 @@ private void ParseSection() {
} else if (valueSplit.length == 4) {
String refVendor = valueSplit[0];
String refArchitecture = valueSplit[1];
String refVersion = valueSplit[2];
VersionNumber refVersion = new VersionNumber(valueSplit[2]);
String actualValue = valueSplit[3];
this.myUploadTool = actualValue;
this.myReferencedUploadToolPlatformPath = InternalPackageManager.getPlatformInstallPath(refVendor,
Expand Down Expand Up @@ -357,8 +355,6 @@ public BoardDescription(BoardDescription srcObject) {
myOptions = new TreeMap<>(srcObject.myOptions);
}



public String getuploadTool() {
return this.myUploadTool;
}
Expand All @@ -374,7 +370,8 @@ private void setDefaultOptions() {
Map<String, String> allMenuIDs = this.myBoardTxtFile.getMenus();
for (Map.Entry<String, String> curMenuID : allMenuIDs.entrySet()) {
String providedMenuValue = this.myOptions.get(curMenuID.getKey());
ArrayList<String> menuOptions = this.myBoardTxtFile.getMenuItemIDsFromMenuID(curMenuID.getKey(), getBoardID());
ArrayList<String> menuOptions = this.myBoardTxtFile.getMenuItemIDsFromMenuID(curMenuID.getKey(),
getBoardID());
if (menuOptions.size() > 0) {
if (providedMenuValue == null) {

Expand All @@ -398,7 +395,6 @@ public void saveUserSelection() {
myStorageNode.put(KEY_LAST_USED_BOARD_MENU_OPTIONS, KeyValue.makeString(this.myOptions));
}


public String getArchitecture() {
return this.myBoardTxtFile.getArchitecture();
}
Expand Down Expand Up @@ -526,7 +522,6 @@ public String[] getMenuItemNamesFromMenuID(String menuID) {
return this.myBoardTxtFile.getMenuItemNamesFromMenuID(menuID, this.myBoardID);
}


public TreeMap<String, IPath> getAllExamples() {
updateWhenDirty();
return LibraryManager.getAllExamples(this);
Expand Down Expand Up @@ -661,7 +656,6 @@ public String getUploadPatternKey() {
return TOOLS + DOT + upLoadTool + DOT + UPLOAD + DOT + networkPrefix + PATTERN;
}


public IPath getreferencedHardwarePath() {
updateWhenDirty();
IPath platformPath = getReferencedCorePlatformPath();
Expand Down Expand Up @@ -701,7 +695,6 @@ public boolean isNetworkUpload() {
return getHost() != null;
}


protected BoardDescription(File txtFile, String boardID) {
this.myBoardID = boardID;
this.myreferencingBoardsFile = txtFile;
Expand Down Expand Up @@ -730,7 +723,6 @@ protected BoardDescription(File txtFile, String boardID) {
}
}


private Map<String, String> onlyKeepValidOptions(Map<String, String> options) {
Map<String, String> ret = new HashMap<>();

Expand Down Expand Up @@ -824,7 +816,6 @@ public Map<String, String> getEnvVars() {
allVars.put(ENV_KEY_HARDWARE_PATH, getreferencedHardwarePath().toOSString());
allVars.put(ENV_KEY_PLATFORM_PATH, getreferencingPlatformPath().toOSString());


allVars.put(ENV_KEY_SERIAL_PORT, getActualUploadPort());
allVars.put(ENV_KEY_SERIAL_DOT_PORT, getActualUploadPort());

Expand All @@ -846,7 +837,6 @@ public Map<String, String> getEnvVars() {
allVars.put(ENV_KEY_REFERENCED_VARIANT_PLATFORM_PATH, getReferencedVariantPlatformPath().toOSString());
allVars.put(ENV_KEY_REFERENCED_UPLOAD_PLATFORM_PATH, getReferencedUploadPlatformPath().toOSString());


PlatformTxtFile referencedPlatfromFile = getreferencedPlatformFile();
// process the platform file referenced by the boards.txt
if (referencedPlatfromFile != null) {
Expand All @@ -861,12 +851,10 @@ public Map<String, String> getEnvVars() {
// put in the installed tools info
allVars.putAll(getEnVarPlatformInfo());



Programmers localProgrammers[] = Programmers.fromBoards(this);
String programmer = getProgrammer();
for (Programmers curProgrammer : localProgrammers) {
// allVars.putAll(curProgrammer.getAllEnvironVars());
// allVars.putAll(curProgrammer.getAllEnvironVars());
String programmerID = curProgrammer.getIDFromNiceName(programmer);
if (programmerID != null) {
allVars.putAll(curProgrammer.getAllEnvironVars(programmerID));
Expand Down Expand Up @@ -1069,18 +1057,18 @@ public static BoardDescription getFromCDT(ICConfigurationDescription confDesc) {
ret.myBoardID = getOldWayEnvVar(confDesc, "JANTJE.board_ID");
String optinconcat = getOldWayEnvVar(confDesc, "JANTJE.menu");
ret.myOptions = KeyValue.makeMap(optinconcat);

String referencingBoardsFile = getOldWayEnvVar(confDesc, "JANTJE.boards_file");
int packagesIndex=referencingBoardsFile.indexOf( "\\arduinoPlugin\\packages\\");
if(packagesIndex==-1) {
packagesIndex=referencingBoardsFile.indexOf( "/arduinoPlugin/packages/");
int packagesIndex = referencingBoardsFile.indexOf("\\arduinoPlugin\\packages\\");
if (packagesIndex == -1) {
packagesIndex = referencingBoardsFile.indexOf("/arduinoPlugin/packages/");
}
if(packagesIndex!=-1) {
if (packagesIndex != -1) {
referencingBoardsFile = sloeberHomePath.append(referencingBoardsFile.substring(packagesIndex)).toString();
}
ret.myreferencingBoardsFile = resolvePathEnvironmentString(new File(referencingBoardsFile));
ret.myBoardTxtFile = new BoardTxtFile(ret.myreferencingBoardsFile);

return ret;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import io.sloeber.core.api.Defaults;
import io.sloeber.core.api.LibraryDescriptor;
import io.sloeber.core.tools.Version;
import io.sloeber.core.api.VersionNumber;

/**
* This class represents a json file that references libraries
Expand Down Expand Up @@ -64,7 +64,7 @@ public void resolve(File packageFile) {

LibraryJson current = this.latestLibs.get(name);
if (current != null) {
if (Version.compare(library.getVersion(), current.getVersion()) > 0) {
if (library.getVersion().compareTo(current.getVersion()) > 0) {
this.latestLibs.put(name, library);
}
} else {
Expand All @@ -77,7 +77,7 @@ public LibraryJson getLatestLibrary(String name) {
return this.latestLibs.get(name);
}

public LibraryJson getLibrary(String libName, String version) {
public LibraryJson getLibrary(String libName, VersionNumber version) {
for (LibraryJson library : this.libraries) {
if (library.getName().equals(libName) && (library.getVersion().equals(version))) {
return library;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.google.gson.JsonParseException;

import io.sloeber.core.Activator;
import io.sloeber.core.api.VersionNumber;
import io.sloeber.core.common.Common;
import io.sloeber.core.common.ConfigurationPreferences;
import io.sloeber.core.managers.InternalPackageManager;
Expand All @@ -38,7 +39,7 @@
public class LibraryJson implements Comparable<LibraryJson> {

private String name;
private String version;
private VersionNumber version;
private String author;
private String maintainer;
private String sentence;
Expand All @@ -58,7 +59,7 @@ public LibraryJson(JsonElement json, LibraryIndexJson libraryIndexJson) {
JsonObject jsonObject = json.getAsJsonObject();
try {
name = getSafeString(jsonObject, "name");
version = getSafeString(jsonObject, "version");
version = getSafeVersion(jsonObject, "version");
author = getSafeString(jsonObject, "author");
maintainer = getSafeString(jsonObject, "maintainer");
sentence = getSafeString(jsonObject, "sentence");
Expand All @@ -82,64 +83,64 @@ public LibraryJson(JsonElement json, LibraryIndexJson libraryIndexJson) {
}

public String getName() {
return this.name;
return name;
}

public String getVersion() {
return this.version;
public VersionNumber getVersion() {
return version;
}

public String getAuthor() {
return this.author;
return author;
}

public String getMaintainer() {
return this.maintainer;
return maintainer;
}

public String getSentence() {
return this.sentence;
return sentence;
}

public String getParagraph() {
return this.paragraph;
return paragraph;
}

public String getWebsite() {
return this.website;
return website;
}

public String getCategory() {
return this.category;
return category;
}

public List<String> getArchitectures() {
return this.architectures;
return architectures;
}

public List<String> getTypes() {
return this.types;
return types;
}

public String getUrl() {
return this.url;
return url;
}

public String getArchiveFileName() {
return this.archiveFileName;
return archiveFileName;
}

public int getSize() {
return this.size;
return size;
}

public String getChecksum() {
return this.checksum;
return checksum;
}

public IPath getInstallPath() {
return ConfigurationPreferences.getInstallationPathLibraries().append(this.name.replace(' ', '_'))
.append(this.version);
.append(version.toString());
}

public boolean isInstalled() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.google.gson.JsonParseException;

import io.sloeber.core.Activator;
import io.sloeber.core.api.VersionNumber;
import io.sloeber.core.common.ConfigurationPreferences;
import io.sloeber.core.common.Const;
import io.sloeber.core.managers.InternalPackageManager;
Expand All @@ -34,7 +35,7 @@ public class ArduinoPlatform {

private String name;
private String architecture;
private String version;
private VersionNumber version;
private String category;
private String url;
private String archiveFileName;
Expand All @@ -55,7 +56,7 @@ public ArduinoPlatform(JsonElement json, Package parent) {
try {
name = getSafeString(jsonObject, "name");
architecture = getSafeString(jsonObject, "architecture");
version = getSafeString(jsonObject, "version");
version = getSafeVersion(jsonObject, "version");
category = getSafeString(jsonObject, "category");
url = getSafeString(jsonObject, "url");
archiveFileName = getSafeString(jsonObject, "archiveFileName");
Expand Down Expand Up @@ -83,35 +84,35 @@ public String getName() {
}

public String getArchitecture() {
return this.architecture;
return architecture;
}

public String getVersion() {
return this.version;
public VersionNumber getVersion() {
return version;
}

public String getCategory() {
return this.category;
return category;
}

public String getUrl() {
return this.url;
return url;
}

public String getArchiveFileName() {
return this.archiveFileName;
return archiveFileName;
}

public String getChecksum() {
return this.checksum;
return checksum;
}

public String getSize() {
return this.size;
return size;
}

public List<ToolDependency> getToolsDependencies() {
return this.toolsDependencies;
return toolsDependencies;
}

public boolean isInstalled() {
Expand All @@ -128,7 +129,7 @@ public File getPlatformFile() {

public IPath getInstallPath() {
IPath stPath = ConfigurationPreferences.getInstallationPathPackages().append(this.myParent.getName())
.append(Const.ARDUINO_HARDWARE_FOLDER_NAME).append(this.architecture).append(this.version);
.append(Const.ARDUINO_HARDWARE_FOLDER_NAME).append(this.architecture).append(this.version.toString());
return stPath;
}

Expand All @@ -138,7 +139,6 @@ public List<IPath> getIncludePath() {
installPath.append(Const.VARIANTS_FOLDER_NAME + "/{build.variant}")); //$NON-NLS-1$
}

@SuppressWarnings("unused")
public IStatus remove(IProgressMonitor monitor) {
// Check if we're installed
if (!isInstalled()) {
Expand Down
Loading

0 comments on commit deb3175

Please sign in to comment.