@@ -152,6 +152,8 @@ static public File getBuildFolder() {
152
152
153
153
static public PreferencesMap getBoardPreferences () {
154
154
TargetBoard board = getTargetBoard ();
155
+ if (board == null )
156
+ return null ;
155
157
156
158
PreferencesMap prefs = new PreferencesMap (board .getPreferences ());
157
159
for (String menuId : board .getMenuIds ()) {
@@ -343,8 +345,11 @@ static public String getSketchbookPath() {
343
345
}
344
346
345
347
public static TargetBoard getTargetBoard () {
348
+ TargetPlatform targetPlatform = getTargetPlatform ();
349
+ if (targetPlatform == null )
350
+ return null ;
346
351
String boardId = PreferencesData .get ("board" );
347
- return getTargetPlatform () .getBoard (boardId );
352
+ return targetPlatform .getBoard (boardId );
348
353
}
349
354
350
355
/**
@@ -669,28 +674,27 @@ static public void main(String args[]) throws Exception {
669
674
}
670
675
671
676
static public void onBoardOrPortChange () {
672
- TargetPlatform targetPlatform = getTargetPlatform ();
673
- if (targetPlatform == null )
674
- return ;
675
-
676
- // Calculate paths for libraries and examples
677
677
examplesFolder = getContentFile ("examples" );
678
678
toolsFolder = getContentFile ("tools" );
679
-
680
- File platformFolder = targetPlatform .getFolder ();
681
679
librariesFolders = new ArrayList <File >();
682
680
librariesFolders .add (getContentFile ("libraries" ));
683
- String core = getBoardPreferences ().get ("build.core" );
684
- if (core .contains (":" )) {
685
- String referencedCore = core .split (":" )[0 ];
686
- TargetPlatform referencedPlatform = getTargetPlatform (referencedCore , targetPlatform .getId ());
687
- if (referencedPlatform != null ) {
688
- File referencedPlatformFolder = referencedPlatform .getFolder ();
689
- librariesFolders .add (new File (referencedPlatformFolder , "libraries" ));
681
+
682
+ // Add library folder for the current selected platform
683
+ TargetPlatform targetPlatform = getTargetPlatform ();
684
+ if (targetPlatform != null ) {
685
+ String core = getBoardPreferences ().get ("build.core" );
686
+ if (core .contains (":" )) {
687
+ String referencedCore = core .split (":" )[0 ];
688
+ TargetPlatform referencedPlatform = getTargetPlatform (referencedCore , targetPlatform .getId ());
689
+ if (referencedPlatform != null ) {
690
+ File referencedPlatformFolder = referencedPlatform .getFolder ();
691
+ librariesFolders .add (new File (referencedPlatformFolder , "libraries" ));
692
+ }
690
693
}
694
+ File platformFolder = targetPlatform .getFolder ();
695
+ librariesFolders .add (new File (platformFolder , "libraries" ));
696
+ librariesFolders .add (getSketchbookLibrariesFolder ());
691
697
}
692
- librariesFolders .add (new File (platformFolder , "libraries" ));
693
- librariesFolders .add (getSketchbookLibrariesFolder ());
694
698
695
699
// Scan for libraries in each library folder.
696
700
// Libraries located in the latest folders on the list can override
0 commit comments