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,40 +93,25 @@ public class Compiler implements MessageConsumer {
List<File> objectFiles = new ArrayList<File>(); List<File> objectFiles = new ArrayList<File>();
// 0. include paths for core + all libraries
List includePaths = new ArrayList(); List includePaths = new ArrayList();
includePaths.add(corePath); includePaths.add(corePath);
String runtimeLibraryName = buildPath + File.separator + "core.a";
// 1. compile the core, outputting .o files to <buildPath> and then
// collecting them into the core.a library file.
List<File> coreObjectFiles =
compileFiles(avrBasePath, buildPath, includePaths,
findFilesInPath(corePath, "S", true),
findFilesInPath(corePath, "c", true),
findFilesInPath(corePath, "cpp", true),
boardPreferences);
List baseCommandAR = new ArrayList(Arrays.asList(new String[] {
avrBasePath + "avr-ar",
"rcs",
runtimeLibraryName
}));
for(File file : coreObjectFiles) {
List commandAR = new ArrayList(baseCommandAR);
commandAR.add(file.getAbsolutePath());
execAsynchronously(commandAR);
}
// 2. compile the libraries, outputting .o files to: <buildPath>/<library>/
// use library directories as include paths for all libraries
for (File file : sketch.getImportedLibraries()) { for (File file : sketch.getImportedLibraries()) {
includePaths.add(file.getPath()); includePaths.add(file.getPath());
} }
// 1. 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));
// 2. compile the libraries, outputting .o files to: <buildPath>/<library>/
for (File libraryFolder : sketch.getImportedLibraries()) { for (File libraryFolder : sketch.getImportedLibraries()) {
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");
@ -151,14 +136,29 @@ public class Compiler implements MessageConsumer {
includePaths.remove(includePaths.size() - 1); includePaths.remove(includePaths.size() - 1);
} }
// 3. compile the sketch (already in the buildPath) // 3. compile the core, outputting .o files to <buildPath> and then
// collecting them into the core.a library file.
objectFiles.addAll( includePaths.clear();
includePaths.add(corePath); // include path for core only
List<File> coreObjectFiles =
compileFiles(avrBasePath, buildPath, includePaths, compileFiles(avrBasePath, buildPath, includePaths,
findFilesInPath(buildPath, "S", false), findFilesInPath(corePath, "S", true),
findFilesInPath(buildPath, "c", false), findFilesInPath(corePath, "c", true),
findFilesInPath(buildPath, "cpp", false), findFilesInPath(corePath, "cpp", true),
boardPreferences)); boardPreferences);
String runtimeLibraryName = buildPath + File.separator + "core.a";
List baseCommandAR = new ArrayList(Arrays.asList(new String[] {
avrBasePath + "avr-ar",
"rcs",
runtimeLibraryName
}));
for(File file : coreObjectFiles) {
List commandAR = new ArrayList(baseCommandAR);
commandAR.add(file.getAbsolutePath());
execAsynchronously(commandAR);
}
// 4. link it all together into the .elf file // 4. link it all together into the .elf file