// Add the Arduino folder
ArduinoHelpers.createNewFolder(project, "arduino", null);
// Set the environment variables
ICProjectDescription prjDesc = CoreModel.getDefault().getProjectDescription(project);
for (int i = 0; i < cfgNamesAndTCIds.size(); i++) {
ICConfigurationDescription configurationDescription = prjDesc.getConfigurationByName(cfgNamesAndTCIds.get(i).Name);
mArduinoPage.saveAllSelections(configurationDescription);
ArduinoHelpers.setTheEnvironmentVariables(project, configurationDescription, cfgNamesAndTCIds.get(i).DebugCompilerSettings);
}
// Set the path variables
ArduinoHelpers.setProjectPathVariables(project, mArduinoPage.getPlatformFolder());
// Intermediately save or the adding code will fail
// Release is the active config (as that is the "IDE" Arduino type....)
ICConfigurationDescription defaultConfigDescription = prjDesc.getConfigurationByName(cfgNamesAndTCIds.get(0).Name);
prjDesc.setActiveConfiguration(defaultConfigDescription);
// Insert The Arduino Code
// NOTE: Not duplicated for debug (the release reference is just to get at some environment variables)
ArduinoHelpers.addArduinoCodeToProject(project, defaultConfigDescription);
//
// add the correct files to the project
//
mNewArduinoSketchWizardCodeSelectionPage.createFiles(project, monitor);
//
// add the libraries to the project if needed
//
mNewArduinoSketchWizardCodeSelectionPage.importLibraries(project, prjDesc.getConfigurations());
ICResourceDescription cfgd = defaultConfigDescription.getResourceDescription(new Path(""), true);
ICExclusionPatternPathEntry[] entries = cfgd.getConfiguration().getSourceEntries();
if (entries.length == 1) {
Path exclusionPath[] = new Path[2];
exclusionPath[0] = new Path("Libraries/*/?xamples");
exclusionPath[1] = new Path("Libraries/*/?xtras");
ICExclusionPatternPathEntry newSourceEntry = new CSourceEntry(entries[0].getFullPath(), exclusionPath,
ICSettingEntry.VALUE_WORKSPACE_PATH);
ICSourceEntry[] out = null;
out = new ICSourceEntry[1];
out[0] = (ICSourceEntry) newSourceEntry;
try {
cfgd.getConfiguration().setSourceEntries(out);
} catch (CoreException e) {
// ignore
}
} else {
// this should not happen
}
// set warning levels default on
IEnvironmentVariableManager envManager = CCorePlugin.getDefault().getBuildEnvironmentManager();
IContributedEnvironment contribEnv = envManager.getContributedEnvironment();
IEnvironmentVariable var = new EnvironmentVariable(ArduinoConst.ENV_KEY_JANTJE_WARNING_LEVEL, ArduinoConst.ENV_KEY_WARNING_LEVEL_ON);
contribEnv.addVariable(var, cfgd.getConfiguration());
prjDesc.setActiveConfiguration(defaultConfigDescription);
prjDesc.setCdtProjectCreated();
CoreModel.getDefault().getProjectDescriptionManager().setProjectDescription(project, prjDesc, true, null);
monitor.done();
} catch (CoreException e) {
Common.log(new Status(IStatus.ERROR, ArduinoConst.CORE_PLUGIN_ID, "Failed to create project " + project.getName(), e));