Skip to content

Commit 769bdb4

Browse files
committed
Fixed the indexer bug
Fixed the delete of .hex (didn't delete) Fixed compilation did not occur.
1 parent 6d64fe5 commit 769bdb4

File tree

3 files changed

+76
-100
lines changed

3 files changed

+76
-100
lines changed

it.baeyens.arduino.core/src/it/baeyens/arduino/toolchain/hexNameProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ else if (command.indexOf(".bin") != -1)
2929
fileExtension = "bin";
3030

3131
IPath[] outputNames = new IPath[1];
32-
outputNames[0] = new Path(cConf.getName()).append(project.getName()).addFileExtension(fileExtension);
32+
outputNames[0] = new Path(project.getName()).addFileExtension(fileExtension);
3333
return outputNames;
3434
}
3535
}
Lines changed: 48 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
package it.baeyens.arduino.tools;
22

33
import org.eclipse.cdt.core.model.CoreModel;
4+
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
45
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
56
import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager;
7+
import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
68
import org.eclipse.cdt.managedbuilder.core.IBuilder;
7-
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
89
import org.eclipse.cdt.managedbuilder.core.IToolChain;
910
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
1011
import org.eclipse.cdt.managedbuilder.internal.core.Configuration;
1112
import org.eclipse.cdt.managedbuilder.internal.core.ManagedBuildInfo;
1213
import org.eclipse.cdt.managedbuilder.internal.core.ManagedProject;
1314
import org.eclipse.cdt.managedbuilder.internal.core.ToolChain;
15+
import org.eclipse.cdt.managedbuilder.internal.dataprovider.ConfigurationDataProvider;
1416
import org.eclipse.core.resources.IProject;
1517
import org.eclipse.core.runtime.CoreException;
1618
import org.eclipse.core.runtime.IProgressMonitor;
@@ -41,87 +43,67 @@ public class ShouldHaveBeenInCDT {
4143
* The monitor to follow the process
4244
* @throws CoreException
4345
*/
44-
public static void setCProjectDescription(IProject project,
45-
String sTCIds[], //sTCIds and sCfgs -- Need to be ordered the same and the same length
46-
String sCfgs[],
47-
boolean isManagedBuild,
48-
IProgressMonitor monitor) throws CoreException {
46+
public static void setCProjectDescription(IProject project, String sTCIds[], // sTCIds and sCfgs -- Need to be ordered the same and the same
47+
// length
48+
String sCfgs[], boolean isManagedBuild, IProgressMonitor monitor) throws CoreException {
4949

50-
<<<<<<< HEAD
5150
ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager();
5251
ICProjectDescription des = mngr.createProjectDescription(project, false, false);
5352
ManagedBuildInfo info = ManagedBuildManager.createBuildInfo(project);
5453
ManagedProject mProj = new ManagedProject(des);
5554
info.setManagedProject(mProj);
5655
monitor.worked(20);
5756

58-
String s = "it.baeyens.arduino.core.toolChain.release";
59-
IToolChain tcs = ManagedBuildManager.getExtensionToolChain(s);
60-
61-
Configuration cfg = new Configuration(mProj, (ToolChain) tcs, ManagedBuildManager.calculateChildId(s, null), configuration);
62-
IBuilder bld = cfg.getEditableBuilder();
63-
if (bld != null) {
64-
if (bld.isInternalBuilder()) {
65-
IConfiguration prefCfg = ManagedBuildManager.getPreferenceConfiguration(false);
66-
IBuilder prefBuilder = prefCfg.getBuilder();
67-
cfg.changeBuilder(prefBuilder, ManagedBuildManager.calculateChildId(cfg.getId(), null), prefBuilder.getName());
68-
bld = cfg.getEditableBuilder();
69-
bld.setBuildPath(null);
70-
}
71-
bld.setManagedBuildOn(isManagedBuild);
72-
} else {
73-
System.out.println("Messages.StdProjectTypeHandler_3");
74-
}
75-
cfg.setArtifactName(mProj.getDefaultArtifactName());
57+
// String s = "it.baeyens.arduino.core.toolChain.release";
58+
// IToolChain tcs = ManagedBuildManager.getExtensionToolChain(s);
59+
//
60+
// Configuration cfg = new Configuration(mProj, (ToolChain) tcs, ManagedBuildManager.calculateChildId(s, null), "Release");
61+
// IBuilder bld = cfg.getEditableBuilder();
62+
// if (bld != null) {
63+
// if (bld.isInternalBuilder()) {
64+
// IConfiguration prefCfg = ManagedBuildManager.getPreferenceConfiguration(false);
65+
// IBuilder prefBuilder = prefCfg.getBuilder();
66+
// cfg.changeBuilder(prefBuilder, ManagedBuildManager.calculateChildId(cfg.getId(), null), prefBuilder.getName());
67+
// bld = cfg.getEditableBuilder();
68+
// bld.setBuildPath(null);
69+
// }
70+
// bld.setManagedBuildOn(isManagedBuild);
71+
// } else {
72+
// System.out.println("Messages.StdProjectTypeHandler_3");
73+
// }
74+
// cfg.setArtifactName(mProj.getDefaultArtifactName());
7675
// CConfigurationData data = cfg.getConfigurationData();
7776
// ICConfigurationDescription cfgDes = des.createConfiguration(ManagedBuildManager.CFG_DATA_PROVIDER_ID, data);
78-
77+
//
7978
// ConfigurationDataProvider.setDefaultLanguageSettingsProviders(project, cfg, cfgDes);
8079

81-
// BK - 2013.10.18
82-
// creates/add the configuration to the project description
83-
// des.createConfiguration(ManagedBuildManager.CFG_DATA_PROVIDER_ID, cfg.getConfigurationData());
80+
// Iterate across the configurations
81+
for (int i = 0; i < Math.min(sTCIds.length, sCfgs.length); i++) {
82+
IToolChain tcs = ManagedBuildManager.getExtensionToolChain(sTCIds[i]);
8483

84+
Configuration cfg = new Configuration(mProj, (ToolChain) tcs, ManagedBuildManager.calculateChildId(sTCIds[i], null), sCfgs[i]);
85+
IBuilder bld = cfg.getEditableBuilder();
86+
if (bld != null) {
87+
// if (bld.isInternalBuilder()) {
88+
// IConfiguration prefCfg = ManagedBuildManager.getPreferenceConfiguration(false);
89+
// IBuilder prefBuilder = prefCfg.getBuilder();
90+
// String name = prefBuilder.getName();
91+
// cfg.changeBuilder(prefBuilder, ManagedBuildManager.calculateChildId(cfg.getId(), null), name);
92+
// bld = cfg.getEditableBuilder();
93+
// bld.setBuildPath(null);
94+
// }
95+
bld.setManagedBuildOn(isManagedBuild);
96+
cfg.setArtifactName("${ProjName}");
97+
} else {
98+
System.out.println("Messages.StdProjectTypeHandler_3");
99+
}
100+
CConfigurationData data = cfg.getConfigurationData();
101+
ICConfigurationDescription cfgDes = des.createConfiguration(ManagedBuildManager.CFG_DATA_PROVIDER_ID, data);
102+
ConfigurationDataProvider.setDefaultLanguageSettingsProviders(project, cfg, cfgDes);
103+
}
85104
monitor.worked(50);
86105
mngr.setProjectDescription(project, des);
87106

88-
=======
89-
ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager();
90-
ICProjectDescription des = mngr.createProjectDescription(project, false, false);
91-
ManagedBuildInfo info = ManagedBuildManager.createBuildInfo(project);
92-
ManagedProject mProj = new ManagedProject(des);
93-
info.setManagedProject(mProj);
94-
monitor.worked(20);
95-
96-
//Iterate across the configurations
97-
for(int i = 0; i < Math.min(sTCIds.length, sCfgs.length); i++)
98-
{
99-
IToolChain tcs = ManagedBuildManager.getExtensionToolChain( sTCIds[i] );
100-
101-
Configuration cfg = new Configuration(mProj, (ToolChain) tcs, ManagedBuildManager.calculateChildId(sTCIds[i], null), sCfgs[i]);
102-
IBuilder bld = cfg.getEditableBuilder();
103-
if (bld != null) {
104-
if (bld.isInternalBuilder()) {
105-
IConfiguration prefCfg = ManagedBuildManager.getPreferenceConfiguration(false);
106-
IBuilder prefBuilder = prefCfg.getBuilder();
107-
cfg.changeBuilder(prefBuilder, ManagedBuildManager.calculateChildId(cfg.getId(), null), prefBuilder.getName());
108-
bld = cfg.getEditableBuilder();
109-
bld.setBuildPath(null);
110-
}
111-
bld.setManagedBuildOn(isManagedBuild);
112-
} else {
113-
System.out.println("Messages.StdProjectTypeHandler_3");
114-
}
115-
116-
cfg.setArtifactName(mProj.getDefaultArtifactName());
117-
118-
//BK - 2013.10.18
119-
// creates/add the configuration to the project description
120-
des.createConfiguration(ManagedBuildManager.CFG_DATA_PROVIDER_ID, cfg.getConfigurationData());
121-
}
122-
monitor.worked(50);
123-
mngr.setProjectDescription(project, des);
124-
>>>>>>> 4cbef47052e0da99c097e164594f614f1b8bc5f7
125107
}
126108

127109
}

it.baeyens.arduino.core/src/it/baeyens/arduino/ui/NewArduinoSketchWizard.java

Lines changed: 27 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import org.eclipse.cdt.core.settings.model.ICResourceDescription;
2020
import org.eclipse.cdt.core.settings.model.ICSettingEntry;
2121
import org.eclipse.cdt.core.settings.model.ICSourceEntry;
22-
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
2322
import org.eclipse.core.resources.IContainer;
2423
import org.eclipse.core.resources.IProject;
2524
import org.eclipse.core.resources.IProjectDescription;
@@ -152,13 +151,19 @@ void createProject(IProjectDescription description, IProject project, IProgressM
152151
project.open(IResource.BACKGROUND_REFRESH, new SubProgressMonitor(monitor, 1000));
153152
IContainer container = project;
154153

155-
//TODO: Consider renaming Release to ArduinoIDEConfig
156-
//TODO: Consider renaming Debug to DragonAVR
157-
//Debug has same toolchain as release
158-
String sCfgs[] = {"Release", "Debug"};
159-
String sTCIds[] = {"it.baeyens.arduino.core.toolChain.release",
160-
"it.baeyens.arduino.core.toolChain.release"};
161-
154+
// String s = "it.baeyens.arduino.core.toolChain.release";
155+
// ShouldHaveBeenInCDT.setCProjectDescription(project, ManagedBuildManager.getExtensionToolChain(s), "Release", true, monitor);
156+
// this creates the .cproject file
157+
158+
// TODO: Consider renaming Release to ArduinoIDEConfig JABA:I don't think his is a good idea "standard" or "arduino" may be better
159+
// Note that changing Release invalidates all existing workspaces. So if we change this timing will be very important.
160+
// TODO: Consider renaming Debug to DragonAVR JABA:I think his is a viable idea
161+
// Debug has same toolchain as release
162+
String sCfgs[] = { "Release", "Debug" };
163+
String sTCIds[] = { "it.baeyens.arduino.core.toolChain.release", "it.baeyens.arduino.core.toolChain.release" };
164+
// String sCfgs[] = { "Release" };
165+
// String sTCIds[] = { "it.baeyens.arduino.core.toolChain.release" };
166+
162167
// Creates the .cproject file with the configurations
163168
ShouldHaveBeenInCDT.setCProjectDescription(project, sTCIds, sCfgs, true, monitor);
164169

@@ -171,43 +176,33 @@ void createProject(IProjectDescription description, IProject project, IProgressM
171176
// Set the environment variables
172177
ICProjectDescription prjDesc = CoreModel.getDefault().getProjectDescription(project);
173178

174-
//We don't iterate on the configs. Behaviour is a little custom for each.
175-
//Release
176-
ICConfigurationDescription configurationDescriptionRel = prjDesc
177-
.getConfigurationByName( sCfgs[0] );
178-
mArduinoPage.saveAllSelections(configurationDescriptionRel);
179-
ArduinoHelpers.setTheEnvironmentVariables(project,
180-
configurationDescriptionRel, false);
181-
182-
//Debug
183-
ICConfigurationDescription configurationDescriptionDbg = prjDesc
184-
.getConfigurationByName( sCfgs[1] );
185-
mArduinoPage.saveAllSelections(configurationDescriptionDbg);
186-
//The last boolean indicates to set debug settings in the compilation
187-
ArduinoHelpers.setTheEnvironmentVariables(project,
188-
configurationDescriptionDbg, true);
179+
for (int i = 0; i < Math.min(sTCIds.length, sCfgs.length); i++) {
180+
ICConfigurationDescription configurationDescriptionRel = prjDesc.getConfigurationByName(sCfgs[i]);
181+
mArduinoPage.saveAllSelections(configurationDescriptionRel);
182+
ArduinoHelpers.setTheEnvironmentVariables(project, configurationDescriptionRel, sCfgs.equals("Debug"));
183+
}
189184

190185
// Set the path variables
191186
IPath platformPath = new Path(new File(mArduinoPage.mPageLayout.mControlBoardsTxtFile.getText().trim()).getParent())
192187
.append(ArduinoConst.PLATFORM_FILE_NAME);
193188
ArduinoHelpers.setProjectPathVariables(project, platformPath.removeLastSegments(1));
194189

195-
//Intermediately save or the adding code will fail
196-
//Release is the active config (as that is the "IDE" Arduino type....)
197-
prjDesc.setActiveConfiguration(configurationDescriptionRel);
190+
// Intermediately save or the adding code will fail
191+
// Release is the active config (as that is the "IDE" Arduino type....)
192+
ICConfigurationDescription defaultConfigDescription = prjDesc.getConfigurationByName(sCfgs[0]);
193+
prjDesc.setActiveConfiguration(defaultConfigDescription);
198194

199195
// Insert The Arduino Code
200-
//NOTE: Not duplicated for debug (the release reference is just to get at some environment variables)
201-
ArduinoHelpers.addArduinoCodeToProject(project, configurationDescriptionRel);
202-
196+
// NOTE: Not duplicated for debug (the release reference is just to get at some environment variables)
197+
ArduinoHelpers.addArduinoCodeToProject(project, defaultConfigDescription);
203198

204199
/* Add the sketch source code file */
205200
ArduinoHelpers.addFileToProject(container, new Path(project.getName() + ".cpp"),
206201
Stream.openContentStream(project.getName(), "", "templates/sketch.cpp"), monitor);
207202

208203
/* Add the sketch header file */
209204
String Include = "WProgram.h";
210-
if (ArduinoInstancePreferences.isArduinoIdeOne()) //Arduino v1.0+
205+
if (ArduinoInstancePreferences.isArduinoIdeOne()) // Arduino v1.0+
211206
{
212207
Include = "Arduino.h";
213208
}
@@ -232,8 +227,7 @@ void createProject(IProjectDescription description, IProject project, IProgressM
232227
// .createResourceConfiguration(file);
233228
// ResConfig.setExclude(true);
234229

235-
236-
ICResourceDescription cfgd = configurationDescriptionRel.getResourceDescription(new Path(""), true);
230+
ICResourceDescription cfgd = defaultConfigDescription.getResourceDescription(new Path(""), true);
237231
ICExclusionPatternPathEntry[] entries = cfgd.getConfiguration().getSourceEntries();
238232
if (entries.length == 1) {
239233
Path exclusionPath[] = new Path[1];
@@ -269,7 +263,7 @@ void createProject(IProjectDescription description, IProject project, IProgressM
269263
// }
270264
// }
271265

272-
prjDesc.setActiveConfiguration(configurationDescriptionRel);
266+
prjDesc.setActiveConfiguration(defaultConfigDescription);
273267
prjDesc.setCdtProjectCreated();
274268
CoreModel.getDefault().getProjectDescriptionManager().setProjectDescription(project, prjDesc, true, null);
275269
monitor.done();

0 commit comments

Comments
 (0)