use of io.sloeber.core.txt.BoardTxtFile in project arduino-eclipse-plugin by Sloeber.
the class BoardDescription method makeBoardDescriptors.
/**
* make a board descriptor for each board in the board.txt file with the default
* options
*
* @param boardFile
* @return a list of board descriptors
*/
public static List<BoardDescription> makeBoardDescriptors(File boardFile) {
BoardTxtFile txtFile = new BoardTxtFile(resolvePathEnvironmentString(boardFile));
List<BoardDescription> boards = new ArrayList<>();
List<String> boardIDs = txtFile.getAllBoardIDs();
for (String curboardID : boardIDs) {
Map<String, String> boardSection = txtFile.getSection(curboardID);
if (boardSection != null) {
if (!"true".equalsIgnoreCase(boardSection.get("hide"))) {
// $NON-NLS-1$ //$NON-NLS-2$
boards.add(new BoardDescription(boardFile, curboardID, null));
}
}
}
return boards;
}
use of io.sloeber.core.txt.BoardTxtFile in project arduino-eclipse-plugin by Sloeber.
the class BoardDescription method setreferencingBoardsFile.
public void setreferencingBoardsFile(File boardsFile) {
if (boardsFile == null) {
// ignore
return;
}
/*
* do not do this optimization as workaround changes will not be captured if
* (this.myreferencingBoardsFile.equals(resolvePathEnvironmentString(boardsFile)
* )) { return; }
*/
myBoardTxtFile = new BoardTxtFile(resolvePathEnvironmentString(boardsFile));
setDirty();
}
use of io.sloeber.core.txt.BoardTxtFile in project arduino-eclipse-plugin by Sloeber.
the class BoardsManager method getAllmenus.
public static TreeMap<String, String> getAllmenus() {
TreeMap<String, String> ret = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
File[] boardFiles = getAllBoardsFiles();
for (File curBoardFile : boardFiles) {
BoardTxtFile txtFile = new BoardTxtFile(curBoardFile);
ret.putAll(txtFile.getMenus());
}
return ret;
}
use of io.sloeber.core.txt.BoardTxtFile in project arduino-eclipse-plugin by Sloeber.
the class BoardDescription method getFromCDT.
/**
* method to get the configuration info from the old way Sloeber stored data
*
* @param confDesc
* @return
*/
@SuppressWarnings("nls")
public static BoardDescription getFromCDT(ICConfigurationDescription confDesc) {
BoardDescription ret = new BoardDescription();
ret.myUploadPort = getOldWayEnvVar(confDesc, "JANTJE.com_port");
ret.myProgrammer = getOldWayEnvVar(confDesc, "JANTJE.upload");
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/");
}
if (packagesIndex != -1) {
referencingBoardsFile = sloeberHomePath.append(referencingBoardsFile.substring(packagesIndex)).toString();
}
File resolvedFile = resolvePathEnvironmentString(new File(referencingBoardsFile));
ret.myBoardTxtFile = new BoardTxtFile(resolvedFile);
return ret;
}
use of io.sloeber.core.txt.BoardTxtFile in project arduino-eclipse-plugin by Sloeber.
the class BoardDescription method getEnvVars.
/**
* This method creates environment variables based on the platform.txt and
* boards.txt. platform.txt is processed first and then boards.txt. This way
* boards.txt settings can overwrite common settings in platform.txt The
* environment variables are only valid for the project given as parameter The
* project properties are used to identify the boards.txt and platform.txt as
* well as the board id to select the settings in the board.txt file At the end
* also the path variable is set
*
* To be able to quickly fix boards.txt and platform.txt problems I also added a
* pre and post platform and boards files that are processed before and after
* the arduino delivered boards.txt file.
*
* @param project
* the project for which the environment variables are set
* @param arduinoProperties
* the info of the selected board to set the variables for
*/
public Map<String, String> getEnvVars() {
updateWhenDirty();
TxtFile pluginPreProcessingPlatformTxt = new TxtFile(ConfigurationPreferences.getPreProcessingPlatformFile());
TxtFile pluginPostProcessingPlatformTxt = new TxtFile(ConfigurationPreferences.getPostProcessingPlatformFile());
BoardTxtFile pluginPreProcessingBoardsTxt = new BoardTxtFile(ConfigurationPreferences.getPreProcessingBoardsFile());
BoardTxtFile pluginPostProcessingBoardsTxt = new BoardTxtFile(ConfigurationPreferences.getPostProcessingBoardsFile());
Map<String, String> allVars = pluginPreProcessingPlatformTxt.getAllEnvironVars(EMPTY);
allVars.putAll(pluginPreProcessingBoardsTxt.getBoardEnvironVars(getBoardID()));
String architecture = getArchitecture();
IPath coreHardwarePath = getreferencedCoreHardwarePath();
allVars.put(ENV_KEY_BUILD_ARCH, architecture.toUpperCase());
allVars.put(ENV_KEY_HARDWARE_PATH, coreHardwarePath.removeLastSegments(1).toOSString());
allVars.put(ENV_KEY_BUILD_SYSTEM_PATH, coreHardwarePath.append(SYSTEM).toOSString());
allVars.put(ENV_KEY_PLATFORM_PATH, getreferencingPlatformPath().toOSString());
allVars.put(ENV_KEY_SERIAL_PORT, getActualUploadPort());
allVars.put(ENV_KEY_SERIAL_DOT_PORT, getActualUploadPort());
// $NON-NLS-1$
allVars.put(ENV_KEY_SERIAL_PORT_FILE, getActualUploadPort().replace("/dev/", EMPTY));
// if actual core path is osstring regression test issue555 willl fail teensy
// stuff
allVars.put(ENV_KEY_BUILD_ACTUAL_CORE_PATH, getActualCoreCodePath().toString());
IPath variantPath = getActualVariantPath();
if (variantPath != null) {
allVars.put(ENV_KEY_BUILD_VARIANT_PATH, variantPath.toOSString());
} else {
// teensy does not use variants
allVars.put(ENV_KEY_BUILD_VARIANT_PATH, EMPTY);
}
PlatformTxtFile referencedPlatfromFile = getreferencedCorePlatformFile();
// process the platform file referenced by the boards.txt
if (referencedPlatfromFile != null) {
allVars.putAll(referencedPlatfromFile.getAllEnvironVars());
}
PlatformTxtFile referencingPlatfromFile = getReferencingPlatformFile();
// process the platform file next to the selected boards.txt
if (referencingPlatfromFile != null) {
allVars.putAll(referencingPlatfromFile.getAllEnvironVars());
}
// put in the installed tools info
allVars.putAll(getEnVarPlatformInfo());
// boards settings not coming from menu selections
allVars.putAll(myBoardTxtFile.getBoardEnvironVars(getBoardID()));
// board settings from menu selections
Map<String, String> options = getOptions();
KeyValueTree rootData = myBoardTxtFile.getData();
KeyValueTree menuData = rootData.getChild(getBoardID() + DOT + MENU);
for (Entry<String, String> curOption : options.entrySet()) {
String menuID = curOption.getKey();
String SelectedMenuItemID = curOption.getValue();
KeyValueTree curSelectedMenuItem = menuData.getChild(menuID + DOT + SelectedMenuItemID);
allVars.putAll(curSelectedMenuItem.toKeyValues(EMPTY, false));
}
// This moved last. See github issue 1410
Programmers[] localProgrammers = Programmers.fromBoards(this);
String programmer = getProgrammer();
for (Programmers curProgrammer : localProgrammers) {
String programmerID = curProgrammer.getIDFromNiceName(programmer);
if (programmerID != null) {
allVars.putAll(curProgrammer.getAllEnvironVars(programmerID));
}
}
// add the stuff that comes with the plugin that is marked as post
allVars.putAll(pluginPostProcessingPlatformTxt.getAllEnvironVars(EMPTY));
allVars.putAll(pluginPostProcessingBoardsTxt.getBoardEnvironVars(getBoardID()));
// Do some coded post processing
allVars.putAll(getEnvVarsPostProcessing(allVars));
return allVars;
}
Aggregations