mirror of
https://github.com/arduino/Arduino.git
synced 2025-03-15 12:29:26 +01:00
Fixed compile process up to step 4. asyncExec cannot have null argmuments from the array.
This commit is contained in:
parent
b0556c2e74
commit
72c4404c6d
@ -97,16 +97,19 @@ public class Compiler implements MessageConsumer {
|
|||||||
platformPreferences = new HashMap(Base.getPlatformPreferences(platform));
|
platformPreferences = new HashMap(Base.getPlatformPreferences(platform));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
System.out.println("////////////////////////////compiler.java is doing stuff/////////////////");
|
||||||
//Put all the global preference configuration into one Master configpreferences
|
//Put all the global preference configuration into one Master configpreferences
|
||||||
configPreferences = mergePreferences( Preferences.getMap(), platformPreferences, boardPreferences);
|
configPreferences = mergePreferences( Preferences.getMap(), platformPreferences, boardPreferences);
|
||||||
avrBasePath = configPreferences.get("compiler.path");
|
avrBasePath = configPreferences.get("compiler.path");
|
||||||
if (avrBasePath == null)
|
if (avrBasePath == null)
|
||||||
{
|
{
|
||||||
avrBasePath = Base.getAvrBasePath();
|
avrBasePath = Base.getAvrBasePath();
|
||||||
|
System.out.println("avrBasePath: " + avrBasePath);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
System.out.println("avrBasePath:exists: " + avrBasePath);
|
||||||
|
|
||||||
//Put in the system path in the compiler path if available
|
//Put in the system path in the compiler path if available
|
||||||
MessageFormat compileFormat = new MessageFormat(avrBasePath);
|
MessageFormat compileFormat = new MessageFormat(avrBasePath);
|
||||||
String basePath = System.getProperty("user.dir");
|
String basePath = System.getProperty("user.dir");
|
||||||
@ -116,6 +119,8 @@ public class Compiler implements MessageConsumer {
|
|||||||
}
|
}
|
||||||
Object[] Args = {basePath};
|
Object[] Args = {basePath};
|
||||||
avrBasePath = compileFormat.format( Args );
|
avrBasePath = compileFormat.format( Args );
|
||||||
|
System.out.println("avrBasePath:new: " + avrBasePath);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
this.board = configPreferences.get("board");
|
this.board = configPreferences.get("board");
|
||||||
@ -159,7 +164,7 @@ public class Compiler implements MessageConsumer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<File> objectFiles = new ArrayList<File>();
|
objectFiles = new ArrayList<File>();
|
||||||
|
|
||||||
// 0. include paths for core + all libraries
|
// 0. include paths for core + all libraries
|
||||||
|
|
||||||
@ -171,6 +176,7 @@ public class Compiler implements MessageConsumer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 1. compile the sketch (already in the buildPath)
|
// 1. compile the sketch (already in the buildPath)
|
||||||
|
System.out.println("1. compileSketch");
|
||||||
compileSketch(avrBasePath, buildPath, includePaths, configPreferences);
|
compileSketch(avrBasePath, buildPath, includePaths, configPreferences);
|
||||||
/*
|
/*
|
||||||
objectFiles.addAll(
|
objectFiles.addAll(
|
||||||
@ -182,6 +188,12 @@ public class Compiler implements MessageConsumer {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// 2. compile the libraries, outputting .o files to: <buildPath>/<library>/
|
// 2. compile the libraries, outputting .o files to: <buildPath>/<library>/
|
||||||
|
// 2. compile the libraries, outputting .o files to:
|
||||||
|
// <buildPath>/<library>/
|
||||||
|
//Doesn't really use configPreferences
|
||||||
|
System.out.println("2. compileLibraries");
|
||||||
|
compileLibraries(avrBasePath, buildPath, includePaths, configPreferences);
|
||||||
|
/*
|
||||||
|
|
||||||
for (File libraryFolder : sketch.getImportedLibraries()) {
|
for (File libraryFolder : sketch.getImportedLibraries()) {
|
||||||
File outputFolder = new File(buildPath, libraryFolder.getName());
|
File outputFolder = new File(buildPath, libraryFolder.getName());
|
||||||
@ -206,9 +218,15 @@ public class Compiler implements MessageConsumer {
|
|||||||
// other libraries should not see this library's utility/ folder
|
// other libraries should not see this library's utility/ folder
|
||||||
includePaths.remove(includePaths.size() - 1);
|
includePaths.remove(includePaths.size() - 1);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
// 3. compile the core, outputting .o files to <buildPath> and then
|
// 3. compile the core, outputting .o files to <buildPath> and then
|
||||||
// collecting them into the core.a library file.
|
// collecting them into the core.a library file.
|
||||||
|
System.out.println("3. compileCore");
|
||||||
|
System.out.println("corePath: " + corePath);
|
||||||
|
compileCore(avrBasePath, buildPath, corePath, pins, pinsPath, configPreferences);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
includePaths.clear();
|
includePaths.clear();
|
||||||
includePaths.add(corePath); // include path for core only
|
includePaths.add(corePath); // include path for core only
|
||||||
@ -233,6 +251,9 @@ public class Compiler implements MessageConsumer {
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
// 4. link it all together into the .elf file
|
// 4. link it all together into the .elf file
|
||||||
|
System.out.println("4. compileLink");
|
||||||
|
compileLink(avrBasePath, buildPath, corePath, includePaths, configPreferences);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
List baseCommandLinker = new ArrayList(Arrays.asList(new String[] {
|
List baseCommandLinker = new ArrayList(Arrays.asList(new String[] {
|
||||||
avrBasePath + "avr-gcc",
|
avrBasePath + "avr-gcc",
|
||||||
@ -263,6 +284,9 @@ public class Compiler implements MessageConsumer {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// 5. extract EEPROM data (from EEMEM directive) to .eep file.
|
// 5. extract EEPROM data (from EEMEM directive) to .eep file.
|
||||||
|
System.out.println("5. compileEep");
|
||||||
|
compileEep(avrBasePath, buildPath, includePaths, configPreferences);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
commandObjcopy = new ArrayList(baseCommandObjcopy);
|
commandObjcopy = new ArrayList(baseCommandObjcopy);
|
||||||
commandObjcopy.add(2, "ihex");
|
commandObjcopy.add(2, "ihex");
|
||||||
@ -275,8 +299,13 @@ public class Compiler implements MessageConsumer {
|
|||||||
commandObjcopy.add(buildPath + File.separator + primaryClassName + ".elf");
|
commandObjcopy.add(buildPath + File.separator + primaryClassName + ".elf");
|
||||||
commandObjcopy.add(buildPath + File.separator + primaryClassName + ".eep");
|
commandObjcopy.add(buildPath + File.separator + primaryClassName + ".eep");
|
||||||
execAsynchronously(commandObjcopy);
|
execAsynchronously(commandObjcopy);
|
||||||
|
*/
|
||||||
|
|
||||||
// 6. build the .hex file
|
// 6. build the .hex file
|
||||||
|
System.out.println("6. compileHex");
|
||||||
|
compileHex(avrBasePath, buildPath, includePaths, configPreferences);
|
||||||
|
|
||||||
|
/*
|
||||||
commandObjcopy = new ArrayList(baseCommandObjcopy);
|
commandObjcopy = new ArrayList(baseCommandObjcopy);
|
||||||
commandObjcopy.add(2, "ihex");
|
commandObjcopy.add(2, "ihex");
|
||||||
commandObjcopy.add(".eeprom"); // remove eeprom data
|
commandObjcopy.add(".eeprom"); // remove eeprom data
|
||||||
@ -383,8 +412,17 @@ public class Compiler implements MessageConsumer {
|
|||||||
* Either succeeds or throws a RunnerException fit for public consumption.
|
* Either succeeds or throws a RunnerException fit for public consumption.
|
||||||
*/
|
*/
|
||||||
private void execAsynchronously(String[] command) throws RunnerException {
|
private void execAsynchronously(String[] command) throws RunnerException {
|
||||||
// String[] command = new String[commandList.size()];
|
|
||||||
//commandList.toArray(command);
|
//eliminate any empty array entries
|
||||||
|
List<String> stringList = new ArrayList<String>();
|
||||||
|
for(String string : command) {
|
||||||
|
string = string.trim();
|
||||||
|
if(string != null && string.length() > 0) {
|
||||||
|
stringList.add(string);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
command = stringList.toArray(new String[stringList.size()]);
|
||||||
|
|
||||||
int result = 0;
|
int result = 0;
|
||||||
|
|
||||||
if (verbose || Preferences.getBoolean("build.verbose")) {
|
if (verbose || Preferences.getBoolean("build.verbose")) {
|
||||||
@ -443,6 +481,7 @@ public class Compiler implements MessageConsumer {
|
|||||||
re.hideStackTrace();
|
re.hideStackTrace();
|
||||||
throw re;
|
throw re;
|
||||||
}
|
}
|
||||||
|
System.out.println("execAsync: Done.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -675,8 +714,15 @@ public class Compiler implements MessageConsumer {
|
|||||||
};
|
};
|
||||||
|
|
||||||
String command = compileFormat.format( Args );
|
String command = compileFormat.format( Args );
|
||||||
System.out.println("command:" + command);
|
|
||||||
String[] commandArray = command.split(",");
|
String[] commandArray = command.split(",");
|
||||||
|
|
||||||
|
/*
|
||||||
|
System.out.println("command:" + command);
|
||||||
|
for (int ii = 0; ii < commandArray.length; ii++)
|
||||||
|
{
|
||||||
|
System.out.println("'" + commandArray[ii] + "'");
|
||||||
|
}
|
||||||
|
*/
|
||||||
return commandArray;
|
return commandArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -706,6 +752,7 @@ public class Compiler implements MessageConsumer {
|
|||||||
|
|
||||||
static public ArrayList<File> findFilesInPath(String path, String extension,
|
static public ArrayList<File> findFilesInPath(String path, String extension,
|
||||||
boolean recurse) {
|
boolean recurse) {
|
||||||
|
System.out.println("findFilesInPath: " + path);
|
||||||
return findFilesInFolder(new File(path), extension, recurse);
|
return findFilesInFolder(new File(path), extension, recurse);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -747,46 +794,49 @@ public class Compiler implements MessageConsumer {
|
|||||||
void compileLibraries (String avrBasePath, String buildPath, ArrayList<String> includePaths, HashMap<String, String> configPreferences)
|
void compileLibraries (String avrBasePath, String buildPath, ArrayList<String> includePaths, HashMap<String, String> configPreferences)
|
||||||
throws RunnerException
|
throws RunnerException
|
||||||
{
|
{
|
||||||
//logger.debug("compileLibraries: start");
|
System.out.println("compileLibraries: start");
|
||||||
for (File libraryFolder : sketch.getImportedLibraries())
|
|
||||||
{
|
for (File libraryFolder : sketch.getImportedLibraries()) {
|
||||||
|
System.out.println("libraryFolder: " + libraryFolder);
|
||||||
File outputFolder = new File(buildPath, libraryFolder.getName());
|
File outputFolder = new File(buildPath, libraryFolder.getName());
|
||||||
File utilityFolder = new File(libraryFolder, "utility");
|
File utilityFolder = new File(libraryFolder, "utility");
|
||||||
createFolder(outputFolder);
|
createFolder(outputFolder);
|
||||||
// this library can use includes in its utility/ folder
|
// this library can use includes in its utility/ folder
|
||||||
this.includePaths.add(utilityFolder.getAbsolutePath());
|
includePaths.add(utilityFolder.getAbsolutePath());
|
||||||
this.objectFiles.addAll(compileFiles(avrBasePath,
|
objectFiles.addAll(
|
||||||
outputFolder.getAbsolutePath(), includePaths,
|
compileFiles(avrBasePath, outputFolder.getAbsolutePath(), includePaths,
|
||||||
findFilesInFolder(libraryFolder, "S", false),
|
findFilesInFolder(libraryFolder, "S", false),
|
||||||
findFilesInFolder(libraryFolder, "c", false),
|
findFilesInFolder(libraryFolder, "c", false),
|
||||||
findFilesInFolder(libraryFolder, "cpp", false),
|
findFilesInFolder(libraryFolder, "cpp", false),
|
||||||
configPreferences));
|
boardPreferences));
|
||||||
outputFolder = new File(outputFolder, "utility");
|
outputFolder = new File(outputFolder, "utility");
|
||||||
createFolder(outputFolder);
|
createFolder(outputFolder);
|
||||||
this.objectFiles.addAll(compileFiles(avrBasePath,
|
objectFiles.addAll(
|
||||||
outputFolder.getAbsolutePath(), includePaths,
|
compileFiles(avrBasePath, outputFolder.getAbsolutePath(), includePaths,
|
||||||
findFilesInFolder(utilityFolder, "S", false),
|
findFilesInFolder(utilityFolder, "S", false),
|
||||||
findFilesInFolder(utilityFolder, "c", false),
|
findFilesInFolder(utilityFolder, "c", false),
|
||||||
findFilesInFolder(utilityFolder, "cpp", false),
|
findFilesInFolder(utilityFolder, "cpp", false),
|
||||||
configPreferences));
|
boardPreferences));
|
||||||
// other libraries should not see this library's utility/ folder
|
// other libraries should not see this library's utility/ folder
|
||||||
this.includePaths.remove(includePaths.size() - 1);
|
includePaths.remove(includePaths.size() - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. compile the core, outputting .o files to <buildPath> and then
|
// 3. compile the core, outputting .o files to <buildPath> and then
|
||||||
// collecting them into the core.a library file.
|
// collecting them into the core.a library file.
|
||||||
void compileCore (String avrBasePath, String buildPath, String corePath, HashMap<String, String> configPreferences)
|
void compileCore (String avrBasePath, String buildPath, String corePath, String pins, String pinsPath, HashMap<String, String> configPreferences)
|
||||||
throws RunnerException
|
throws RunnerException
|
||||||
{
|
{
|
||||||
//logger.debug("compileCore(...) start");
|
System.out.println("compileCore(...) start");
|
||||||
|
|
||||||
ArrayList<String> includePaths = new ArrayList();
|
ArrayList<String> includePaths = new ArrayList();
|
||||||
includePaths.add(corePath); //include core path only
|
includePaths.add(corePath); //include core path only
|
||||||
|
if (pinsPath != null) includePaths.add(pinsPath);
|
||||||
|
|
||||||
String baseCommandString = configPreferences.get("recipe.ar.pattern");
|
String baseCommandString = configPreferences.get("recipe.ar.pattern");
|
||||||
String commandString = "";
|
String commandString = "";
|
||||||
MessageFormat compileFormat = new MessageFormat(baseCommandString);
|
MessageFormat compileFormat = new MessageFormat(baseCommandString);
|
||||||
|
System.out.println("corePath: " + corePath);
|
||||||
List<File> coreObjectFiles = compileFiles(
|
List<File> coreObjectFiles = compileFiles(
|
||||||
avrBasePath,
|
avrBasePath,
|
||||||
buildPath,
|
buildPath,
|
||||||
@ -810,6 +860,7 @@ public class Compiler implements MessageConsumer {
|
|||||||
//objectName
|
//objectName
|
||||||
file.getAbsolutePath()
|
file.getAbsolutePath()
|
||||||
};
|
};
|
||||||
|
System.out.println("compileCore(...) substitute");
|
||||||
|
|
||||||
commandString = compileFormat.format( Args );
|
commandString = compileFormat.format( Args );
|
||||||
String[] commandArray = commandString.split(",");
|
String[] commandArray = commandString.split(",");
|
||||||
@ -823,8 +874,9 @@ public class Compiler implements MessageConsumer {
|
|||||||
void compileLink(String avrBasePath, String buildPath, String corePath, ArrayList<String> includePaths, HashMap<String, String> configPreferences)
|
void compileLink(String avrBasePath, String buildPath, String corePath, ArrayList<String> includePaths, HashMap<String, String> configPreferences)
|
||||||
throws RunnerException
|
throws RunnerException
|
||||||
{
|
{
|
||||||
//logger.debug("compileLink: start");
|
System.out.println("compileLink: start");
|
||||||
String baseCommandString = configPreferences.get("recipe.c.combine.pattern");
|
String baseCommandString = configPreferences.get("recipe.c.combine.pattern");
|
||||||
|
System.out.println("baseCommandstring: " + baseCommandString);
|
||||||
String commandString = "";
|
String commandString = "";
|
||||||
MessageFormat compileFormat = new MessageFormat(baseCommandString);
|
MessageFormat compileFormat = new MessageFormat(baseCommandString);
|
||||||
String objectFileList = "";
|
String objectFileList = "";
|
||||||
@ -832,6 +884,7 @@ public class Compiler implements MessageConsumer {
|
|||||||
for (File file : objectFiles) {
|
for (File file : objectFiles) {
|
||||||
objectFileList = objectFileList + file.getAbsolutePath() + ",";
|
objectFileList = objectFileList + file.getAbsolutePath() + ",";
|
||||||
}
|
}
|
||||||
|
System.out.println("objectFileList: " + objectFileList);
|
||||||
|
|
||||||
Object[] Args = {
|
Object[] Args = {
|
||||||
avrBasePath,
|
avrBasePath,
|
||||||
@ -848,6 +901,12 @@ public class Compiler implements MessageConsumer {
|
|||||||
configPreferences.get("ldscript"),
|
configPreferences.get("ldscript"),
|
||||||
};
|
};
|
||||||
String[] commandArray = commandString.split(",");
|
String[] commandArray = commandString.split(",");
|
||||||
|
System.out.println("commandString: " + commandString);
|
||||||
|
for (int ii = 0; ii < commandArray.length; ii++)
|
||||||
|
{
|
||||||
|
System.out.println("'" + commandArray[ii] + "'");
|
||||||
|
}
|
||||||
|
System.out.println("4. compileLink:prexec");
|
||||||
execAsynchronously(commandArray);
|
execAsynchronously(commandArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -895,9 +954,6 @@ public class Compiler implements MessageConsumer {
|
|||||||
execAsynchronously(commandArray);
|
execAsynchronously(commandArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//merge all the preferences file in the correct order of precedence
|
//merge all the preferences file in the correct order of precedence
|
||||||
HashMap mergePreferences(Map Preferences, Map platformPreferences, Map boardPreferences)
|
HashMap mergePreferences(Map Preferences, Map platformPreferences, Map boardPreferences)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user