@@ -190,27 +190,28 @@ private PreferencesMap loadPreferences(TargetBoard board, TargetPlatform platfor
190
190
return prefs ;
191
191
}
192
192
193
+ private void addPathFlagIfPathExists (List <String > cmd , String flag , File folder ) {
194
+ if (folder .exists ()) {
195
+ cmd .add (flag );
196
+ cmd .add (folder .getAbsolutePath ());
197
+ }
198
+ }
199
+
193
200
private void callArduinoBuilder (TargetBoard board , TargetPlatform platform , TargetPackage aPackage , String vidpid , BuilderAction action , OutputStream outStream , OutputStream errStream ) throws RunnerException {
194
201
List <String > cmd = new ArrayList <>();
195
202
cmd .add (BaseNoGui .getContentFile ("arduino-builder" ).getAbsolutePath ());
196
203
cmd .add (action .value );
197
204
cmd .add ("-logger=machine" );
198
205
199
- Stream .of (BaseNoGui .getHardwarePath (), new File (BaseNoGui .getSettingsFolder (), "packages" ).getAbsolutePath (), BaseNoGui .getSketchbookHardwareFolder ().getAbsolutePath ())
200
- .forEach (p -> {
201
- if (Files .exists (Paths .get (p ))) {
202
- cmd .add ("-hardware" );
203
- cmd .add (p );
204
- }
205
- });
206
+ File installedPackagesFolder = new File (BaseNoGui .getSettingsFolder (), "packages" );
206
207
207
- Stream . of ( BaseNoGui . getContentFile ( "tools-builder" ). getAbsolutePath (), Paths . get ( BaseNoGui . getHardwarePath (), "tools " , "avr" ). toAbsolutePath (). toString (), new File ( BaseNoGui .getSettingsFolder (), "packages" ). getAbsolutePath ())
208
- . forEach ( p -> {
209
- if ( Files . exists ( Paths . get ( p ))) {
210
- cmd . add ( "-tools" );
211
- cmd . add ( p );
212
- }
213
- } );
208
+ addPathFlagIfPathExists ( cmd , "-hardware " , BaseNoGui .getHardwareFolder ());
209
+ addPathFlagIfPathExists ( cmd , "-hardware" , installedPackagesFolder );
210
+ addPathFlagIfPathExists ( cmd , "-hardware" , BaseNoGui . getSketchbookHardwareFolder ());
211
+
212
+ addPathFlagIfPathExists ( cmd , "-tools" , BaseNoGui . getContentFile ( "tools-builder" ) );
213
+ addPathFlagIfPathExists ( cmd , "-tools" , Paths . get ( BaseNoGui . getHardwarePath (), "tools" , "avr" ). toFile ());
214
+ addPathFlagIfPathExists ( cmd , "-tools" , installedPackagesFolder );
214
215
215
216
cmd .add ("-built-in-libraries" );
216
217
cmd .add (BaseNoGui .getContentFile ("libraries" ).getAbsolutePath ());
0 commit comments