16
16
import org .eclipse .cdt .core .settings .model .ICProjectDescription ;
17
17
import org .eclipse .cdt .core .settings .model .ICSettingEntry ;
18
18
import org .eclipse .cdt .core .settings .model .ICSourceEntry ;
19
- import org .eclipse .cdt .core .settings .model .util .CDataUtil ;
20
19
import org .eclipse .core .resources .IFile ;
21
20
import org .eclipse .core .resources .IFolder ;
22
21
import org .eclipse .core .resources .IProject ;
43
42
import io .sloeber .autoBuild .helpers .api .KeyValueTree ;
44
43
import io .sloeber .autoBuild .integration .AutoBuildConfigurationDescription ;
45
44
import io .sloeber .autoBuild .integration .AutoBuildManager ;
45
+ import io .sloeber .autoBuild .schema .api .IConfiguration ;
46
46
import io .sloeber .autoBuild .schema .api .IProjectType ;
47
47
import io .sloeber .core .Activator ;
48
48
import io .sloeber .core .internal .SloeberConfiguration ;
49
+ import io .sloeber .core .listeners .IndexerController ;
49
50
import io .sloeber .core .natures .SloeberNature ;
50
51
import io .sloeber .core .txt .TxtFile ;
51
52
@@ -84,10 +85,6 @@ public void run(IProgressMonitor internalMonitor) throws CoreException {
84
85
OldCoreFolder .delete (true , monitor );
85
86
}
86
87
87
- // IFile CdtDotFile = project.getFile(".cproject"); //$NON-NLS-1$
88
- // if(CdtDotFile.exists()) {
89
- // CdtDotFile.delete(true, monitor);
90
- // }
91
88
92
89
File sloeberDotFile = project .getFile (".sproject" ).getLocation ().toFile (); //$NON-NLS-1$
93
90
File sloeberCfgFile = project .getFile (SLOEBER_CFG ).getLocation ().toFile ();
@@ -104,6 +101,22 @@ public void run(IProgressMonitor internalMonitor) throws CoreException {
104
101
}
105
102
}
106
103
104
+ CCorePlugin cCorePlugin = CCorePlugin .getDefault ();
105
+ ICProjectDescription oldPrjCDesc = cCorePlugin .getProjectDescription (project , false );
106
+ Set <String >cfgNames =new HashSet <>();
107
+ for (ICConfigurationDescription curConfig : oldPrjCDesc .getConfigurations ()) {
108
+ cfgNames .add ( curConfig .getName ());
109
+ }
110
+
111
+
112
+ KeyValueTree oldConfigs =null ;
113
+ if (oldSloeberInfo != null ) {
114
+ oldConfigs = oldSloeberInfo .getData ().getChild ("Config" ); //$NON-NLS-1$
115
+ for (String curTree : oldConfigs .getChildren ().keySet ()) {
116
+ cfgNames .add (curTree );
117
+ }
118
+ }
119
+
107
120
String builderName = AutoBuildProject .INTERNAL_BUILDER_ID ;
108
121
IBuildTools buildTools = IBuildToolsManager .getDefault ().getBuildTools (SLOEBER_BUILD_TOOL_PROVIDER_ID ,
109
122
null );
@@ -114,46 +127,33 @@ public void run(IProgressMonitor internalMonitor) throws CoreException {
114
127
CCProjectNature .CC_NATURE_ID , codeProvider , buildTools , true , internalMonitor );
115
128
116
129
SloeberNature .addNature (project , internalMonitor );
117
-
118
- CCorePlugin cCorePlugin = CCorePlugin .getDefault ();
119
130
ICProjectDescription prjCDesc = cCorePlugin .getProjectDescription (project , true );
120
131
121
- Set <String >cfgNames =new HashSet <>();
122
- for (ICConfigurationDescription curConfig : prjCDesc .getConfigurations ()) {
123
- cfgNames .add ( curConfig .getName ());
124
- }
125
- KeyValueTree oldConfigs =null ;
126
- if (oldSloeberInfo != null ) {
127
- oldConfigs = oldSloeberInfo .getData ().getChild ("Config" ); //$NON-NLS-1$
128
- for (String curTree : oldConfigs .getChildren ().keySet ()) {
129
- cfgNames .add (curTree );
130
- }
131
- }
132
+
133
+ IConfiguration defaultConfig = projectType .getConfigurations ()[0 ];
132
134
for (String cfgName :cfgNames ) {
133
135
KeyValueTree oldConfig =null ;
134
136
if (oldConfigs != null ) {
135
137
oldConfig = oldConfigs .getChild (cfgName );
136
138
}
137
- //get the CDT config and AutoBuildConfigurationDescription (if it does not exist create it)
138
- ICConfigurationDescription curConfig = prjCDesc .getConfigurationByName (cfgName );
139
- if (curConfig ==null ) {
140
- //config does not exists so create it
141
- String id = CDataUtil .genId (Activator .getId ());
142
- curConfig = prjCDesc .createConfiguration (id ,cfgName ,prjCDesc .getActiveConfiguration ());
139
+
140
+ IConfiguration config = projectType .getConfiguration (cfgName );
141
+ if (config == null ) {
142
+ config = defaultConfig ;
143
143
}
144
- IAutoBuildConfigurationDescription autoConf = IAutoBuildConfigurationDescription
145
- .getConfig (curConfig );
146
- if (!(autoConf instanceof AutoBuildConfigurationDescription )) {
147
- // this should not happen as we just created a autoBuild project
148
- Activator .log (new Status (SLOEBER_STATUS_DEBUG , Activator .getId (),
149
- "\" Auto build created a project that does not seem to be a autobuild project :-s : " //$NON-NLS-1$
150
- + project .getName ()));
151
- continue ;
144
+ ICConfigurationDescription curConfig = prjCDesc .getConfigurationByName (cfgName );
145
+ AutoBuildConfigurationDescription autoConf =null ;
146
+ if (curConfig == null ) {
147
+ // config does not exists so create it
148
+ autoConf = new AutoBuildConfigurationDescription (config ,
149
+ project , buildTools , null );
150
+ autoConf .setName (cfgName );
151
+ curConfig = prjCDesc .createConfiguration (AutoBuildProject .INTERNAL_BUILDER_ID , autoConf );
152
+ autoConf .setCdtConfigurationDescription (curConfig );
153
+ }else {
154
+ autoConf = (AutoBuildConfigurationDescription ) IAutoBuildConfigurationDescription .getConfig (curConfig );
152
155
}
153
156
154
-
155
-
156
-
157
157
ICSourceEntry newSourceEntries [] = new ICSourceEntry [2 ];
158
158
// old Sloeber project so the code is in the root of the project for sure
159
159
// as we are at the root
@@ -201,24 +201,27 @@ public void run(IProgressMonitor internalMonitor) throws CoreException {
201
201
SubMonitor refreshMonitor = SubMonitor .convert (internalMonitor , 3 );
202
202
project .open (refreshMonitor );
203
203
project .refreshLocal (IResource .DEPTH_INFINITE , refreshMonitor );
204
+ prjCDesc .setActiveConfiguration (prjCDesc .getConfigurations ()[0 ]);
204
205
prjCDesc .setCdtProjectCreated ();
206
+
205
207
cCorePlugin .setProjectDescription (project , prjCDesc , true , SubMonitor .convert (internalMonitor , 1 ));
206
- project .close (monitor );
207
- project .open (monitor );
208
+ // project.close(monitor);
209
+ // project.open(monitor);
208
210
209
211
Activator .log (new Status (SLOEBER_STATUS_DEBUG , Activator .getId (),
210
212
"internal creation of project is done: " + project .getName ())); //$NON-NLS-1$
211
- // IndexerController.index(newProjectHandle);
212
213
}
213
214
};
214
215
try
215
216
216
217
{
218
+ IndexerController .doNotIndex (project );
217
219
workspace .run (runnable , root , IWorkspace .AVOID_UPDATE , monitor );
218
220
} catch (Exception e ) {
219
- Activator .log (new Status (IStatus .INFO , io .sloeber .core .Activator .getId (),
221
+ Activator .log (new Status (IStatus .ERROR , io .sloeber .core .Activator .getId (),
220
222
"Project creation failed: " + project .getName (), e )); //$NON-NLS-1$
221
223
}
224
+ IndexerController .index (project );
222
225
monitor .done ();
223
226
}
224
227
@@ -233,10 +236,14 @@ private static OtherDescription getOtherDescription(KeyValueTree config) {
233
236
234
237
private static CompileDescription getCompileDescription (KeyValueTree oldConfig ) {
235
238
CompileDescription ret = new CompileDescription ();
239
+ if (oldConfig == null ) {
240
+ return ret ;
241
+ }
236
242
KeyValueTree compileConfig =oldConfig .getChild ("compile" ).getChild ("sloeber" ); //$NON-NLS-1$ //$NON-NLS-2$
237
243
if (compileConfig == null ) {
238
244
return ret ;
239
245
}
246
+
240
247
KeyValueTree extraConfig =compileConfig .getChild ("extra" ); //$NON-NLS-1$
241
248
ret .set_All_CompileOptions (extraConfig .getValue ("all" )); //$NON-NLS-1$
242
249
ret .set_Archive_CompileOptions (extraConfig .getValue ("archive" )); //$NON-NLS-1$
@@ -281,10 +288,11 @@ private static BoardDescription getBoardDescription(KeyValueTree oldConfig) {
281
288
}
282
289
}
283
290
}
284
- if (foundBoardsFilePath == null ) {
291
+ if (foundBoardsFilePath == null || (! foundBoardsFilePath . toFile (). exists ()) ) {
285
292
return new BoardDescription ();
286
293
}
287
294
295
+
288
296
KeyValueTree optionsHolder =oldConfig .getChild ("board.BOARD.MENU" ); //$NON-NLS-1$
289
297
290
298
Map <String , String > options =new HashMap <>();
0 commit comments