From 96d7d46e35d5c88b61ecca5e20e4df0d1c8d3f48 Mon Sep 17 00:00:00 2001 From: Robert Giseburt Date: Tue, 4 Dec 2012 22:42:16 -0600 Subject: [PATCH 1/2] Grab library includes from other library files. LibraryA.h can now include LibraryB.h, and the path for LibraryB will be added to the compile line. --- app/src/processing/app/Base.java | 3 ++ app/src/processing/app/Sketch.java | 28 ++++++++++++++-- app/src/processing/app/debug/Compiler.java | 37 ++++++++++++++++++++-- 3 files changed, 64 insertions(+), 4 deletions(-) diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java index afa62e18bfc..0345a67dece 100644 --- a/app/src/processing/app/Base.java +++ b/app/src/processing/app/Base.java @@ -2046,6 +2046,9 @@ protected File getDefaultSketchbookFolder() { return sketchbookFolder; } + static public Map getImportToLibraryTable() { + return importToLibraryTable; + } /** * Check for a new sketchbook location. diff --git a/app/src/processing/app/Sketch.java b/app/src/processing/app/Sketch.java index 6d84c70b968..dec5b3d7098 100644 --- a/app/src/processing/app/Sketch.java +++ b/app/src/processing/app/Sketch.java @@ -1426,12 +1426,36 @@ public String preprocess(String buildPath, PdePreprocessor preprocessor) throws libraryPath = ""; for (String item : preprocessor.getExtraImports()) { - File libFolder = (File) Base.importToLibraryTable.get(item); - //If needed can Debug libraryPath here + File libFolder = (File) Base.importToLibraryTable.get(item); + //If needed can Debug libraryPath here if (libFolder != null && !importedLibraries.contains(libFolder)) { importedLibraries.add(libFolder); + + File headerFile = new File(libFolder.getAbsolutePath() + File.separator + item); + try { + String program = Base.loadFile(headerFile); + + String importRegexp = "^\\s*#include\\s*[<\"](\\S+)[\">]"; + + String[][] pieces = PApplet.matchAll(program, importRegexp); + + if (pieces != null) { + for (int i = 0; i < pieces.length; i++) { + File libFolder2 = (File) Base.importToLibraryTable.get(pieces[i][1]); // the package name + //If needed can Debug libraryPath here + if (libFolder2 != null && !importedLibraries.contains(libFolder2)) { + importedLibraries.add(libFolder2); + } + } + } + } catch (IOException e) { + e.printStackTrace(); + throw new RunnerException(I18n.format(_("Problem opening file {0}"), headerFile.getAbsolutePath())); + } + //classPath += Compiler.contentsToClassPath(libFolder); + // This is never used ... toss it? libraryPath += File.pathSeparator + libFolder.getAbsolutePath(); } } diff --git a/app/src/processing/app/debug/Compiler.java b/app/src/processing/app/debug/Compiler.java index 1bd8b8c256c..d8830dfa331 100644 --- a/app/src/processing/app/debug/Compiler.java +++ b/app/src/processing/app/debug/Compiler.java @@ -58,6 +58,33 @@ public class Compiler implements MessageConsumer { private RunnerException exception; + List getLocalIncludePaths(List includePaths, File programFile) + throws RunnerException { + List allIncludePaths = new ArrayList(includePaths); + try { + String program = Base.loadFile(programFile); + + String importRegexp = "^\\s*#include\\s*[<\"](\\S+)[\">]"; + + String[][] pieces = PApplet.matchAll(program, importRegexp); + + if (pieces != null) { + for (int i = 0; i < pieces.length; i++) { + File libFolder = (File) Base.getImportToLibraryTable().get(pieces[i][1]); // the package name + //If needed can Debug libraryPath here + if (libFolder != null && !allIncludePaths.contains(libFolder.getPath())) { + allIncludePaths.add(libFolder.getPath()); + } + } + } + } catch (IOException e) { + e.printStackTrace(); + throw new RunnerException(I18n.format(_("Problem opening file {0}"), programFile.getAbsolutePath())); + } + + return allIncludePaths; + } + /** * Compile sketch. * @@ -211,7 +238,10 @@ private List compileFiles(String outputPath, File sourcePath, objectPaths.add(objectFile); if (is_already_compiled(file, objectFile, dependFile, prefs)) continue; - String[] cmd = getCommandCompilerC(includePaths, file.getAbsolutePath(), + + List localIncludePaths = getLocalIncludePaths(includePaths, file); + + String[] cmd = getCommandCompilerC(localIncludePaths, file.getAbsolutePath(), objectPath); execAsynchronously(cmd); } @@ -224,7 +254,10 @@ private List compileFiles(String outputPath, File sourcePath, objectPaths.add(objectFile); if (is_already_compiled(file, objectFile, dependFile, prefs)) continue; - String[] cmd = getCommandCompilerCPP(includePaths, + + List localIncludePaths = getLocalIncludePaths(includePaths, file); + + String[] cmd = getCommandCompilerCPP(localIncludePaths, file.getAbsolutePath(), objectPath); execAsynchronously(cmd); } From cc9dada43a3bc3040d8ea5ff4495eb5c30d5d5e9 Mon Sep 17 00:00:00 2001 From: Robert Giseburt Date: Tue, 4 Dec 2012 22:42:51 -0600 Subject: [PATCH 2/2] Do we really want the PULLUP on a LOW pin? --- hardware/arduino/sam/cores/arduino/wiring_digital.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hardware/arduino/sam/cores/arduino/wiring_digital.c b/hardware/arduino/sam/cores/arduino/wiring_digital.c index 7c958de8a56..fd8a1e798ef 100644 --- a/hardware/arduino/sam/cores/arduino/wiring_digital.c +++ b/hardware/arduino/sam/cores/arduino/wiring_digital.c @@ -84,7 +84,7 @@ extern void digitalWrite( uint32_t ulPin, uint32_t ulVal ) } else { - PIO_SetOutput( g_APinDescription[ulPin].pPort, g_APinDescription[ulPin].ulPin, ulVal, 0, PIO_PULLUP ) ; + PIO_SetOutput( g_APinDescription[ulPin].pPort, g_APinDescription[ulPin].ulPin, ulVal, 0, 0 ) ; } }