use of org.eclipse.cdt.core.envvar.EnvironmentVariable in project arduino-eclipse-plugin by Sloeber.
the class Helpers method setTheEnvironmentVariablesAddtheBoardsTxt.
/**
* This method parses the boards.txt file for values to be added to the
* environment variables First it adds all the variables based on the board name
* [boardID].[key]=[value] results in [key]=[value] (taking in account the
* modifiers) Then it parses for the menu variables
* menu.[menuID].[boardID].[selectionID].[key]=[value] results in [key]=[value]
* (taking in account the modifiers)
*
* @param contribEnv
* @param confDesc
* @param platformFilename
* The file to parse
*/
private static void setTheEnvironmentVariablesAddtheBoardsTxt(IContributedEnvironment contribEnv, ICConfigurationDescription confDesc, InternalBoardDescriptor boardDescriptor, boolean warn) {
TxtFile boardsFile = boardDescriptor.getTxtFile();
String boardID = boardDescriptor.getBoardID();
Map<String, String> options = boardDescriptor.getOptions();
// Get the boards section and add all entries to the environment
// variables
Map<String, String> boardSectionMap = boardsFile.getSection(boardID);
if (boardSectionMap == null) {
if (warn) {
Common.log(new Status(IStatus.INFO, Const.CORE_PLUGIN_ID, Messages.Helpers_The_project + confDesc.getProjectDescription().getProject().getName() + Messages.Helpers_Invalid_boards_config + confDesc.getName() + Messages.Helpers_boards_file + boardsFile.getTxtFile().toString() + Messages.Helpers_Boards_id + boardID));
}
return;
}
List<EnvironmentVariable> localVariables = new ArrayList<>();
for (Entry<String, String> currentPair : boardSectionMap.entrySet()) {
// if it is not a menu item add it
if (!currentPair.getKey().startsWith(MENU_KEY)) {
String keyString = MakeKeyString(currentPair.getKey());
String valueString = MakeEnvironmentString(currentPair.getValue(), Const.ERASE_START, true);
if (isLocalKey(currentPair.getKey())) {
localVariables.add(new EnvironmentVariable(keyString, valueString));
} else {
contribEnv.addVariable(new EnvironmentVariable(keyString, valueString), confDesc);
}
}
}
for (EnvironmentVariable environmentVariable : localVariables) {
contribEnv.addVariable(environmentVariable, confDesc);
}
for (Entry<String, String> currentPair : boardSectionMap.entrySet()) {
// if it is a menu item add it
if (currentPair.getKey().startsWith(MENU_KEY)) {
String[] keySplit = currentPair.getKey().split("\\.");
String menuID = keySplit[1];
String menuItemID = keySplit[2];
if (menuItemID.equalsIgnoreCase(options.get(menuID.toUpperCase()))) {
// we also need to skip the name
// $NON-NLS-1$
String StartValue = MENU + DOT + menuID + DOT + menuItemID + DOT;
try {
String keyString = MakeKeyString(currentPair.getKey().substring(StartValue.length()));
String valueString = MakeEnvironmentString(currentPair.getValue(), Const.ERASE_START, true);
contribEnv.addVariable(new EnvironmentVariable(keyString, valueString), confDesc);
} catch (StringIndexOutOfBoundsException e) {
// ignore as this is the case when the menu name is
// processed
}
}
}
}
}
use of org.eclipse.cdt.core.envvar.EnvironmentVariable in project arduino-eclipse-plugin by Sloeber.
the class CompileOptions method save.
/**
* save the compilation options in this configuration description.
*
* @param configuration
* must be a valid configuration description
*/
public void save(ICConfigurationDescription configuration) {
CompileOptions curOptions = new CompileOptions(configuration);
if (needsDirtyFlag(curOptions)) {
IProject project = configuration.getProjectDescription().getProject();
Helpers.setDirtyFlag(project, configuration);
}
IEnvironmentVariableManager envManager = CCorePlugin.getDefault().getBuildEnvironmentManager();
IContributedEnvironment contribEnv = envManager.getContributedEnvironment();
IEnvironmentVariable var = new EnvironmentVariable(ENV_KEY_JANTJE_WARNING_LEVEL, this.myWarningLevel.toString());
contribEnv.addVariable(var, configuration);
if (this.isWarningLevel()) {
var = new EnvironmentVariable(ENV_KEY_WARNING_LEVEL_OFF, ENV_KEY_WARNING_LEVEL_ON);
contribEnv.addVariable(var, configuration);
}
if (this.myAlternativeSizeCommand) {
var = new EnvironmentVariable(ENV_KEY_JANTJE_SIZE_SWITCH, // $NON-NLS-1$
"${" + ENV_KEY_JANTJE_SIZE_COMMAND + // $NON-NLS-1$
"}");
contribEnv.addVariable(var, configuration);
} else {
var = new EnvironmentVariable(ENV_KEY_JANTJE_SIZE_SWITCH, // $NON-NLS-1$
"${" + Common.get_ENV_KEY_RECIPE(Const.ACTION_SIZE) + // $NON-NLS-1$
"}");
contribEnv.addVariable(var, configuration);
}
var = new EnvironmentVariable(ENV_KEY_JANTJE_ADDITIONAL_COMPILE_OPTIONS, this.my_C_andCPP_CompileOptions);
contribEnv.addVariable(var, configuration);
var = new EnvironmentVariable(ENV_KEY_JANTJE_ADDITIONAL_CPP_COMPILE_OPTIONS, this.my_CPP_CompileOptions);
contribEnv.addVariable(var, configuration);
var = new EnvironmentVariable(ENV_KEY_JANTJE_ADDITIONAL_C_COMPILE_OPTIONS, this.my_C_CompileOptions);
contribEnv.addVariable(var, configuration);
var = new EnvironmentVariable(ENV_KEY_JANTJE_ASSEMBLY_COMPILE_OPTIONS, this.my_Assembly_CompileOptions);
contribEnv.addVariable(var, configuration);
var = new EnvironmentVariable(ENV_KEY_JANTJE_ARCHIVE_COMPILE_OPTIONS, this.my_Archive_CompileOptions);
contribEnv.addVariable(var, configuration);
var = new EnvironmentVariable(ENV_KEY_JANTJE_LINK_COMPILE_OPTIONS, this.my_Link_CompileOptions);
contribEnv.addVariable(var, configuration);
var = new EnvironmentVariable(ENV_KEY_JANTJE_ALL_COMPILE_OPTIONS, this.my_All_CompileOptions);
contribEnv.addVariable(var, configuration);
}
use of org.eclipse.cdt.core.envvar.EnvironmentVariable in project arduino-eclipse-plugin by Sloeber.
the class Common method setBuildEnvironmentVariable.
public static void setBuildEnvironmentVariable(IContributedEnvironment contribEnv, ICConfigurationDescription confdesc, String key, String value) {
IEnvironmentVariable var = new EnvironmentVariable(key, makePathEnvironmentString(value));
contribEnv.addVariable(var, confdesc);
}
use of org.eclipse.cdt.core.envvar.EnvironmentVariable in project arduino-eclipse-plugin by Sloeber.
the class arduinoUploader method setEnvironmentvarsForAutorizedUpload.
private void setEnvironmentvarsForAutorizedUpload(IContributedEnvironment contribEnv, ICConfigurationDescription configurationDescription, String host) {
String passWord = null;
passWord = getPasswordFromCode();
IEnvironmentVariable var = new EnvironmentVariable(Const.ENV_KEY_NETWORK_AUTH, passWord);
contribEnv.addVariable(var, configurationDescription);
}
use of org.eclipse.cdt.core.envvar.EnvironmentVariable in project arduino-eclipse-plugin by Sloeber.
the class Shared method applyKnownWorkArounds.
/*
* For some boards that do not run out of the box we know how to fix it. This
* code fixes these things
*/
public static void applyKnownWorkArounds() {
/*
* for chipkit PONTECH UAV100 board boards.txt contains
* usbono_pic32.compiler.c.extra_flags=-G1024 -Danything=1 and platform.txt
* contains ... {compiler.define} "{compiler.cpp.extra_flags}"
* {build.extra_flags} ... resulting in ... "-G1024 -Danything=1" ... Arduino
* IDE magically makes this ... "-G1024" -Danything=1 ... But I refuse to do
* this type of smart parsing because modifying text files is lots easier
* therefore as a workaround I replace "{compiler.cpp.extra_flags}" in
* platform.txt with {compiler.cpp.extra_flags}
*/
java.nio.file.Path packageRoot = Paths.get(ConfigurationPreferences.getInstallationPathPackages().toOSString());
java.nio.file.Path platform_txt = packageRoot.resolve("chipKIT").resolve("hardware").resolve("pic32").resolve("2.0.1").resolve("platform.txt");
if (platform_txt.toFile().exists()) {
FileModifiers.replaceInFile(platform_txt.toFile(), false, "\"{compiler.cpp.extra_flags}\"", "{compiler.cpp.extra_flags}");
}
/*
* oak on windows does not come with all required libraries and assumes arduino
* IDE has them available So I set sloeber_path_extension to the teensy root
*
*/
if (SystemUtils.IS_OS_WINDOWS) {
java.nio.file.Path arduinoIDERoot = Paths.get(MySystem.getTeensyPlatform());
if (arduinoIDERoot.toFile().exists()) {
try {
// /cater for null pointer
arduinoIDERoot = arduinoIDERoot.getParent().getParent();
IEnvironmentVariable var = new EnvironmentVariable("sloeber_path_extension", arduinoIDERoot.toString());
IEclipsePreferences myScope = InstanceScope.INSTANCE.getNode("org.eclipse.cdt.core");
Preferences t = myScope.node("environment").node("workspace").node(var.getName().toUpperCase());
t.put("delimiter", var.getDelimiter());
t.put("operation", "append");
t.put("value", var.getValue());
myScope.flush();
} catch (Exception e) {
e.printStackTrace();
}
}
}
/*
* oak on linux comes with a esptool2 in a wrong folder.
* As it is only 1 file I move the file
*
*/
if (SystemUtils.IS_OS_LINUX) {
java.nio.file.Path esptool2root = packageRoot.resolve("digistump").resolve("tools").resolve("esptool2").resolve("0.9.1");
java.nio.file.Path esptool2wrong = esptool2root.resolve("0.9.1").resolve("esptool2");
java.nio.file.Path esptool2right = esptool2root.resolve("esptool2");
if (esptool2wrong.toFile().exists()) {
try {
Files.move(esptool2wrong, esptool2right);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
/*
* Elector heeft core Platino maar de directory noemt platino.
* In windows geen probleem maar in case sensitive linux dus wel
*/
if (SystemUtils.IS_OS_LINUX) {
java.nio.file.Path cores = packageRoot.resolve("Elektor").resolve("hardware").resolve("avr").resolve("1.0.0").resolve("cores");
java.nio.file.Path coreWrong = cores.resolve("platino");
java.nio.file.Path coreGood = cores.resolve("Platino");
if (coreWrong.toFile().exists()) {
coreWrong.toFile().renameTo(coreGood.toFile());
}
}
}
Aggregations