@@ -97,16 +97,19 @@ public boolean compile(Sketch sketch,
97
97
platformPreferences = new HashMap (Base .getPlatformPreferences (platform ));
98
98
}
99
99
100
-
100
+ System . out . println ( "////////////////////////////compiler.java is doing stuff/////////////////" );
101
101
//Put all the global preference configuration into one Master configpreferences
102
102
configPreferences = mergePreferences ( Preferences .getMap (), platformPreferences , boardPreferences );
103
103
avrBasePath = configPreferences .get ("compiler.path" );
104
104
if (avrBasePath == null )
105
105
{
106
106
avrBasePath = Base .getAvrBasePath ();
107
+ System .out .println ("avrBasePath: " + avrBasePath );
107
108
}
108
109
else
109
110
{
111
+ System .out .println ("avrBasePath:exists: " + avrBasePath );
112
+
110
113
//Put in the system path in the compiler path if available
111
114
MessageFormat compileFormat = new MessageFormat (avrBasePath );
112
115
String basePath = System .getProperty ("user.dir" );
@@ -116,6 +119,8 @@ public boolean compile(Sketch sketch,
116
119
}
117
120
Object [] Args = {basePath };
118
121
avrBasePath = compileFormat .format ( Args );
122
+ System .out .println ("avrBasePath:new: " + avrBasePath );
123
+
119
124
120
125
}
121
126
this .board = configPreferences .get ("board" );
@@ -159,7 +164,7 @@ public boolean compile(Sketch sketch,
159
164
}
160
165
}
161
166
162
- List < File > objectFiles = new ArrayList <File >();
167
+ objectFiles = new ArrayList <File >();
163
168
164
169
// 0. include paths for core + all libraries
165
170
@@ -171,6 +176,7 @@ public boolean compile(Sketch sketch,
171
176
}
172
177
173
178
// 1. compile the sketch (already in the buildPath)
179
+ System .out .println ("1. compileSketch" );
174
180
compileSketch (avrBasePath , buildPath , includePaths , configPreferences );
175
181
/*
176
182
objectFiles.addAll(
@@ -182,6 +188,12 @@ public boolean compile(Sketch sketch,
182
188
*/
183
189
184
190
// 2. compile the libraries, outputting .o files to: <buildPath>/<library>/
191
+ // 2. compile the libraries, outputting .o files to:
192
+ // <buildPath>/<library>/
193
+ //Doesn't really use configPreferences
194
+ System .out .println ("2. compileLibraries" );
195
+ compileLibraries (avrBasePath , buildPath , includePaths , configPreferences );
196
+ /*
185
197
186
198
for (File libraryFolder : sketch.getImportedLibraries()) {
187
199
File outputFolder = new File(buildPath, libraryFolder.getName());
@@ -206,9 +218,15 @@ public boolean compile(Sketch sketch,
206
218
// other libraries should not see this library's utility/ folder
207
219
includePaths.remove(includePaths.size() - 1);
208
220
}
221
+ */
209
222
210
223
// 3. compile the core, outputting .o files to <buildPath> and then
211
224
// collecting them into the core.a library file.
225
+ System .out .println ("3. compileCore" );
226
+ System .out .println ("corePath: " + corePath );
227
+ compileCore (avrBasePath , buildPath , corePath , pins , pinsPath , configPreferences );
228
+
229
+
212
230
/*
213
231
includePaths.clear();
214
232
includePaths.add(corePath); // include path for core only
@@ -233,6 +251,9 @@ public boolean compile(Sketch sketch,
233
251
}
234
252
*/
235
253
// 4. link it all together into the .elf file
254
+ System .out .println ("4. compileLink" );
255
+ compileLink (avrBasePath , buildPath , corePath , includePaths , configPreferences );
256
+
236
257
/*
237
258
List baseCommandLinker = new ArrayList(Arrays.asList(new String[] {
238
259
avrBasePath + "avr-gcc",
@@ -263,6 +284,9 @@ public boolean compile(Sketch sketch,
263
284
*/
264
285
265
286
// 5. extract EEPROM data (from EEMEM directive) to .eep file.
287
+ System .out .println ("5. compileEep" );
288
+ compileEep (avrBasePath , buildPath , includePaths , configPreferences );
289
+
266
290
/*
267
291
commandObjcopy = new ArrayList(baseCommandObjcopy);
268
292
commandObjcopy.add(2, "ihex");
@@ -275,8 +299,13 @@ public boolean compile(Sketch sketch,
275
299
commandObjcopy.add(buildPath + File.separator + primaryClassName + ".elf");
276
300
commandObjcopy.add(buildPath + File.separator + primaryClassName + ".eep");
277
301
execAsynchronously(commandObjcopy);
302
+ */
278
303
279
304
// 6. build the .hex file
305
+ System .out .println ("6. compileHex" );
306
+ compileHex (avrBasePath , buildPath , includePaths , configPreferences );
307
+
308
+ /*
280
309
commandObjcopy = new ArrayList(baseCommandObjcopy);
281
310
commandObjcopy.add(2, "ihex");
282
311
commandObjcopy.add(".eeprom"); // remove eeprom data
@@ -383,8 +412,17 @@ private List<File> compileFiles(String avrBasePath,
383
412
* Either succeeds or throws a RunnerException fit for public consumption.
384
413
*/
385
414
private void execAsynchronously (String [] command ) throws RunnerException {
386
- // String[] command = new String[commandList.size()];
387
- //commandList.toArray(command);
415
+
416
+ //eliminate any empty array entries
417
+ List <String > stringList = new ArrayList <String >();
418
+ for (String string : command ) {
419
+ string = string .trim ();
420
+ if (string != null && string .length () > 0 ) {
421
+ stringList .add (string );
422
+ }
423
+ }
424
+ command = stringList .toArray (new String [stringList .size ()]);
425
+
388
426
int result = 0 ;
389
427
390
428
if (verbose || Preferences .getBoolean ("build.verbose" )) {
@@ -443,6 +481,7 @@ private void execAsynchronously(String[] command) throws RunnerException {
443
481
re .hideStackTrace ();
444
482
throw re ;
445
483
}
484
+ System .out .println ("execAsync: Done." );
446
485
}
447
486
448
487
@@ -675,8 +714,15 @@ static private String[] getCommandCompilerCPP(String avrBasePath,
675
714
};
676
715
677
716
String command = compileFormat .format ( Args );
678
- System .out .println ("command:" + command );
679
717
String [] commandArray = command .split ("," );
718
+
719
+ /*
720
+ System.out.println("command:" + command);
721
+ for (int ii = 0; ii < commandArray.length; ii++)
722
+ {
723
+ System.out.println("'" + commandArray[ii] + "'");
724
+ }
725
+ */
680
726
return commandArray ;
681
727
}
682
728
@@ -706,6 +752,7 @@ public boolean accept(File dir, String name) {
706
752
707
753
static public ArrayList <File > findFilesInPath (String path , String extension ,
708
754
boolean recurse ) {
755
+ System .out .println ("findFilesInPath: " + path );
709
756
return findFilesInFolder (new File (path ), extension , recurse );
710
757
}
711
758
@@ -747,46 +794,49 @@ void compileSketch(String avrBasePath, String buildPath, ArrayList<String> inclu
747
794
void compileLibraries (String avrBasePath , String buildPath , ArrayList <String > includePaths , HashMap <String , String > configPreferences )
748
795
throws RunnerException
749
796
{
750
- //logger.debug("compileLibraries: start");
751
- for (File libraryFolder : sketch .getImportedLibraries ())
752
- {
753
- File outputFolder = new File (buildPath , libraryFolder .getName ());
754
- File utilityFolder = new File (libraryFolder , "utility" );
755
- createFolder (outputFolder );
756
- // this library can use includes in its utility/ folder
757
- this .includePaths .add (utilityFolder .getAbsolutePath ());
758
- this .objectFiles .addAll (compileFiles (avrBasePath ,
759
- outputFolder .getAbsolutePath (), includePaths ,
760
- findFilesInFolder (libraryFolder , "S" , false ),
761
- findFilesInFolder (libraryFolder , "c" , false ),
762
- findFilesInFolder (libraryFolder , "cpp" , false ),
763
- configPreferences ));
764
- outputFolder = new File (outputFolder , "utility" );
765
- createFolder (outputFolder );
766
- this .objectFiles .addAll (compileFiles (avrBasePath ,
767
- outputFolder .getAbsolutePath (), includePaths ,
768
- findFilesInFolder (utilityFolder , "S" , false ),
769
- findFilesInFolder (utilityFolder , "c" , false ),
770
- findFilesInFolder (utilityFolder , "cpp" , false ),
771
- configPreferences ));
772
- // other libraries should not see this library's utility/ folder
773
- this .includePaths .remove (includePaths .size () - 1 );
774
- }
775
- }
797
+ System .out .println ("compileLibraries: start" );
798
+
799
+ for (File libraryFolder : sketch .getImportedLibraries ()) {
800
+ System .out .println ("libraryFolder: " + libraryFolder );
801
+ File outputFolder = new File (buildPath , libraryFolder .getName ());
802
+ File utilityFolder = new File (libraryFolder , "utility" );
803
+ createFolder (outputFolder );
804
+ // this library can use includes in its utility/ folder
805
+ includePaths .add (utilityFolder .getAbsolutePath ());
806
+ objectFiles .addAll (
807
+ compileFiles (avrBasePath , outputFolder .getAbsolutePath (), includePaths ,
808
+ findFilesInFolder (libraryFolder , "S" , false ),
809
+ findFilesInFolder (libraryFolder , "c" , false ),
810
+ findFilesInFolder (libraryFolder , "cpp" , false ),
811
+ boardPreferences ));
812
+ outputFolder = new File (outputFolder , "utility" );
813
+ createFolder (outputFolder );
814
+ objectFiles .addAll (
815
+ compileFiles (avrBasePath , outputFolder .getAbsolutePath (), includePaths ,
816
+ findFilesInFolder (utilityFolder , "S" , false ),
817
+ findFilesInFolder (utilityFolder , "c" , false ),
818
+ findFilesInFolder (utilityFolder , "cpp" , false ),
819
+ boardPreferences ));
820
+ // other libraries should not see this library's utility/ folder
821
+ includePaths .remove (includePaths .size () - 1 );
822
+ }
823
+ }
776
824
777
825
// 3. compile the core, outputting .o files to <buildPath> and then
778
826
// collecting them into the core.a library file.
779
- void compileCore (String avrBasePath , String buildPath , String corePath , HashMap <String , String > configPreferences )
827
+ void compileCore (String avrBasePath , String buildPath , String corePath , String pins , String pinsPath , HashMap <String , String > configPreferences )
780
828
throws RunnerException
781
829
{
782
- //logger.debug ("compileCore(...) start");
830
+ System . out . println ("compileCore(...) start" );
783
831
784
832
ArrayList <String > includePaths = new ArrayList ();
785
833
includePaths .add (corePath ); //include core path only
834
+ if (pinsPath != null ) includePaths .add (pinsPath );
835
+
786
836
String baseCommandString = configPreferences .get ("recipe.ar.pattern" );
787
837
String commandString = "" ;
788
838
MessageFormat compileFormat = new MessageFormat (baseCommandString );
789
-
839
+ System . out . println ( "corePath: " + corePath );
790
840
List <File > coreObjectFiles = compileFiles (
791
841
avrBasePath ,
792
842
buildPath ,
@@ -810,6 +860,7 @@ void compileCore (String avrBasePath, String buildPath, String corePath, HashMap
810
860
//objectName
811
861
file .getAbsolutePath ()
812
862
};
863
+ System .out .println ("compileCore(...) substitute" );
813
864
814
865
commandString = compileFormat .format ( Args );
815
866
String [] commandArray = commandString .split ("," );
@@ -823,15 +874,17 @@ void compileCore (String avrBasePath, String buildPath, String corePath, HashMap
823
874
void compileLink (String avrBasePath , String buildPath , String corePath , ArrayList <String > includePaths , HashMap <String , String > configPreferences )
824
875
throws RunnerException
825
876
{
826
- //logger.debug ("compileLink: start");
877
+ System . out . println ("compileLink: start" );
827
878
String baseCommandString = configPreferences .get ("recipe.c.combine.pattern" );
879
+ System .out .println ("baseCommandstring: " + baseCommandString );
828
880
String commandString = "" ;
829
881
MessageFormat compileFormat = new MessageFormat (baseCommandString );
830
882
String objectFileList = "" ;
831
883
832
884
for (File file : objectFiles ) {
833
885
objectFileList = objectFileList + file .getAbsolutePath () + "," ;
834
886
}
887
+ System .out .println ("objectFileList: " + objectFileList );
835
888
836
889
Object [] Args = {
837
890
avrBasePath ,
@@ -848,6 +901,12 @@ void compileLink(String avrBasePath, String buildPath, String corePath, ArrayLis
848
901
configPreferences .get ("ldscript" ),
849
902
};
850
903
String [] commandArray = commandString .split ("," );
904
+ System .out .println ("commandString: " + commandString );
905
+ for (int ii = 0 ; ii < commandArray .length ; ii ++)
906
+ {
907
+ System .out .println ("'" + commandArray [ii ] + "'" );
908
+ }
909
+ System .out .println ("4. compileLink:prexec" );
851
910
execAsynchronously (commandArray );
852
911
}
853
912
@@ -894,9 +953,6 @@ void compileHex (String avrBasePath, String buildPath, ArrayList<String> include
894
953
String [] commandArray = commandString .split ("," );
895
954
execAsynchronously (commandArray );
896
955
}
897
-
898
-
899
-
900
956
901
957
//merge all the preferences file in the correct order of precedence
902
958
HashMap mergePreferences (Map Preferences , Map platformPreferences , Map boardPreferences )
0 commit comments