@@ -138,13 +138,22 @@ public void run(IProgressMonitor internalMonitor) throws CoreException {
138
138
139
139
// create a sloeber project
140
140
SloeberProject sloeberProject = new SloeberProject (project );
141
+ CCorePlugin cCorePlugin = CCorePlugin .getDefault ();
142
+ ICProjectDescription prjCDesc = cCorePlugin .getProjectDescription (project , true );
143
+ if (upgradeArduinoProject (sloeberProject , prjCDesc )) {
144
+ try {
145
+ cCorePlugin .setProjectDescription (project , prjCDesc );
146
+ } catch (CoreException e ) {
147
+ e .printStackTrace ();
148
+ }
149
+ }
141
150
if (!sloeberProject .readConfigFromFiles ()) {
142
151
String RELEASE = "Release" ;
143
152
sloeberProject .setBoardDescription (RELEASE , new BoardDescription (), false );
144
153
sloeberProject .setCompileDescription (RELEASE , new CompileDescription ());
145
154
sloeberProject .setOtherDescription (RELEASE , new OtherDescription ());
146
- // we failed to read from disk so we set opourselfves some values
147
- // faking the stuf is in memory
155
+ // we failed to read from disk so we set up some values
156
+ // faking the stuff is in memory
148
157
149
158
}
150
159
String configName = sloeberProject .myBoardDescriptions .keySet ().iterator ().next ();
@@ -184,9 +193,7 @@ public void run(IProgressMonitor internalMonitor) throws CoreException {
184
193
ManagedBuildManager .setDefaultConfiguration (project , defaultConfig );
185
194
186
195
Map <String , String > configs2 = new HashMap <>();
187
-
188
- CCorePlugin cCorePlugin = CCorePlugin .getDefault ();
189
- ICProjectDescription prjCDesc = cCorePlugin .getProjectDescription (project );
196
+ prjCDesc = cCorePlugin .getProjectDescription (project );
190
197
ICConfigurationDescription activeConfig = prjCDesc .getActiveConfiguration ();
191
198
192
199
for (String curConfigName : sloeberProject .myBoardDescriptions .keySet ()) {
@@ -370,36 +377,29 @@ public void run(IProgressMonitor internalMonitor) throws CoreException {
370
377
* project in a new for
371
378
* currently only 1 conversion is implemented
372
379
*
373
- * @param projectName
374
- * @param projectURI
375
- * @param monitor
380
+ * returns true if the projectdescription needs to be saved
376
381
*/
377
382
378
- public void upgradeArduinoProject (String projectName , URI projectURI , IProgressMonitor monitor ) {
383
+ private static boolean upgradeArduinoProject (SloeberProject project , ICProjectDescription prjCDesc ) {
379
384
boolean saveProjDesc = false ;
380
- CCorePlugin cCorePlugin = CCorePlugin .getDefault ();
381
- ICProjectDescription prjCDesc = cCorePlugin .getProjectDescription (myProject , true );
385
+
382
386
if (prjCDesc == null ) {
383
387
//CDT project description is not found or is not writable
388
+ return false ;
384
389
}
385
390
386
- if (! getConfigLocalFile ().exists ()) {
391
+ if (project . getConfigLocalFile ().exists ()) {
387
392
//if the .sproject file exists check for old data and clean old data if found
393
+ saveProjDesc = removeCDTEnvironmentVars (prjCDesc );
388
394
} else {
389
395
//No sloeber project file try to migrate from old CDT storage
390
- if (readConfigFromCDT (prjCDesc )) {
391
- createSloeberConfigFiles (prjCDesc );
392
- setAllEnvironmentVars (prjCDesc );
396
+ if (project . readConfigFromCDT (prjCDesc )) {
397
+ project . createSloeberConfigFiles (prjCDesc );
398
+ project . setAllEnvironmentVars (prjCDesc );
393
399
saveProjDesc = removeCDTEnvironmentVars (prjCDesc );
394
400
}
395
401
}
396
- if (saveProjDesc ) {
397
- try {
398
- cCorePlugin .setProjectDescription (myProject , prjCDesc );
399
- } catch (CoreException e ) {
400
- e .printStackTrace ();
401
- }
402
- }
402
+ return saveProjDesc ;
403
403
}
404
404
405
405
private HashMap <String , String > getEnvVars (String configKey ) {
@@ -959,10 +959,16 @@ private static String getOtherPrefix(String confDescName) {
959
959
return CONFIG_DOT + confDescName + DOT + "other." ; //$NON-NLS-1$
960
960
}
961
961
962
+ /*
963
+ * Get the file that Sloeber maintains and that is meant to be stored in version control
964
+ */
962
965
private IFile getConfigVersionFile () {
963
966
return myProject .getFile (SLOEBER_CFG );
964
967
}
965
968
969
+ /*
970
+ * Get the sloeber configuration file
971
+ */
966
972
private IFile getConfigLocalFile () {
967
973
return myProject .getFile (".sproject" ); //$NON-NLS-1$
968
974
}
0 commit comments