From 6750e679afe8b83e38d5efbb17859bbd686eb81e Mon Sep 17 00:00:00 2001 From: "David A. Mellis" Date: Sat, 27 Nov 2010 11:39:42 -0600 Subject: [PATCH] Building sketch first (so errors appear faster). http://code.google.com/p/arduino/issues/detail?id=393 --- app/src/processing/app/debug/Compiler.java | 118 ++++++++++----------- 1 file changed, 59 insertions(+), 59 deletions(-) diff --git a/app/src/processing/app/debug/Compiler.java b/app/src/processing/app/debug/Compiler.java index 97b61fdaf..f2fa5e26d 100644 --- a/app/src/processing/app/debug/Compiler.java +++ b/app/src/processing/app/debug/Compiler.java @@ -93,72 +93,72 @@ public class Compiler implements MessageConsumer { List objectFiles = new ArrayList(); - List includePaths = new ArrayList(); - includePaths.add(corePath); - - String runtimeLibraryName = buildPath + File.separator + "core.a"; + // 0. include paths for core + all libraries - // 1. compile the core, outputting .o files to and then - // collecting them into the core.a library file. - - List 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 - })); + List includePaths = new ArrayList(); + includePaths.add(corePath); + for (File file : sketch.getImportedLibraries()) { + includePaths.add(file.getPath()); + } - for(File file : coreObjectFiles) { - List commandAR = new ArrayList(baseCommandAR); - commandAR.add(file.getAbsolutePath()); - execAsynchronously(commandAR); - } + // 1. compile the sketch (already in the buildPath) - // 2. compile the libraries, outputting .o files to: // + 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 - for (File file : sketch.getImportedLibraries()) { - includePaths.add(file.getPath()); - } + // 2. compile the libraries, outputting .o files to: // - for (File libraryFolder : sketch.getImportedLibraries()) { - File outputFolder = new File(buildPath, libraryFolder.getName()); - File utilityFolder = new File(libraryFolder, "utility"); - 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); - } + for (File libraryFolder : sketch.getImportedLibraries()) { + File outputFolder = new File(buildPath, libraryFolder.getName()); + File utilityFolder = new File(libraryFolder, "utility"); + 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); + } - // 3. compile the sketch (already in the buildPath) + // 3. compile the core, outputting .o files to and then + // collecting them into the core.a library file. - objectFiles.addAll( - compileFiles(avrBasePath, buildPath, includePaths, - findFilesInPath(buildPath, "S", false), - findFilesInPath(buildPath, "c", false), - findFilesInPath(buildPath, "cpp", false), - boardPreferences)); + includePaths.clear(); + includePaths.add(corePath); // include path for core only + List coreObjectFiles = + compileFiles(avrBasePath, buildPath, includePaths, + findFilesInPath(corePath, "S", true), + 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