use of io.sloeber.core.txt.KeyValueTree in project arduino-eclipse-plugin by Sloeber.
the class TestTxtFile method getValuekey2.
@Test
public void getValuekey2() {
KeyValueTree root = getDataSet1();
String result = root.getValue("key1.key1_2");
String expectedResult = "value1_2";
assertEquals("Wrong getvalue", expectedResult, result);
}
use of io.sloeber.core.txt.KeyValueTree in project arduino-eclipse-plugin by Sloeber.
the class TestTxtFile method getValuekey3.
@Test
public void getValuekey3() {
KeyValueTree root = getDataSet1();
String result = root.getValue("key1.key1_2");
String expectedResult = "value1_2";
assertEquals("Wrong getvalue", expectedResult, result);
}
use of io.sloeber.core.txt.KeyValueTree in project arduino-eclipse-plugin by Sloeber.
the class TestTxtFile method dumpMatchesExpectationKey1.
@Test
public void dumpMatchesExpectationKey1() {
KeyValueTree root = getDataSet1();
KeyValueTree key1 = root.getChild("key1");
String result = key1.dump();
String expectedResult = "key1_1=value1_1\n" + "key1_2=value1_2\n";
assertEquals("select key1", expectedResult, result);
}
use of io.sloeber.core.txt.KeyValueTree 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;
}
use of io.sloeber.core.txt.KeyValueTree in project arduino-eclipse-plugin by Sloeber.
the class SloeberProject method readConfigFromFiles.
/**
* Read the sloeber configuration file and setup the project
*
* @return true if the files exist
*/
private boolean readConfigFromFiles() {
IFile file = getConfigLocalFile();
IFile versionFile = getConfigVersionFile();
if (!(file.exists() || versionFile.exists())) {
// no sloeber files found
return false;
}
if (file.exists()) {
myCfgFile = new TxtFile(file.getLocation().toFile());
if (versionFile.exists()) {
myCfgFile.mergeFile(versionFile.getLocation().toFile());
}
} else {
myCfgFile = new TxtFile(versionFile.getLocation().toFile());
}
KeyValueTree allFileConfigs = myCfgFile.getData().getChild(CONFIG);
for (Entry<String, KeyValueTree> curChild : allFileConfigs.getChildren().entrySet()) {
String curConfName = curChild.getKey();
BoardDescription boardDesc = new BoardDescription(myCfgFile, getBoardPrefix(curConfName));
CompileDescription compileDescription = new CompileDescription(myCfgFile, getCompilePrefix(curConfName));
OtherDescription otherDesc = new OtherDescription(myCfgFile, getOtherPrefix(curConfName));
String curConfKey = curConfName;
myBoardDescriptions.put(curConfKey, boardDesc);
myCompileDescriptions.put(curConfKey, compileDescription);
myOtherDescriptions.put(curConfKey, otherDesc);
}
return true;
}
Aggregations