49
49
import processing .app .PreferencesData ;
50
50
import processing .app .SketchCode ;
51
51
import processing .app .SketchData ;
52
- import processing .app .helpers .FileUtils ;
53
- import processing .app .helpers .PreferencesMap ;
54
- import processing .app .helpers .ProcessUtils ;
55
- import processing .app .helpers .StringReplacer ;
52
+ import processing .app .helpers .*;
56
53
import processing .app .helpers .filefilters .OnlyDirs ;
57
54
import processing .app .packages .Library ;
58
55
import processing .app .packages .LibraryList ;
@@ -86,7 +83,7 @@ public interface ProgressListener {
86
83
87
84
private ProgressListener progressListener ;
88
85
89
- static public String build (SketchData data , String buildPath , File tempBuildFolder , ProgressListener progListener , boolean verbose ) throws RunnerException {
86
+ static public String build (SketchData data , String buildPath , File tempBuildFolder , ProgressListener progListener , boolean verbose ) throws RunnerException , PreferencesMapException {
90
87
if (SketchData .checkSketchFile (data .getPrimaryFile ()) == null )
91
88
BaseNoGui .showError (_ ("Bad file selected" ),
92
89
_ ("Bad sketch primary file or bad sketck directory structure" ), null );
@@ -338,12 +335,12 @@ protected void size(PreferencesMap prefs) throws RunnerException {
338
335
339
336
/**
340
337
* Compile sketch.
341
- * @param buildPath
338
+ * @param _verbose
342
339
*
343
340
* @return true if successful.
344
341
* @throws RunnerException Only if there's a problem. Only then.
345
342
*/
346
- public boolean compile (boolean _verbose ) throws RunnerException {
343
+ public boolean compile (boolean _verbose ) throws RunnerException , PreferencesMapException {
347
344
preprocess (prefs .get ("build.path" ));
348
345
349
346
verbose = _verbose || PreferencesData .getBoolean ("build.verbose" );
@@ -505,7 +502,7 @@ private PreferencesMap createBuildPreferences(String _buildPath,
505
502
506
503
private List <File > compileFiles (File outputPath , File sourcePath ,
507
504
boolean recurse , List <File > includeFolders )
508
- throws RunnerException {
505
+ throws RunnerException , PreferencesMapException {
509
506
List <File > sSources = findFilesInFolder (sourcePath , "S" , recurse );
510
507
List <File > cSources = findFilesInFolder (sourcePath , "c" , recurse );
511
508
List <File > cppSources = findFilesInFolder (sourcePath , "cpp" , recurse );
@@ -545,7 +542,7 @@ private List<File> compileFiles(File outputPath, File sourcePath,
545
542
* Strip escape sequences used in makefile dependency files (.d)
546
543
* https://github.com/arduino/Arduino/issues/2255#issuecomment-57645845
547
544
*
548
- * @param dep
545
+ * @param line
549
546
* @return
550
547
*/
551
548
protected static String unescapeDepFile (String line ) {
@@ -816,16 +813,16 @@ public void message(String s) {
816
813
817
814
private String [] getCommandCompilerS (List <File > includeFolders ,
818
815
File sourceFile , File objectFile )
819
- throws RunnerException {
816
+ throws RunnerException , PreferencesMapException {
820
817
String includes = prepareIncludes (includeFolders );
821
818
PreferencesMap dict = new PreferencesMap (prefs );
822
819
dict .put ("ide_version" , "" + BaseNoGui .REVISION );
823
820
dict .put ("includes" , includes );
824
821
dict .put ("source_file" , sourceFile .getAbsolutePath ());
825
822
dict .put ("object_file" , objectFile .getAbsolutePath ());
826
823
824
+ String cmd = prefs .getOrExcept ("recipe.S.o.pattern" );
827
825
try {
828
- String cmd = prefs .get ("recipe.S.o.pattern" );
829
826
return StringReplacer .formatAndSplit (cmd , dict , true );
830
827
} catch (Exception e ) {
831
828
throw new RunnerException (e );
@@ -834,7 +831,7 @@ private String[] getCommandCompilerS(List<File> includeFolders,
834
831
835
832
private String [] getCommandCompilerC (List <File > includeFolders ,
836
833
File sourceFile , File objectFile )
837
- throws RunnerException {
834
+ throws RunnerException , PreferencesMapException {
838
835
String includes = prepareIncludes (includeFolders );
839
836
840
837
PreferencesMap dict = new PreferencesMap (prefs );
@@ -843,7 +840,7 @@ private String[] getCommandCompilerC(List<File> includeFolders,
843
840
dict .put ("source_file" , sourceFile .getAbsolutePath ());
844
841
dict .put ("object_file" , objectFile .getAbsolutePath ());
845
842
846
- String cmd = prefs .get ("recipe.c.o.pattern" );
843
+ String cmd = prefs .getOrExcept ("recipe.c.o.pattern" );
847
844
try {
848
845
return StringReplacer .formatAndSplit (cmd , dict , true );
849
846
} catch (Exception e ) {
@@ -853,7 +850,7 @@ private String[] getCommandCompilerC(List<File> includeFolders,
853
850
854
851
private String [] getCommandCompilerCPP (List <File > includeFolders ,
855
852
File sourceFile , File objectFile )
856
- throws RunnerException {
853
+ throws RunnerException , PreferencesMapException {
857
854
String includes = prepareIncludes (includeFolders );
858
855
859
856
PreferencesMap dict = new PreferencesMap (prefs );
@@ -862,7 +859,7 @@ private String[] getCommandCompilerCPP(List<File> includeFolders,
862
859
dict .put ("source_file" , sourceFile .getAbsolutePath ());
863
860
dict .put ("object_file" , objectFile .getAbsolutePath ());
864
861
865
- String cmd = prefs .get ("recipe.cpp.o.pattern" );
862
+ String cmd = prefs .getOrExcept ("recipe.cpp.o.pattern" );
866
863
try {
867
864
return StringReplacer .formatAndSplit (cmd , dict , true );
868
865
} catch (Exception e ) {
@@ -909,21 +906,21 @@ static public List<File> findFilesInFolder(File folder, String extension,
909
906
}
910
907
911
908
// 1. compile the sketch (already in the buildPath)
912
- void compileSketch (List <File > includeFolders ) throws RunnerException {
909
+ void compileSketch (List <File > includeFolders ) throws RunnerException , PreferencesMapException {
913
910
File buildPath = prefs .getFile ("build.path" );
914
911
objectFiles .addAll (compileFiles (buildPath , buildPath , false , includeFolders ));
915
912
}
916
913
917
914
// 2. compile the libraries, outputting .o files to:
918
915
// <buildPath>/<library>/
919
- void compileLibraries (List <File > includeFolders ) throws RunnerException {
916
+ void compileLibraries (List <File > includeFolders ) throws RunnerException , PreferencesMapException {
920
917
for (Library lib : importedLibraries ) {
921
918
compileLibrary (lib , includeFolders );
922
919
}
923
920
}
924
921
925
922
private void compileLibrary (Library lib , List <File > includeFolders )
926
- throws RunnerException {
923
+ throws RunnerException , PreferencesMapException {
927
924
File libFolder = lib .getSrcFolder ();
928
925
File libBuildFolder = prefs .getFile (("build.path" ), lib .getName ());
929
926
@@ -949,15 +946,15 @@ private void compileLibrary(Library lib, List<File> includeFolders)
949
946
}
950
947
}
951
948
952
- private void recursiveCompileFilesInFolder (File srcBuildFolder , File srcFolder , List <File > includeFolders ) throws RunnerException {
949
+ private void recursiveCompileFilesInFolder (File srcBuildFolder , File srcFolder , List <File > includeFolders ) throws RunnerException , PreferencesMapException {
953
950
compileFilesInFolder (srcBuildFolder , srcFolder , includeFolders );
954
951
for (File subFolder : srcFolder .listFiles (new OnlyDirs ())) {
955
952
File subBuildFolder = new File (srcBuildFolder , subFolder .getName ());
956
953
recursiveCompileFilesInFolder (subBuildFolder , subFolder , includeFolders );
957
954
}
958
955
}
959
956
960
- private void compileFilesInFolder (File buildFolder , File srcFolder , List <File > includeFolders ) throws RunnerException {
957
+ private void compileFilesInFolder (File buildFolder , File srcFolder , List <File > includeFolders ) throws RunnerException , PreferencesMapException {
961
958
createFolder (buildFolder );
962
959
List <File > objects = compileFiles (buildFolder , srcFolder , false , includeFolders );
963
960
objectFiles .addAll (objects );
@@ -968,7 +965,7 @@ private void compileFilesInFolder(File buildFolder, File srcFolder, List<File> i
968
965
// Also compiles the variant (if it supplies actual source files),
969
966
// which are included in the link directly (not through core.a)
970
967
void compileCore ()
971
- throws RunnerException {
968
+ throws RunnerException , PreferencesMapException {
972
969
973
970
File coreFolder = prefs .getFile ("build.core.path" );
974
971
File variantFolder = prefs .getFile ("build.variant.path" );
@@ -1024,8 +1021,8 @@ void compileCore()
1024
1021
dict .put ("object_file" , file .getAbsolutePath ());
1025
1022
1026
1023
String [] cmdArray ;
1024
+ String cmd = prefs .getOrExcept ("recipe.ar.pattern" );
1027
1025
try {
1028
- String cmd = prefs .get ("recipe.ar.pattern" );
1029
1026
cmdArray = StringReplacer .formatAndSplit (cmd , dict , true );
1030
1027
} catch (Exception e ) {
1031
1028
throw new RunnerException (e );
@@ -1040,7 +1037,7 @@ void compileCore()
1040
1037
1041
1038
// 4. link it all together into the .elf file
1042
1039
void compileLink ()
1043
- throws RunnerException {
1040
+ throws RunnerException , PreferencesMapException {
1044
1041
1045
1042
// TODO: Make the --relax thing in configuration files.
1046
1043
@@ -1063,8 +1060,8 @@ void compileLink()
1063
1060
dict .put ("ide_version" , "" + BaseNoGui .REVISION );
1064
1061
1065
1062
String [] cmdArray ;
1063
+ String cmd = prefs .getOrExcept ("recipe.c.combine.pattern" );
1066
1064
try {
1067
- String cmd = prefs .get ("recipe.c.combine.pattern" );
1068
1065
cmdArray = StringReplacer .formatAndSplit (cmd , dict , true );
1069
1066
} catch (Exception e ) {
1070
1067
throw new RunnerException (e );
@@ -1073,13 +1070,13 @@ void compileLink()
1073
1070
}
1074
1071
1075
1072
// 5. extract EEPROM data (from EEMEM directive) to .eep file.
1076
- void compileEep () throws RunnerException {
1073
+ void compileEep () throws RunnerException , PreferencesMapException {
1077
1074
PreferencesMap dict = new PreferencesMap (prefs );
1078
1075
dict .put ("ide_version" , "" + BaseNoGui .REVISION );
1079
1076
1080
1077
String [] cmdArray ;
1078
+ String cmd = prefs .getOrExcept ("recipe.objcopy.eep.pattern" );
1081
1079
try {
1082
- String cmd = prefs .get ("recipe.objcopy.eep.pattern" );
1083
1080
cmdArray = StringReplacer .formatAndSplit (cmd , dict , true );
1084
1081
} catch (Exception e ) {
1085
1082
throw new RunnerException (e );
@@ -1088,13 +1085,13 @@ void compileEep() throws RunnerException {
1088
1085
}
1089
1086
1090
1087
// 6. build the .hex file
1091
- void compileHex () throws RunnerException {
1088
+ void compileHex () throws RunnerException , PreferencesMapException {
1092
1089
PreferencesMap dict = new PreferencesMap (prefs );
1093
1090
dict .put ("ide_version" , "" + BaseNoGui .REVISION );
1094
1091
1095
1092
String [] cmdArray ;
1093
+ String cmd = prefs .getOrExcept ("recipe.objcopy.hex.pattern" );
1096
1094
try {
1097
- String cmd = prefs .get ("recipe.objcopy.hex.pattern" );
1098
1095
cmdArray = StringReplacer .formatAndSplit (cmd , dict , true );
1099
1096
} catch (Exception e ) {
1100
1097
throw new RunnerException (e );
0 commit comments