1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-03-15 12:29:26 +01:00

Building sketch first (so errors appear faster).

http://code.google.com/p/arduino/issues/detail?id=393
This commit is contained in:
David A. Mellis 2010-11-27 11:39:42 -06:00
parent 5d9602a28a
commit 6750e679af

View File

@ -93,72 +93,72 @@ public class Compiler implements MessageConsumer {
List<File> objectFiles = new ArrayList<File>(); List<File> objectFiles = new ArrayList<File>();
List includePaths = new ArrayList(); // 0. include paths for core + all libraries
includePaths.add(corePath);
String runtimeLibraryName = buildPath + File.separator + "core.a"; List includePaths = new ArrayList();
includePaths.add(corePath);
for (File file : sketch.getImportedLibraries()) {
includePaths.add(file.getPath());
}
// 1. compile the core, outputting .o files to <buildPath> and then // 1. compile the sketch (already in the buildPath)
// collecting them into the core.a library file.
List<File> coreObjectFiles = objectFiles.addAll(
compileFiles(avrBasePath, buildPath, includePaths, compileFiles(avrBasePath, buildPath, includePaths,
findFilesInPath(corePath, "S", true), findFilesInPath(buildPath, "S", false),
findFilesInPath(corePath, "c", true), findFilesInPath(buildPath, "c", false),
findFilesInPath(corePath, "cpp", true), findFilesInPath(buildPath, "cpp", false),
boardPreferences); boardPreferences));
List baseCommandAR = new ArrayList(Arrays.asList(new String[] { // 2. compile the libraries, outputting .o files to: <buildPath>/<library>/
avrBasePath + "avr-ar",
"rcs",
runtimeLibraryName
}));
for(File file : coreObjectFiles) { for (File libraryFolder : sketch.getImportedLibraries()) {
List commandAR = new ArrayList(baseCommandAR); File outputFolder = new File(buildPath, libraryFolder.getName());
commandAR.add(file.getAbsolutePath()); File utilityFolder = new File(libraryFolder, "utility");
execAsynchronously(commandAR); createFolder(outputFolder);
} // this library can use includes in its utility/ folder
includePaths.add(utilityFolder.getAbsolutePath());
objectFiles.addAll(
compileFiles(avrBasePath, outputFolder.getAbsolutePath(), includePaths,
findFilesInFolder(libraryFolder, "S", false),
findFilesInFolder(libraryFolder, "c", false),
findFilesInFolder(libraryFolder, "cpp", false),
boardPreferences));
outputFolder = new File(outputFolder, "utility");
createFolder(outputFolder);
objectFiles.addAll(
compileFiles(avrBasePath, outputFolder.getAbsolutePath(), includePaths,
findFilesInFolder(utilityFolder, "S", false),
findFilesInFolder(utilityFolder, "c", false),
findFilesInFolder(utilityFolder, "cpp", false),
boardPreferences));
// other libraries should not see this library's utility/ folder
includePaths.remove(includePaths.size() - 1);
}
// 2. compile the libraries, outputting .o files to: <buildPath>/<library>/ // 3. compile the core, outputting .o files to <buildPath> and then
// collecting them into the core.a library file.
// use library directories as include paths for all libraries includePaths.clear();
for (File file : sketch.getImportedLibraries()) { includePaths.add(corePath); // include path for core only
includePaths.add(file.getPath()); List<File> coreObjectFiles =
} compileFiles(avrBasePath, buildPath, includePaths,
findFilesInPath(corePath, "S", true),
findFilesInPath(corePath, "c", true),
findFilesInPath(corePath, "cpp", true),
boardPreferences);
for (File libraryFolder : sketch.getImportedLibraries()) { String runtimeLibraryName = buildPath + File.separator + "core.a";
File outputFolder = new File(buildPath, libraryFolder.getName()); List baseCommandAR = new ArrayList(Arrays.asList(new String[] {
File utilityFolder = new File(libraryFolder, "utility"); avrBasePath + "avr-ar",
createFolder(outputFolder); "rcs",
// this library can use includes in its utility/ folder runtimeLibraryName
includePaths.add(utilityFolder.getAbsolutePath()); }));
objectFiles.addAll( for(File file : coreObjectFiles) {
compileFiles(avrBasePath, outputFolder.getAbsolutePath(), includePaths, List commandAR = new ArrayList(baseCommandAR);
findFilesInFolder(libraryFolder, "S", false), commandAR.add(file.getAbsolutePath());
findFilesInFolder(libraryFolder, "c", false), execAsynchronously(commandAR);
findFilesInFolder(libraryFolder, "cpp", false), }
boardPreferences));
outputFolder = new File(outputFolder, "utility");
createFolder(outputFolder);
objectFiles.addAll(
compileFiles(avrBasePath, outputFolder.getAbsolutePath(), includePaths,
findFilesInFolder(utilityFolder, "S", false),
findFilesInFolder(utilityFolder, "c", false),
findFilesInFolder(utilityFolder, "cpp", false),
boardPreferences));
// other libraries should not see this library's utility/ folder
includePaths.remove(includePaths.size() - 1);
}
// 3. compile the sketch (already in the buildPath)
objectFiles.addAll(
compileFiles(avrBasePath, buildPath, includePaths,
findFilesInPath(buildPath, "S", false),
findFilesInPath(buildPath, "c", false),
findFilesInPath(buildPath, "cpp", false),
boardPreferences));
// 4. link it all together into the .elf file // 4. link it all together into the .elf file