Skip to content

Commit 72c4404

Browse files
committed
Fixed compile process up to step 4. asyncExec cannot have null argmuments from the array.
1 parent b0556c2 commit 72c4404

File tree

1 file changed

+94
-38
lines changed

1 file changed

+94
-38
lines changed

app/src/processing/app/debug/Compiler.java

+94-38
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,19 @@ public boolean compile(Sketch sketch,
9797
platformPreferences = new HashMap(Base.getPlatformPreferences(platform));
9898
}
9999

100-
100+
System.out.println("////////////////////////////compiler.java is doing stuff/////////////////");
101101
//Put all the global preference configuration into one Master configpreferences
102102
configPreferences = mergePreferences( Preferences.getMap(), platformPreferences, boardPreferences);
103103
avrBasePath = configPreferences.get("compiler.path");
104104
if (avrBasePath == null)
105105
{
106106
avrBasePath = Base.getAvrBasePath();
107+
System.out.println("avrBasePath: " + avrBasePath);
107108
}
108109
else
109110
{
111+
System.out.println("avrBasePath:exists: " + avrBasePath);
112+
110113
//Put in the system path in the compiler path if available
111114
MessageFormat compileFormat = new MessageFormat(avrBasePath);
112115
String basePath = System.getProperty("user.dir");
@@ -116,6 +119,8 @@ public boolean compile(Sketch sketch,
116119
}
117120
Object[] Args = {basePath};
118121
avrBasePath = compileFormat.format( Args );
122+
System.out.println("avrBasePath:new: " + avrBasePath);
123+
119124

120125
}
121126
this.board = configPreferences.get("board");
@@ -159,7 +164,7 @@ public boolean compile(Sketch sketch,
159164
}
160165
}
161166

162-
List<File> objectFiles = new ArrayList<File>();
167+
objectFiles = new ArrayList<File>();
163168

164169
// 0. include paths for core + all libraries
165170

@@ -171,6 +176,7 @@ public boolean compile(Sketch sketch,
171176
}
172177

173178
// 1. compile the sketch (already in the buildPath)
179+
System.out.println("1. compileSketch");
174180
compileSketch(avrBasePath, buildPath, includePaths, configPreferences);
175181
/*
176182
objectFiles.addAll(
@@ -182,6 +188,12 @@ public boolean compile(Sketch sketch,
182188
*/
183189

184190
// 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+
/*
185197
186198
for (File libraryFolder : sketch.getImportedLibraries()) {
187199
File outputFolder = new File(buildPath, libraryFolder.getName());
@@ -206,9 +218,15 @@ public boolean compile(Sketch sketch,
206218
// other libraries should not see this library's utility/ folder
207219
includePaths.remove(includePaths.size() - 1);
208220
}
221+
*/
209222

210223
// 3. compile the core, outputting .o files to <buildPath> and then
211224
// 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+
212230
/*
213231
includePaths.clear();
214232
includePaths.add(corePath); // include path for core only
@@ -233,6 +251,9 @@ public boolean compile(Sketch sketch,
233251
}
234252
*/
235253
// 4. link it all together into the .elf file
254+
System.out.println("4. compileLink");
255+
compileLink(avrBasePath, buildPath, corePath, includePaths, configPreferences);
256+
236257
/*
237258
List baseCommandLinker = new ArrayList(Arrays.asList(new String[] {
238259
avrBasePath + "avr-gcc",
@@ -263,6 +284,9 @@ public boolean compile(Sketch sketch,
263284
*/
264285

265286
// 5. extract EEPROM data (from EEMEM directive) to .eep file.
287+
System.out.println("5. compileEep");
288+
compileEep(avrBasePath, buildPath, includePaths, configPreferences);
289+
266290
/*
267291
commandObjcopy = new ArrayList(baseCommandObjcopy);
268292
commandObjcopy.add(2, "ihex");
@@ -275,8 +299,13 @@ public boolean compile(Sketch sketch,
275299
commandObjcopy.add(buildPath + File.separator + primaryClassName + ".elf");
276300
commandObjcopy.add(buildPath + File.separator + primaryClassName + ".eep");
277301
execAsynchronously(commandObjcopy);
302+
*/
278303

279304
// 6. build the .hex file
305+
System.out.println("6. compileHex");
306+
compileHex(avrBasePath, buildPath, includePaths, configPreferences);
307+
308+
/*
280309
commandObjcopy = new ArrayList(baseCommandObjcopy);
281310
commandObjcopy.add(2, "ihex");
282311
commandObjcopy.add(".eeprom"); // remove eeprom data
@@ -383,8 +412,17 @@ private List<File> compileFiles(String avrBasePath,
383412
* Either succeeds or throws a RunnerException fit for public consumption.
384413
*/
385414
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+
388426
int result = 0;
389427

390428
if (verbose || Preferences.getBoolean("build.verbose")) {
@@ -443,6 +481,7 @@ private void execAsynchronously(String[] command) throws RunnerException {
443481
re.hideStackTrace();
444482
throw re;
445483
}
484+
System.out.println("execAsync: Done.");
446485
}
447486

448487

@@ -675,8 +714,15 @@ static private String[] getCommandCompilerCPP(String avrBasePath,
675714
};
676715

677716
String command = compileFormat.format( Args );
678-
System.out.println("command:" + command);
679717
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+
*/
680726
return commandArray;
681727
}
682728

@@ -706,6 +752,7 @@ public boolean accept(File dir, String name) {
706752

707753
static public ArrayList<File> findFilesInPath(String path, String extension,
708754
boolean recurse) {
755+
System.out.println("findFilesInPath: " + path);
709756
return findFilesInFolder(new File(path), extension, recurse);
710757
}
711758

@@ -747,46 +794,49 @@ void compileSketch(String avrBasePath, String buildPath, ArrayList<String> inclu
747794
void compileLibraries (String avrBasePath, String buildPath, ArrayList<String> includePaths, HashMap<String, String> configPreferences)
748795
throws RunnerException
749796
{
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+
}
776824

777825
// 3. compile the core, outputting .o files to <buildPath> and then
778826
// 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)
780828
throws RunnerException
781829
{
782-
//logger.debug("compileCore(...) start");
830+
System.out.println("compileCore(...) start");
783831

784832
ArrayList<String> includePaths = new ArrayList();
785833
includePaths.add(corePath); //include core path only
834+
if (pinsPath != null) includePaths.add(pinsPath);
835+
786836
String baseCommandString = configPreferences.get("recipe.ar.pattern");
787837
String commandString = "";
788838
MessageFormat compileFormat = new MessageFormat(baseCommandString);
789-
839+
System.out.println("corePath: " + corePath);
790840
List<File> coreObjectFiles = compileFiles(
791841
avrBasePath,
792842
buildPath,
@@ -810,6 +860,7 @@ void compileCore (String avrBasePath, String buildPath, String corePath, HashMap
810860
//objectName
811861
file.getAbsolutePath()
812862
};
863+
System.out.println("compileCore(...) substitute");
813864

814865
commandString = compileFormat.format( Args );
815866
String[] commandArray = commandString.split(",");
@@ -823,15 +874,17 @@ void compileCore (String avrBasePath, String buildPath, String corePath, HashMap
823874
void compileLink(String avrBasePath, String buildPath, String corePath, ArrayList<String> includePaths, HashMap<String, String> configPreferences)
824875
throws RunnerException
825876
{
826-
//logger.debug("compileLink: start");
877+
System.out.println("compileLink: start");
827878
String baseCommandString = configPreferences.get("recipe.c.combine.pattern");
879+
System.out.println("baseCommandstring: " + baseCommandString);
828880
String commandString = "";
829881
MessageFormat compileFormat = new MessageFormat(baseCommandString);
830882
String objectFileList = "";
831883

832884
for (File file : objectFiles) {
833885
objectFileList = objectFileList + file.getAbsolutePath() + ",";
834886
}
887+
System.out.println("objectFileList: " + objectFileList);
835888

836889
Object[] Args = {
837890
avrBasePath,
@@ -848,6 +901,12 @@ void compileLink(String avrBasePath, String buildPath, String corePath, ArrayLis
848901
configPreferences.get("ldscript"),
849902
};
850903
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");
851910
execAsynchronously(commandArray);
852911
}
853912

@@ -894,9 +953,6 @@ void compileHex (String avrBasePath, String buildPath, ArrayList<String> include
894953
String[] commandArray = commandString.split(",");
895954
execAsynchronously(commandArray);
896955
}
897-
898-
899-
900956

901957
//merge all the preferences file in the correct order of precedence
902958
HashMap mergePreferences(Map Preferences, Map platformPreferences, Map boardPreferences)

0 commit comments

Comments
 (0)