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); } 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 ) ; } }