use of io.sloeber.core.api.CompileOptions in project arduino-eclipse-plugin by Sloeber.
the class RegressionTest method are_defines_before_includes_taken_into_account.
/**
* If a .ino file is including a include using extern C is this handled
* properly by the ino to cpp parser
* @throws Exception
*/
@SuppressWarnings("static-method")
@Test
public void are_defines_before_includes_taken_into_account() throws Exception {
PackageManager.installLatestPlatform("package_index.json", "arduino", "Arduino AVR Boards");
Map<String, String> unoOptions = new HashMap<>();
BoardDescriptor unoBoardid = PackageManager.getBoardDescriptor("package_index.json", "arduino", "Arduino AVR Boards", "uno", unoOptions);
IProject theTestProject = null;
String projectName = "externc";
IPath templateFolder = Shared.getTemplateFolder(projectName);
CodeDescriptor codeDescriptor = CodeDescriptor.createCustomTemplate(templateFolder);
NullProgressMonitor monitor = new NullProgressMonitor();
try {
theTestProject = unoBoardid.createProject(projectName, null, ConfigurationDescriptor.getDefaultDescriptors(), codeDescriptor, new CompileOptions(null), monitor);
// for the indexer
Shared.waitForAllJobsToFinish();
theTestProject.build(IncrementalProjectBuilder.FULL_BUILD, monitor);
if (Shared.hasBuildErrors(theTestProject)) {
fail("Failed to compile the project:" + projectName + " extern \"C\" has not been taken into account properly.");
}
} catch (Exception e) {
e.printStackTrace();
fail("Failed to create the project:" + projectName);
return;
}
}
use of io.sloeber.core.api.CompileOptions in project arduino-eclipse-plugin by Sloeber.
the class RegressionTest method issue555.
/**
* make sure when switching between a board with variant file and without
* the build still succeeds
*/
@SuppressWarnings("static-method")
@Test
public void issue555() {
if (MySystem.getTeensyPlatform().isEmpty()) {
// do not fail as this will always fail on travis
return;
}
Map<String, String> unoOptions = new HashMap<>();
BoardDescriptor unoBoardid = PackageManager.getBoardDescriptor("package_index.json", "arduino", "Arduino AVR Boards", "uno", unoOptions);
Map<String, String> teensyOptions = new HashMap<>();
teensyOptions.put("usb", "serial");
teensyOptions.put("speed", "96");
teensyOptions.put("keys", "en-us");
BoardDescriptor teensyBoardid = PackageManager.getBoardDescriptor("local", MySystem.getTeensyBoard_txt(), "", "teensy31", teensyOptions);
IProject theTestProject = null;
CodeDescriptor codeDescriptor = CodeDescriptor.createDefaultIno();
String projectName = "issue555";
NullProgressMonitor monitor = new NullProgressMonitor();
try {
theTestProject = unoBoardid.createProject(projectName, null, ConfigurationDescriptor.getDefaultDescriptors(), codeDescriptor, new CompileOptions(null), monitor);
// for the indexer
Shared.waitForAllJobsToFinish();
} catch (Exception e) {
e.printStackTrace();
fail("Failed to create the project:" + projectName);
return;
}
try {
theTestProject.build(IncrementalProjectBuilder.FULL_BUILD, monitor);
if (Shared.hasBuildErrors(theTestProject)) {
fail("Failed to compile the project:" + projectName + " as teensy build errors");
}
} catch (CoreException e) {
e.printStackTrace();
fail("Failed to compile the project:" + unoBoardid.getBoardName() + " as uno exception");
}
teensyBoardid.configureProject(theTestProject, monitor);
Shared.waitForAllJobsToFinish();
try {
theTestProject.build(IncrementalProjectBuilder.FULL_BUILD, monitor);
if (Shared.hasBuildErrors(theTestProject)) {
fail("Failed to compile the project:" + projectName + " as teensy");
}
} catch (CoreException e) {
e.printStackTrace();
fail("Failed to compile the project:" + unoBoardid.getBoardName() + " as teensy exception");
}
}
use of io.sloeber.core.api.CompileOptions in project arduino-eclipse-plugin by Sloeber.
the class Shared method BuildAndVerify.
public static void BuildAndVerify(BoardDescriptor boardid, CodeDescriptor codeDescriptor) {
IProject theTestProject = null;
NullProgressMonitor monitor = new NullProgressMonitor();
String projectName = String.format("%03d_", new Integer(mBuildCounter++)) + boardid.getBoardID();
try {
theTestProject = boardid.createProject(projectName, null, ConfigurationDescriptor.getDefaultDescriptors(), codeDescriptor, new CompileOptions(null), monitor);
// for the indexer
Shared.waitForAllJobsToFinish();
} catch (Exception e) {
e.printStackTrace();
fail("Failed to create the project:" + projectName);
return;
}
try {
theTestProject.build(IncrementalProjectBuilder.FULL_BUILD, monitor);
if (Shared.hasBuildErrors(theTestProject)) {
fail("Failed to compile the project:" + projectName + " build errors");
}
} catch (CoreException e) {
e.printStackTrace();
fail("Failed to compile the project:" + boardid.getBoardName() + " exception");
}
try {
theTestProject.delete(false, true, null);
} catch (CoreException e) {
e.printStackTrace();
}
}
use of io.sloeber.core.api.CompileOptions in project arduino-eclipse-plugin by Sloeber.
the class Helpers method setTheEnvironmentVariablesPostProcessing.
/**
* Following post processing is done
*
* CDT uses different keys to identify the input and output files then the
* arduino recipes. Therefore I split the arduino recipes into parts (based on
* the arduino keys) and connect them again in the plugin.xml using the CDT
* keys. This code assumes that the command is in following order ${first part}
* ${files} ${second part} [${ARCHIVE_FILE} ${third part}] with [optional]
*
* Secondly The handling of the upload variables is done differently in arduino
* than here. This is taken care of here. for example the output of this input
* tools.avrdude.upload.pattern="{cmd.path}" "-C{config.path}" {upload.verbose}
* is changed as if it were the output of this input
* tools.avrdude.upload.pattern="{tools.avrdude.cmd.path}"
* "-C{tools.avrdude.config.path}" {tools.avrdude.upload.verbose}
*
* thirdly if a programmer is selected different from default some extra actions
* are done here so no special code is needed to handle programmers
*
* Fourthly The build path for the core is {BUILD.PATH}/core/core in sloeber
* where it is {BUILD.PATH}/core/ in arduino world and used to be {BUILD.PATH}/
* This only gives problems in the link command as sometimes there are hardcoded
* links to some sys files so ${A.BUILD.PATH}/core/sys* ${A.BUILD.PATH}/sys* is
* replaced with ${A.BUILD.PATH}/core/core/sys*
*
* @param contribEnv
* @param confDesc
* @param boardsDescriptor
*/
private static void setTheEnvironmentVariablesPostProcessing(IContributedEnvironment contribEnv, ICConfigurationDescription confDesc, InternalBoardDescriptor boardsDescriptor) {
CompileOptions compileOptions = new CompileOptions(confDesc);
// a save will overwrite the warning settings set by arduino
compileOptions.save(confDesc);
String[] actions = { ACTION_C_to_O, ACTION_CPP_to_O, ACTION_S_to_O, ACTION_OBJCOPY_to_HEX, ACTION_OBJCOPY_to_EEP, ACTION_SIZE, ACTION_AR, ACTION_C_COMBINE };
for (String action : actions) {
String recipeKey = get_ENV_KEY_RECIPE(action);
String recipe = getBuildEnvironmentVariable(confDesc, recipeKey, new String(), false);
recipe = recipe.replace("-DARDUINO_BSP_VERSION=\"${A.VERSION}\"", "\"-DARDUINO_BSP_VERSION=\\\"${A.VERSION}\\\"\"");
if (ACTION_C_COMBINE.equals(action)) {
recipe = recipe.replace("${A.BUILD.PATH}/core/sys", "${A.BUILD.PATH}/core/core/sys");
recipe = recipe.replace("${A.BUILD.PATH}/sys", "${A.BUILD.PATH}/core/core/sys");
setBuildEnvironmentVariable(contribEnv, confDesc, recipeKey, recipe);
}
String[] recipeParts = recipe.split("(\"\\$\\{A.OBJECT_FILE}\")|(\\$\\{A.OBJECT_FILES})|(\"\\$\\{A.SOURCE_FILE}\")|(\"[^\"]*\\$\\{A.ARCHIVE_FILE}\")|(\"[^\"]*\\$\\{A.ARCHIVE_FILE_PATH}\")", 3);
switch(recipeParts.length) {
case 0:
setBuildEnvironmentVariable(contribEnv, confDesc, recipeKey + DOT + '1', Messages.Helpers_No_command_for + recipeKey);
break;
case 1:
setBuildEnvironmentVariable(contribEnv, confDesc, recipeKey + DOT + '1', recipeParts[0]);
break;
case 2:
setBuildEnvironmentVariable(contribEnv, confDesc, recipeKey + DOT + '1', recipeParts[0]);
setBuildEnvironmentVariable(contribEnv, confDesc, recipeKey + DOT + '2', recipeParts[1]);
break;
case 3:
setBuildEnvironmentVariable(contribEnv, confDesc, recipeKey + DOT + '1', recipeParts[0]);
setBuildEnvironmentVariable(contribEnv, confDesc, recipeKey + DOT + '2', recipeParts[1]);
setBuildEnvironmentVariable(contribEnv, confDesc, recipeKey + DOT + '3', recipeParts[2]);
break;
default:
}
}
String programmer = boardsDescriptor.getProgrammer();
if (programmer.equalsIgnoreCase(Defaults.getDefaultUploadProtocol())) {
String MComPort = boardsDescriptor.getUploadPort();
if (MComPort.isEmpty()) {
Common.log(new Status(IStatus.WARNING, Const.CORE_PLUGIN_ID, "Upload will fail due to missing upload port"));
}
}
ArrayList<String> objcopyCommand = new ArrayList<>();
// I'm looping through the set of variables to fix some things up
try {
IEnvironmentVariable[] curVariables = contribEnv.getVariables(confDesc);
for (IEnvironmentVariable curVariable : curVariables) {
String name = curVariable.getName();
// FQN
if (name.startsWith("A.TOOLS.")) {
String toolID = curVariable.getName().split("\\.")[2];
String recipe = curVariable.getValue();
int indexOfVar = recipe.indexOf("${A.");
while (indexOfVar != -1) {
int endIndexOfVar = recipe.indexOf('}', indexOfVar);
if (endIndexOfVar != -1) {
String foundSuffix = recipe.substring(indexOfVar + 3, endIndexOfVar);
String foundVar = "A" + foundSuffix;
String replaceVar = "A.TOOLS." + toolID.toUpperCase() + foundSuffix;
if (contribEnv.getVariable(foundVar, confDesc) == null) {
// $NON-NLS-1$
recipe = recipe.replaceAll(foundVar, replaceVar);
}
}
indexOfVar = recipe.indexOf("${A.", indexOfVar + 4);
}
setBuildEnvironmentVariable(contribEnv, confDesc, name, recipe);
}
if (name.startsWith("A.RECIPE.OBJCOPY.") && name.endsWith(".PATTERN") && !curVariable.getValue().isEmpty()) {
objcopyCommand.add(makeEnvironmentVar(name));
}
// Handle spaces in defines for USB stuff in windows
if (Platform.getOS().equals(Platform.OS_WIN32)) {
if ("A.BUILD.USB_MANUFACTURER".equalsIgnoreCase(name)) {
String moddedValue = curVariable.getValue().replace("\"", "\\\"");
setBuildEnvironmentVariable(contribEnv, confDesc, name, moddedValue);
}
if ("A.BUILD.USB_PRODUCT".equalsIgnoreCase(name)) {
String moddedValue = curVariable.getValue().replace("\"", "\\\"");
setBuildEnvironmentVariable(contribEnv, confDesc, name, moddedValue);
}
if ("A.BUILD.USB_FLAGS".equalsIgnoreCase(name)) {
String moddedValue = curVariable.getValue().replace("'", "\"");
setBuildEnvironmentVariable(contribEnv, confDesc, name, moddedValue);
}
if ("A.BUILD.EXTRA_FLAGS".equalsIgnoreCase(name)) {
// for radino
// radinoCC1101.build.extra_flags=-DUSB_VID={build.vid} -DUSB_PID={build.pid} '-DUSB_PRODUCT={build.usb_product}'
String moddedValue = curVariable.getValue().replace("'-DUSB_PRODUCT=${A.BUILD.USB_PRODUCT}'", "\"-DUSB_PRODUCT=${A.BUILD.USB_PRODUCT}\"");
setBuildEnvironmentVariable(contribEnv, confDesc, name, moddedValue);
}
}
}
} catch (Exception e) {
Common.log(new Status(IStatus.WARNING, Const.CORE_PLUGIN_ID, "parsing of upload recipe failed", e));
}
Collections.sort(objcopyCommand);
setBuildEnvironmentVariable(contribEnv, confDesc, "JANTJE.OBJCOPY", StringUtil.join(objcopyCommand, "\n\t"));
}
use of io.sloeber.core.api.CompileOptions in project arduino-eclipse-plugin by Sloeber.
the class RegressionTest method issue687.
/**
* support void loop{};
* @throws Exception
*/
@SuppressWarnings("static-method")
@Test
public void issue687() throws Exception {
PackageManager.installLatestPlatform("package_index.json", "arduino", "Arduino AVR Boards");
Map<String, String> unoOptions = new HashMap<>();
BoardDescriptor unoBoardid = PackageManager.getBoardDescriptor("package_index.json", "arduino", "Arduino AVR Boards", "uno", unoOptions);
IProject theTestProject = null;
String projectName = "issue687";
IPath templateFolder = Shared.getTemplateFolder(projectName);
CodeDescriptor codeDescriptor = CodeDescriptor.createCustomTemplate(templateFolder);
try {
theTestProject = unoBoardid.createProject(projectName, null, ConfigurationDescriptor.getDefaultDescriptors(), codeDescriptor, new CompileOptions(null), new NullProgressMonitor());
// for the indexer
Shared.waitForAllJobsToFinish();
theTestProject.build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor());
if (Shared.hasBuildErrors(theTestProject)) {
fail("Failed to compile the project:" + projectName + " issue687 is not fixed");
}
} catch (Exception e) {
e.printStackTrace();
fail("Failed to create the project:" + projectName);
return;
}
}
Aggregations