mirror of
https://github.com/arduino/Arduino.git
synced 2025-03-14 11: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:
parent
5d9602a28a
commit
6750e679af
@ -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";
|
|
||||||
|
|
||||||
// 1. compile the core, outputting .o files to <buildPath> and then
|
List includePaths = new ArrayList();
|
||||||
// collecting them into the core.a library file.
|
includePaths.add(corePath);
|
||||||
|
for (File file : sketch.getImportedLibraries()) {
|
||||||
List<File> coreObjectFiles =
|
includePaths.add(file.getPath());
|
||||||
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) {
|
// 1. compile the sketch (already in the buildPath)
|
||||||
List commandAR = new ArrayList(baseCommandAR);
|
|
||||||
commandAR.add(file.getAbsolutePath());
|
|
||||||
execAsynchronously(commandAR);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 2. compile the libraries, outputting .o files to: <buildPath>/<library>/
|
objectFiles.addAll(
|
||||||
|
compileFiles(avrBasePath, buildPath, includePaths,
|
||||||
|
findFilesInPath(buildPath, "S", false),
|
||||||
|
findFilesInPath(buildPath, "c", false),
|
||||||
|
findFilesInPath(buildPath, "cpp", false),
|
||||||
|
boardPreferences));
|
||||||
|
|
||||||
// use library directories as include paths for all libraries
|
// 2. compile the libraries, outputting .o files to: <buildPath>/<library>/
|
||||||
for (File file : sketch.getImportedLibraries()) {
|
|
||||||
includePaths.add(file.getPath());
|
|
||||||
}
|
|
||||||
|
|
||||||
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");
|
||||||
createFolder(outputFolder);
|
createFolder(outputFolder);
|
||||||
// this library can use includes in its utility/ folder
|
// this library can use includes in its utility/ folder
|
||||||
includePaths.add(utilityFolder.getAbsolutePath());
|
includePaths.add(utilityFolder.getAbsolutePath());
|
||||||
objectFiles.addAll(
|
objectFiles.addAll(
|
||||||
compileFiles(avrBasePath, 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),
|
||||||
boardPreferences));
|
boardPreferences));
|
||||||
outputFolder = new File(outputFolder, "utility");
|
outputFolder = new File(outputFolder, "utility");
|
||||||
createFolder(outputFolder);
|
createFolder(outputFolder);
|
||||||
objectFiles.addAll(
|
objectFiles.addAll(
|
||||||
compileFiles(avrBasePath, 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),
|
||||||
boardPreferences));
|
boardPreferences));
|
||||||
// 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 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();
|
||||||
compileFiles(avrBasePath, buildPath, includePaths,
|
includePaths.add(corePath); // include path for core only
|
||||||
findFilesInPath(buildPath, "S", false),
|
List<File> coreObjectFiles =
|
||||||
findFilesInPath(buildPath, "c", false),
|
compileFiles(avrBasePath, buildPath, includePaths,
|
||||||
findFilesInPath(buildPath, "cpp", false),
|
findFilesInPath(corePath, "S", true),
|
||||||
boardPreferences));
|
findFilesInPath(corePath, "c", true),
|
||||||
|
findFilesInPath(corePath, "cpp", true),
|
||||||
|
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
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user