73
73
74
74
/**
75
75
* ArduinoHelpers is a static class containing general purpose functions
76
- *
76
+ *
77
77
* @author Jan Baeyens
78
- *
78
+ *
79
79
*/
80
80
public class Helpers extends Common {
81
81
private static final String ARDUINO_CORE_FOLDER_NAME = "cores" ; //$NON-NLS-1$
@@ -115,7 +115,7 @@ public class Helpers extends Common {
115
115
/**
116
116
* This method is the internal working class that adds the provided include
117
117
* path to all configurations and languages.
118
- *
118
+ *
119
119
* @param configurationDescription
120
120
* The configuration description of the project to add it to
121
121
* @param IncludePath
@@ -150,7 +150,7 @@ private static void addIncludeFolder(ICConfigurationDescription configurationDes
150
150
/**
151
151
* Removes include folders that are not valid. This method does not save the
152
152
* configurationDescription description
153
- *
153
+ *
154
154
* @param configurationDescription
155
155
* the configuration that is checked
156
156
* @return true is a include path has been removed. False if the include
@@ -200,7 +200,7 @@ public static boolean removeInvalidIncludeFolders(ICConfigurationDescription con
200
200
/**
201
201
* This method adds the provided path to the include path of all
202
202
* configurations and languages.
203
- *
203
+ *
204
204
* @param project
205
205
* The project to add it to
206
206
* @param IncludePath
@@ -238,7 +238,7 @@ public static void addCodeFolder(IProject project, Path toLinkFolder, String Lin
238
238
* Creates a folder and links the folder to an existing folder Parent
239
239
* folders of the target folder are created if needed. In case this method
240
240
* fails an error is logged.
241
- *
241
+ *
242
242
* @param project
243
243
* the project the newly created folder will belong to
244
244
* @param target
@@ -276,19 +276,19 @@ public static void LinkFolderToFolder(IProject project, IPath source, IPath targ
276
276
* Forget about this. Arduino made this all so complicated I don't know
277
277
* anymore what needs to be added to what<br/>
278
278
* <br/>
279
- *
279
+ *
280
280
* note Arduino has these subfolders in the libraries that need to be
281
281
* include.<br/>
282
282
* <br/>
283
- *
283
+ *
284
284
* note that in the current eclipse version, there is no need to add the
285
285
* subfolder as a code folder. This may change in the future as it looks
286
286
* like a bug to me.<br/>
287
- *
287
+ *
288
288
* @param project
289
289
* @param Path
290
290
* @throws CoreException
291
- *
291
+ *
292
292
* @see addLibraryDependency
293
293
* {@link #addLibraryDependency(IProject, IProject)}
294
294
*/
@@ -322,26 +322,33 @@ public static void addCodeFolder(IProject project, IPath toLinkFolder, String Li
322
322
}
323
323
}
324
324
325
+ public static void removeCodeFolder (IProject project , String LinkName ) throws CoreException {
326
+ IFolder link = project .getFolder (LinkName );
327
+ if (link .exists ()) {
328
+ link .delete (true , null );
329
+ }
330
+ }
331
+
325
332
/**
326
333
* This method creates a link folder in the project and adds the folder as a
327
334
* source path to the project it also adds the path to the include folder if
328
335
* the include path parameter points to a path that contains a subfolder
329
336
* named "utility" this subfolder will be added to the include path as well
330
337
* <br/>
331
338
* <br/>
332
- *
339
+ *
333
340
* note Arduino has these subfolders in the libraries that need to be
334
341
* include.<br/>
335
342
* <br/>
336
- *
343
+ *
337
344
* note that in the current eclipse version, there is no need to add the
338
345
* subfolder as a code folder. This may change in the future as it looks
339
346
* like a bug to me.<br/>
340
- *
347
+ *
341
348
* @param project
342
349
* @param Path
343
350
* @throws CoreException
344
- *
351
+ *
345
352
* @see addLibraryDependency
346
353
* {@link #addLibraryDependency(IProject, IProject)}
347
354
*/
@@ -355,7 +362,7 @@ public static void addCodeFolder(IProject project, Path Path, ICConfigurationDes
355
362
/**
356
363
* addTheNatures replaces all existing natures by the natures needed for a
357
364
* arduino project
358
- *
365
+ *
359
366
* @param project
360
367
* The project where the natures need to be added to
361
368
* @throws CoreException
@@ -375,7 +382,7 @@ public static void addTheNatures(IProjectDescription description) throws CoreExc
375
382
/**
376
383
* This method adds the content of a content stream to a file If the file
377
384
* already exist the file remains untouched
378
- *
385
+ *
379
386
* @param container
380
387
* used as a reference to the file
381
388
* @param path
@@ -416,7 +423,7 @@ public static MessageConsole findConsole(String name) {
416
423
/**
417
424
* This method adds the Arduino code in a subfolder named Arduino. 2 linked
418
425
* subfolders named core and variant link to the real Arduino code note
419
- *
426
+ *
420
427
* @param project
421
428
* The project to add the arduino code to
422
429
* @param configurationDescription
@@ -438,7 +445,10 @@ public static void addArduinoCodeToProject(IProject project, ICConfigurationDesc
438
445
439
446
addCodeFolder (project , corePath , ARDUINO_CODE_FOLDER_NAME + '/' + ARDUINO_CORE_BUILD_FOLDER_NAME ,
440
447
configurationDescription );
441
- if (!boardVariant .isEmpty ()) {
448
+ if (boardVariant .isEmpty ()) {
449
+ // remove the existing link
450
+ Helpers .removeCodeFolder (project , ARDUINO_CODE_FOLDER_NAME + "/variant" ); //$NON-NLS-1$
451
+ } else {
442
452
String redirectVariantPath = getBuildEnvironmentVariable (configurationDescription ,
443
453
ENV_KEY_JANTJE_REFERENCED_VARIANT_PATH , EMPTY_STRING );
444
454
IPath VariantFile ;
@@ -456,7 +466,7 @@ public static void addArduinoCodeToProject(IProject project, ICConfigurationDesc
456
466
457
467
/**
458
468
* Creates a new folder resource as a link or local
459
- *
469
+ *
460
470
* @param Project
461
471
* the project the folder is added to
462
472
* @param newFolderName
@@ -465,7 +475,7 @@ public static void addArduinoCodeToProject(IProject project, ICConfigurationDesc
465
475
* if null a local folder is created using newFolderName if not
466
476
* null a link folder is created with the name newFolderName and
467
477
* pointing to linklocation
468
- *
478
+ *
469
479
* @return nothing
470
480
* @throws CoreException
471
481
*/
@@ -482,7 +492,7 @@ public static void createNewFolder(IProject Project, String newFolderName, URI l
482
492
483
493
/**
484
494
* Remove all the arduino environment variables.
485
- *
495
+ *
486
496
* @param contribEnv
487
497
* @param confDesc
488
498
*/
@@ -502,7 +512,7 @@ private static void removeAllEraseEnvironmentVariables(IContributedEnvironment c
502
512
* platform.txt file. Here I set these values. This method should be called
503
513
* as first. This way the values in platform.txt and boards.txt will take
504
514
* precedence of the default values declared here
505
- *
515
+ *
506
516
* @param contribEnv
507
517
* @param confDesc
508
518
* @param platformFile
@@ -589,7 +599,7 @@ private static void setTheEnvironmentVariablesAddAFile(IContributedEnvironment c
589
599
/**
590
600
* This method parses a file with environment variables like the
591
601
* platform.txt file for values to be added to the environment variables
592
- *
602
+ *
593
603
* @param contribEnv
594
604
* @param confDesc
595
605
* @param envVarFile
@@ -638,7 +648,7 @@ private static void setTheEnvironmentVariablesAddAFile(String prefix, IContribut
638
648
* the modifiers) Then it parses for the menu variables
639
649
* menu.[menuID].[boardID].[selectionID].[key]=[value] results in
640
650
* [key]=[value] (taking in account the modifiers)
641
- *
651
+ *
642
652
* @param contribEnv
643
653
* @param confDesc
644
654
* @param platformFilename
@@ -761,14 +771,14 @@ private static void setTheEnvironmentVariablesAddThePlatformInfo(IContributedEnv
761
771
* The project properties are used to identify the boards.txt and
762
772
* platform.txt as well as the board id to select the settings in the
763
773
* board.txt file At the end also the path variable is set
764
- *
774
+ *
765
775
* from arduino IDE 1.6.5 an additional file generated by the arduino ide is
766
776
* processed. This is the first file processed.
767
- *
777
+ *
768
778
* To be able to quickly fix boards.txt and platform.txt problems I also
769
779
* added a pre and post platform and boards files that are processed before
770
780
* and after the arduino delivered boards.txt file.
771
- *
781
+ *
772
782
* @param project
773
783
* the project for which the environment variables are set
774
784
* @param arduinoProperties
@@ -856,20 +866,20 @@ public static void setTheEnvironmentVariables(IProject project, ICConfigurationD
856
866
* Hardware-specification This method parses the boards.txt file for
857
867
* myboard.build.core myboard.build.variant currently not supported
858
868
* myboard.upload.tool myboard.bootloader.tool
859
- *
869
+ *
860
870
* in case myboard.build.core is of type [vendor]:[value]
861
871
* PATH_VARIABLE_NAME_ARDUINO_PLATFORM is changed to the correct value in
862
872
* case myboard.build.variant is of type [vendor]:[value]
863
873
* PATH_VARIABLE_NAME_ARDUINO_PINS is changed to the correct value
864
- *
874
+ *
865
875
* this method also sets ENV_KEY_JANTJE_BUILD_CORE and
866
876
* ENV_KEY_JANTJE_BUILD_VARIANT to [value] of respectively
867
877
* myboard.build.core and myboard.build.variant
868
- *
878
+ *
869
879
* This method relies on the post processing to set
870
880
* A.BUILD.CORE=${ENV_KEY_JANTJE_BUILD_CORE}
871
881
* A.BUILD.VARIANT=${ENV_KEY_JANTJE_BUILD_VARIANT}
872
- *
882
+ *
873
883
* @param contribEnv
874
884
* @param confDesc
875
885
* @param boardsFile
@@ -929,10 +939,10 @@ private static void setTheEnvironmentVariablesRedirectToOtherVendors(IContribute
929
939
/**
930
940
* This method looks for a referenced platformFile. Ask the boards manager
931
941
* to find the latest installed vendor/architecture platform file
932
- *
942
+ *
933
943
* If this is not found there is still sme old code that probably can be
934
944
* deleted.
935
- *
945
+ *
936
946
* @param vendor
937
947
* @param architecture
938
948
* @return
@@ -946,21 +956,21 @@ private static IPath findReferencedPlatformFile(String vendor, String architectu
946
956
947
957
/**
948
958
* Following post processing is done
949
- *
959
+ *
950
960
* the macro expansion resolves the "file tag" Therefore I split the
951
961
* "recipe" patterns in 2 parts (before and after the "file tag") the
952
962
* pattern in the toolchain is then ${first part} ${files} ${second part}
953
- *
963
+ *
954
964
* The handling of the upload variables is done differently in arduino than
955
965
* here. This is taken care of here. for example the output of this input
956
966
* tools.avrdude.upload.pattern="{cmd.path}" "-C{config.path}"
957
967
* {upload.verbose} is changed as if it were the output of this input
958
968
* tools.avrdude.upload.pattern="{tools.avrdude.cmd.path}"
959
969
* "-C{tools.avrdude.config.path}" {tools.avrdude.upload.verbose}
960
- *
970
+ *
961
971
* if a programmer is selected different from default some extra actions are
962
972
* done here so no special code is needed to handle programmers
963
- *
973
+ *
964
974
* @param contribEnv
965
975
* @param confDesc
966
976
*/
@@ -1116,7 +1126,7 @@ private static void setTheEnvironmentVariablesPostProcessing(IContributedEnviron
1116
1126
* Converts the CPP and C compiler flags to not optimize for space/size and
1117
1127
* to leave symbols in. These changes allow step through debugging with JTAG
1118
1128
* and Dragon AVR
1119
- *
1129
+ *
1120
1130
* @param confDesc
1121
1131
* @param envManager
1122
1132
* @param contribEnv
@@ -1157,7 +1167,7 @@ private static void setTheEnvironmentVariablesModifyDebugCompilerSettings(ICConf
1157
1167
* When parsing boards.txt and platform.txt some processing needs to be done
1158
1168
* to get "acceptable environment variable values" This method does the
1159
1169
* parsing
1160
- *
1170
+ *
1161
1171
* @param inputString
1162
1172
* the value string as read from the file
1163
1173
* @return the string to be stored as value for the environment variable
@@ -1184,11 +1194,11 @@ public static String MakeEnvironmentString(String inputString, String keyPrefix)
1184
1194
* to get "acceptable environment variable keys" This method does the
1185
1195
* parsing some examples on windows "test.windows" becomes "A.TEST"
1186
1196
* "test.linux" becomes "A.TEST.LINUX"
1187
- *
1197
+ *
1188
1198
* on Linux "test.windows" becomes "A.TEST.WINDOWS" "test.linux" becomes
1189
1199
* "A.TEST"
1190
- *
1191
- *
1200
+ *
1201
+ *
1192
1202
* @param inputString
1193
1203
* the key string as read from the file
1194
1204
* @return the string to be used as key for the environment variable
@@ -1214,7 +1224,7 @@ private static String MakeKeyString(String prefix, String string) {
1214
1224
* this to work is by deleting the build folder Still then the "indexer
1215
1225
* needs to recheck his includes from the language provider which still is
1216
1226
* not working
1217
- *
1227
+ *
1218
1228
* @param project
1219
1229
*/
1220
1230
public static void setDirtyFlag (IProject project , ICConfigurationDescription cfgDescription ) {
@@ -1257,7 +1267,7 @@ public static void setDirtyFlag(IProject project, ICConfigurationDescription cfg
1257
1267
* So I keep it for now and we'll see how it goes The eclipse default
1258
1268
* behavior is (starting from the project folder [configuration]/Source The
1259
1269
* Arduino default behavior is all in 1 location (so no subfolders)
1260
- *
1270
+ *
1261
1271
* @param Source
1262
1272
* The source file to find the
1263
1273
* @return The base file name for the ouput if Source is "file.cpp" the
@@ -1276,7 +1286,7 @@ public static IPath GetOutputName(IPath Source) {
1276
1286
/**
1277
1287
* Converts a name to a tagged environment variable if variableName ="this"
1278
1288
* the output is "${this}"
1279
- *
1289
+ *
1280
1290
* @param variableName
1281
1291
* @return
1282
1292
*/
@@ -1288,7 +1298,7 @@ private static String makeEnvironmentVar(String variableName) {
1288
1298
* Give the string entered in the com port try to extract a host. If no host
1289
1299
* is found return null yun.local at xxx.yyy.zzz (arduino yun) returns
1290
1300
* yun.local
1291
- *
1301
+ *
1292
1302
* @param mComPort
1293
1303
* @return
1294
1304
*/
@@ -1301,7 +1311,7 @@ public static String getHostFromComPort(String mComPort) {
1301
1311
1302
1312
/**
1303
1313
* creates links to the root files and folders of the source location
1304
- *
1314
+ *
1305
1315
* @param source
1306
1316
* the location where the files are that need to be linked to
1307
1317
* @param target
@@ -1334,7 +1344,7 @@ public static void linkDirectory(IProject project, IPath source, IPath target) {
1334
1344
/**
1335
1345
* given a action and a tool return the environment key that matches it's
1336
1346
* recipe
1337
- *
1347
+ *
1338
1348
* @param action
1339
1349
* @return he environment variable key to find the recipe
1340
1350
*/
0 commit comments