@@ -1219,29 +1219,34 @@ private File mergeSketchWithBootloaderIfAppropriate(String className, Preference
12191219
12201220 //7. Save the .hex file
12211221 void saveHex () throws RunnerException {
1222- if (!prefs .containsKey ("recipe.output.tmp_file" ) || !prefs .containsKey ("recipe.output.save_file" )) {
1222+ List <String > compiledSketches = new ArrayList <>(prefs .subTree ("recipe.output.tmp_file" , 1 ).values ());
1223+ List <String > copyOfCompiledSketches = new ArrayList <>(prefs .subTree ("recipe.output.save_file" , 1 ).values ());
1224+
1225+ if (isExportCompiledSketchSupported (compiledSketches , copyOfCompiledSketches )) {
12231226 System .err .println (_ ("Warning: This core does not support exporting sketches. Please consider upgrading it or contacting its author" ));
12241227 return ;
12251228 }
12261229
12271230 PreferencesMap dict = new PreferencesMap (prefs );
12281231 dict .put ("ide_version" , "" + BaseNoGui .REVISION );
12291232
1230- try {
1231- List <String > compiledSketches = new ArrayList <String >(prefs .subTree ("recipe.output.tmp_file" , 1 ).values ());
1232- if (!compiledSketches .isEmpty ()) {
1233- List <String > copyOfCompiledSketches = new ArrayList <String >(prefs .subTree ("recipe.output.save_file" , 1 ).values ());
1234- for (int i = 0 ; i < compiledSketches .size (); i ++) {
1235- saveHex (compiledSketches .get (i ), copyOfCompiledSketches .get (i ), prefs );
1236- }
1237- } else {
1233+ if (!compiledSketches .isEmpty ()) {
1234+ for (int i = 0 ; i < compiledSketches .size (); i ++) {
1235+ saveHex (compiledSketches .get (i ), copyOfCompiledSketches .get (i ), prefs );
1236+ }
1237+ } else {
1238+ try {
12381239 saveHex (prefs .getOrExcept ("recipe.output.tmp_file" ), prefs .getOrExcept ("recipe.output.save_file" ), prefs );
1240+ } catch (PreferencesMapException e ) {
1241+ throw new RunnerException (e );
12391242 }
1240- } catch (Exception e ) {
1241- throw new RunnerException (e );
12421243 }
12431244 }
12441245
1246+ private boolean isExportCompiledSketchSupported (List <String > compiledSketches , List <String > copyOfCompiledSketches ) {
1247+ return (compiledSketches .isEmpty () || copyOfCompiledSketches .isEmpty () || copyOfCompiledSketches .size () < compiledSketches .size ()) && (!prefs .containsKey ("recipe.output.tmp_file" ) || !prefs .containsKey ("recipe.output.save_file" ));
1248+ }
1249+
12451250 private void saveHex (String compiledSketch , String copyOfCompiledSketch , PreferencesMap dict ) throws RunnerException {
12461251 try {
12471252 compiledSketch = StringReplacer .replaceFromMapping (compiledSketch , dict );
0 commit comments