|
5 | 5 | import it.baeyens.arduino.tools.ArduinoHelpers;
|
6 | 6 | import it.baeyens.arduino.tools.ArduinoLibraries;
|
7 | 7 |
|
8 |
| -import org.eclipse.cdt.core.CCorePlugin; |
9 |
| -import org.eclipse.cdt.core.envvar.IContributedEnvironment; |
10 |
| -import org.eclipse.cdt.core.envvar.IEnvironmentVariable; |
11 |
| -import org.eclipse.cdt.core.envvar.IEnvironmentVariableManager; |
12 | 8 | import org.eclipse.cdt.core.settings.model.CProjectDescriptionEvent;
|
13 | 9 | import org.eclipse.cdt.core.settings.model.ICProjectDescription;
|
14 | 10 | import org.eclipse.cdt.core.settings.model.ICProjectDescriptionListener;
|
15 |
| -import org.eclipse.core.runtime.CoreException; |
16 |
| -import org.eclipse.core.runtime.IPath; |
17 | 11 | import org.eclipse.core.runtime.IStatus;
|
18 |
| -import org.eclipse.core.runtime.Path; |
19 | 12 | import org.eclipse.core.runtime.Status;
|
20 | 13 |
|
21 | 14 | public class ConfigurationChangeListener implements ICProjectDescriptionListener {
|
22 | 15 |
|
23 | 16 | @Override
|
24 | 17 | public void handleEvent(CProjectDescriptionEvent event) {
|
25 | 18 | // we are only interested in about to apply
|
26 |
| - if (event.getEventType() != CProjectDescriptionEvent.ABOUT_TO_APPLY) |
27 |
| - return; |
| 19 | + // if (event.getEventType() != CProjectDescriptionEvent.ABOUT_TO_APPLY) |
| 20 | + // return; |
| 21 | + // if (true) |
| 22 | + // return; |
28 | 23 | ICProjectDescription projDesc = event.getNewCProjectDescription();
|
29 |
| - IEnvironmentVariableManager envManager = CCorePlugin.getDefault().getBuildEnvironmentManager(); |
30 |
| - IContributedEnvironment contribEnv = envManager.getContributedEnvironment(); |
| 24 | + |
31 | 25 | if (projDesc.getActiveConfiguration() != null) {
|
32 |
| - IEnvironmentVariable var = contribEnv.getVariable(ArduinoConst.ENV_KEY_JANTJE_PLATFORM_FILE, projDesc.getActiveConfiguration()); |
33 |
| - if (var != null) { |
34 |
| - IPath platformPath = new Path(var.getValue()); |
35 |
| - ArduinoHelpers.setProjectPathVariables(projDesc.getProject(), platformPath.removeLastSegments(1)); |
36 |
| - ArduinoHelpers.setTheEnvironmentVariables(projDesc.getProject(), projDesc.getActiveConfiguration(), false); |
37 |
| - try { |
38 |
| - ArduinoHelpers.addArduinoCodeToProject(projDesc.getProject(), projDesc.getActiveConfiguration()); |
39 |
| - } catch (CoreException e1) { |
40 |
| - Common.log(new Status(IStatus.ERROR, ArduinoConst.CORE_PLUGIN_ID, "Error adding the arduino code", e1)); |
41 |
| - } |
42 |
| - ArduinoLibraries.reAttachLibrariesToProject(projDesc.getActiveConfiguration()); |
| 26 | + |
| 27 | + ArduinoHelpers.setTheEnvironmentVariables(projDesc.getProject(), projDesc.getActiveConfiguration(), false); |
| 28 | + ArduinoHelpers.setProjectPathVariables(projDesc.getActiveConfiguration()); |
| 29 | + // try { |
| 30 | + try { |
| 31 | + ArduinoHelpers.addArduinoCodeToProject(projDesc.getProject(), projDesc.getActiveConfiguration()); |
| 32 | + } catch (Exception e) { |
| 33 | + Common.log(new Status(IStatus.WARNING, ArduinoConst.CORE_PLUGIN_ID, "failed to add include folder", e)); |
43 | 34 | }
|
| 35 | + // } catch (CoreException e1) { |
| 36 | + // Common.log(new Status(IStatus.ERROR, ArduinoConst.CORE_PLUGIN_ID, "Error adding the arduino code", e1)); |
| 37 | + // } |
| 38 | + ArduinoLibraries.reAttachLibrariesToProject(projDesc.getActiveConfiguration()); |
44 | 39 | }
|
45 | 40 | }
|
46 | 41 |
|
|
0 commit comments