13
13
14
14
import org .eclipse .cdt .core .CCorePlugin ;
15
15
import org .eclipse .cdt .core .envvar .IContributedEnvironment ;
16
- import org .eclipse .cdt .core .envvar .IEnvironmentVariable ;
17
16
import org .eclipse .cdt .core .envvar .IEnvironmentVariableManager ;
18
17
import org .eclipse .cdt .core .model .CoreModel ;
19
18
import org .eclipse .cdt .core .settings .model .CSourceEntry ;
@@ -65,7 +64,7 @@ public class BoardDescriptor {
65
64
private static final String KEY_LAST_USED_UPLOAD_PROTOCOL = "last Used upload Protocol" ;
66
65
private static final String KEY_LAST_USED_BOARDS_FILE = "Last used Boards file" ;
67
66
private static final String KEY_LAST_USED_BOARD_MENU_OPTIONS = "last used Board custom option selections" ;
68
- private static final String MENUSELECTION = Const .ENV_KEY_JANTJE_START + "MENU. " ;
67
+ private static final String ENV_KEY_JANTJE_MENU_SELECTION = Const .ENV_KEY_JANTJE_START + "MENU" ;
69
68
private static final String ENV_KEY_JANTJE_UPLOAD_PORT = Const .ENV_KEY_JANTJE_START + "COM_PORT" ;
70
69
private static final String ENV_KEY_JANTJE_BOARD_NAME = Const .ENV_KEY_JANTJE_START + "BOARD_NAME" ;
71
70
private static final String ENV_KEY_JANTJE_PROJECT_NAME = Const .ENV_KEY_JANTJE_START + "PROJECT_NAME" ;
@@ -161,7 +160,6 @@ public boolean equals(BoardDescriptor otherBoardDescriptor) {
161
160
*/
162
161
public boolean needsSettingDirty (BoardDescriptor otherBoardDescriptor ) {
163
162
164
-
165
163
if (!this .getBoardID ().equals (otherBoardDescriptor .getBoardID ())) {
166
164
return true ;
167
165
}
@@ -181,8 +179,8 @@ public boolean needsSettingDirty(BoardDescriptor otherBoardDescriptor) {
181
179
return true ;
182
180
}
183
181
if (!this .getMyWorkSpaceLocation ().equals (otherBoardDescriptor .getMyWorkSpaceLocation ())) {
184
- return true ;
185
- }
182
+ return true ;
183
+ }
186
184
return false ;
187
185
}
188
186
@@ -245,14 +243,29 @@ private void ParseSection(Map<String, String> boardInfo) {
245
243
upload = uploadOption ;
246
244
}
247
245
}
248
-
246
+ String architecture = getArchitecture ();
249
247
if (core != null ) {
250
248
String valueSplit [] = core .split (":" );
251
249
if (valueSplit .length == 2 ) {
252
250
String refVendor = valueSplit [0 ];
253
251
String actualValue = valueSplit [1 ];
254
252
this .myBoardsCore = actualValue ;
255
- this .myReferencedCorePlatformPath = findReferencedPlatform (refVendor );
253
+ this .myReferencedCorePlatformPath = Manager .getPlatformInstallPath (refVendor , architecture );
254
+ if (this .myReferencedCorePlatformPath == null ) {
255
+ Common .log (new Status (IStatus .ERROR , Const .CORE_PLUGIN_ID ,
256
+ Messages .Helpers_tool_reference_missing .replaceAll (TOOL_KEY , core )
257
+ .replaceAll (FILE_KEY , getReferencingBoardsFile ().toString ())
258
+ .replaceAll (BOARD_KEY , getBoardID ())));
259
+ return ;
260
+ }
261
+ } else if (valueSplit .length == 4 ) {
262
+ String refVendor = valueSplit [0 ];
263
+ String refArchitecture = valueSplit [1 ];
264
+ String refVersion = valueSplit [2 ];
265
+ String actualValue = valueSplit [3 ];
266
+ this .myUploadTool = actualValue ;
267
+ this .myReferencedCorePlatformPath = Manager .getPlatformInstallPath (refVendor , refArchitecture ,
268
+ refVersion );
256
269
if (this .myReferencedCorePlatformPath == null ) {
257
270
Common .log (new Status (IStatus .ERROR , Const .CORE_PLUGIN_ID ,
258
271
Messages .Helpers_tool_reference_missing .replaceAll (TOOL_KEY , core )
@@ -270,7 +283,22 @@ private void ParseSection(Map<String, String> boardInfo) {
270
283
String refVendor = valueSplit [0 ];
271
284
String actualValue = valueSplit [1 ];
272
285
this .myBoardsVariant = actualValue ;
273
- this .myReferencedBoardVariantPlatformPath = findReferencedPlatform (refVendor );
286
+ this .myReferencedBoardVariantPlatformPath = Manager .getPlatformInstallPath (refVendor , architecture );
287
+ if (this .myReferencedBoardVariantPlatformPath == null ) {
288
+ Common .log (new Status (IStatus .ERROR , Const .CORE_PLUGIN_ID ,
289
+ Messages .Helpers_tool_reference_missing .replaceAll (TOOL_KEY , variant )
290
+ .replaceAll (FILE_KEY , getReferencingBoardsFile ().toString ())
291
+ .replaceAll (BOARD_KEY , getBoardID ())));
292
+ return ;
293
+ }
294
+ } else if (valueSplit .length == 4 ) {
295
+ String refVendor = valueSplit [0 ];
296
+ String refArchitecture = valueSplit [1 ];
297
+ String refVersion = valueSplit [2 ];
298
+ String actualValue = valueSplit [3 ];
299
+ this .myUploadTool = actualValue ;
300
+ this .myReferencedBoardVariantPlatformPath = Manager .getPlatformInstallPath (refVendor , refArchitecture ,
301
+ refVersion );
274
302
if (this .myReferencedBoardVariantPlatformPath == null ) {
275
303
Common .log (new Status (IStatus .ERROR , Const .CORE_PLUGIN_ID ,
276
304
Messages .Helpers_tool_reference_missing .replaceAll (TOOL_KEY , variant )
@@ -288,7 +316,22 @@ private void ParseSection(Map<String, String> boardInfo) {
288
316
String refVendor = valueSplit [0 ];
289
317
String actualValue = valueSplit [1 ];
290
318
this .myUploadTool = actualValue ;
291
- this .myReferencedUploadToolPlatformPath = findReferencedPlatform (refVendor );
319
+ this .myReferencedUploadToolPlatformPath = Manager .getPlatformInstallPath (refVendor , architecture );
320
+ if (this .myReferencedUploadToolPlatformPath == null ) {
321
+ Common .log (new Status (IStatus .ERROR , Const .CORE_PLUGIN_ID ,
322
+ Messages .Helpers_tool_reference_missing .replaceAll (TOOL_KEY , upload )
323
+ .replaceAll (FILE_KEY , getReferencingBoardsFile ().toString ())
324
+ .replaceAll (BOARD_KEY , getBoardID ())));
325
+ return ;
326
+ }
327
+ } else if (valueSplit .length == 4 ) {
328
+ String refVendor = valueSplit [0 ];
329
+ String refArchitecture = valueSplit [1 ];
330
+ String refVersion = valueSplit [2 ];
331
+ String actualValue = valueSplit [3 ];
332
+ this .myUploadTool = actualValue ;
333
+ this .myReferencedUploadToolPlatformPath = Manager .getPlatformInstallPath (refVendor , refArchitecture ,
334
+ refVersion );
292
335
if (this .myReferencedUploadToolPlatformPath == null ) {
293
336
Common .log (new Status (IStatus .ERROR , Const .CORE_PLUGIN_ID ,
294
337
Messages .Helpers_tool_reference_missing .replaceAll (TOOL_KEY , upload )
@@ -325,16 +368,8 @@ protected BoardDescriptor(ICConfigurationDescription confdesc) {
325
368
"" );
326
369
this .myWorkEclipseLocation = Common .getBuildEnvironmentVariable (confdesc , ENV_KEY_JANTJE_ECLIPSE_LOCATION ,
327
370
"" );
328
-
329
- this .myOptions = new TreeMap <>(String .CASE_INSENSITIVE_ORDER );
330
- IEnvironmentVariableManager envManager = CCorePlugin .getDefault ().getBuildEnvironmentManager ();
331
- IContributedEnvironment contribEnv = envManager .getContributedEnvironment ();
332
- IEnvironmentVariable [] curVariables = contribEnv .getVariables (confdesc );
333
- for (IEnvironmentVariable curVariable : curVariables ) {
334
- if (curVariable .getName ().startsWith (MENUSELECTION )) {
335
- this .myOptions .put (curVariable .getName ().substring (MENUSELECTION .length ()), curVariable .getValue ());
336
- }
337
- }
371
+ String optinconcat = Common .getBuildEnvironmentVariable (confdesc , ENV_KEY_JANTJE_MENU_SELECTION , "" );
372
+ this .myOptions = KeyValue .makeMap (optinconcat );
338
373
}
339
374
calculateDerivedFields ();
340
375
}
@@ -603,12 +638,9 @@ public boolean saveConfiguration(ICConfigurationDescription confDesc, IContribut
603
638
Common .setBuildEnvironmentVariable (contribEnv , confDesc , ENV_KEY_JANTJE_ECLIPSE_LOCATION ,
604
639
this .myWorkEclipseLocation );
605
640
Common .setBuildEnvironmentVariable (confDesc , JANTJE_ACTION_UPLOAD , this .myProgrammer );
606
- if (this .myOptions != null ) {
607
- for (Map .Entry <String , String > curoption : this .myOptions .entrySet ()) {
608
- Common .setBuildEnvironmentVariable (contribEnv , confDesc , MENUSELECTION + curoption .getKey (),
609
- curoption .getValue ());
610
- }
611
- }
641
+ String value = KeyValue .makeString (this .myOptions );
642
+ Common .setBuildEnvironmentVariable (contribEnv , confDesc , ENV_KEY_JANTJE_MENU_SELECTION , value );
643
+
612
644
Common .setBuildEnvironmentVariable (contribEnv , confDesc , ENV_KEY_SERIAL_PORT , this .myUploadPort );
613
645
Common .setBuildEnvironmentVariable (contribEnv , confDesc , ENV_KEY_SERIAL_PORT_FILE ,
614
646
this .myUploadPort .replace ("/dev/" , new String ()));
@@ -712,10 +744,9 @@ public String[] getCompatibleBoards() {
712
744
}
713
745
714
746
public String [] getUploadProtocols () {
715
- if (this .myreferencingBoardsFile .exists ()) {
716
- return Programmers .getUploadProtocols (this .myreferencingBoardsFile .toString ());
717
- }
718
- return new String [0 ];
747
+
748
+ return Programmers .getUploadProtocols (this );
749
+
719
750
}
720
751
721
752
public String [] getMenuItemNamesFromMenuID (String menuID ) {
@@ -781,24 +812,6 @@ public String getProjectName() {
781
812
return this .myProjectName ;
782
813
}
783
814
784
- /**
785
- * This method looks for a referenced platform. Ask the boards manager to find
786
- * the latest installed vendor/architecture platform file
787
- *
788
- * If this is not found there is still sme old code that probably can be
789
- * deleted.
790
- *
791
- * @param vendor
792
- * @param architecture
793
- * @return
794
- */
795
- private IPath findReferencedPlatform (String vendor ) {
796
- // ask the boardsmanager for the platform file
797
- IPath ret = Manager .getPlatformInstallPath (vendor , getArchitecture ());
798
- return ret ;
799
-
800
- }
801
-
802
815
/**
803
816
* provide the actual path to the variant. Use this method if you want to know
804
817
* where the variant is
@@ -883,24 +896,25 @@ public IPath getReferencingLibraryPath() {
883
896
884
897
public String getUploadCommand (ICConfigurationDescription confdesc ) {
885
898
String upLoadTool = getActualUploadTool (confdesc );
886
- String action = "UPLOAD" ;
899
+ String action = "UPLOAD" ;
887
900
if (usesProgrammer ()) {
888
- action = "PROGRAM" ;
901
+ action = "PROGRAM" ;
889
902
}
890
- return Common .getBuildEnvironmentVariable (confdesc , "A.TOOLS." + upLoadTool . toUpperCase () + "." + action + ".PATTERN" ,
891
- upLoadTool .toUpperCase ());
903
+ return Common .getBuildEnvironmentVariable (confdesc ,
904
+ "A.TOOLS." + upLoadTool . toUpperCase () + "." + action + ".PATTERN" , upLoadTool .toUpperCase ());
892
905
}
893
906
894
907
public String getActualUploadTool (ICConfigurationDescription confdesc ) {
895
- if (confdesc == null ) {
896
- Common .log (new Status (IStatus .ERROR , Const .CORE_PLUGIN_ID ,"Confdesc null is not alowed here" ));
908
+ if (confdesc == null ) {
909
+ Common .log (new Status (IStatus .ERROR , Const .CORE_PLUGIN_ID , "Confdesc null is not alowed here" ));
897
910
return this .myUploadTool ;
898
911
}
899
- if (usesProgrammer ()) {
900
- return Common .getBuildEnvironmentVariable (confdesc , "A.PROGRAM.TOOL" , "Program tool not properly configured" );
912
+ if (usesProgrammer ()) {
913
+ return Common .getBuildEnvironmentVariable (confdesc , "A.PROGRAM.TOOL" ,
914
+ "Program tool not properly configured" );
901
915
}
902
- if (this .myUploadTool == null ) {
903
- return Common .getBuildEnvironmentVariable (confdesc , "A.UPLOAD.TOOL" , "upload tool not properly configured" );
916
+ if (this .myUploadTool == null ) {
917
+ return Common .getBuildEnvironmentVariable (confdesc , "A.UPLOAD.TOOL" , "upload tool not properly configured" );
904
918
}
905
919
return this .myUploadTool ;
906
920
}
0 commit comments