use of org.eclipse.cdt.core.envvar.IEnvironmentVariable 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