Skip to content

Include library paths used by libraries in the compiler search path. #1250

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/src/processing/app/Base.java
Original file line number Diff line number Diff line change
Expand Up @@ -2046,6 +2046,9 @@ protected File getDefaultSketchbookFolder() {
return sketchbookFolder;
}

static public Map<String, File> getImportToLibraryTable() {
return importToLibraryTable;
}

/**
* Check for a new sketchbook location.
Expand Down
28 changes: 26 additions & 2 deletions app/src/processing/app/Sketch.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Expand Down
37 changes: 35 additions & 2 deletions app/src/processing/app/debug/Compiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,33 @@ public class Compiler implements MessageConsumer {

private RunnerException exception;

List<String> getLocalIncludePaths(List<String> includePaths, File programFile)
throws RunnerException {
List<String> allIncludePaths = new ArrayList<String>(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.
*
Expand Down Expand Up @@ -211,7 +238,10 @@ private List<File> compileFiles(String outputPath, File sourcePath,
objectPaths.add(objectFile);
if (is_already_compiled(file, objectFile, dependFile, prefs))
continue;
String[] cmd = getCommandCompilerC(includePaths, file.getAbsolutePath(),

List<String> localIncludePaths = getLocalIncludePaths(includePaths, file);

String[] cmd = getCommandCompilerC(localIncludePaths, file.getAbsolutePath(),
objectPath);
execAsynchronously(cmd);
}
Expand All @@ -224,7 +254,10 @@ private List<File> compileFiles(String outputPath, File sourcePath,
objectPaths.add(objectFile);
if (is_already_compiled(file, objectFile, dependFile, prefs))
continue;
String[] cmd = getCommandCompilerCPP(includePaths,

List<String> localIncludePaths = getLocalIncludePaths(includePaths, file);

String[] cmd = getCommandCompilerCPP(localIncludePaths,
file.getAbsolutePath(), objectPath);
execAsynchronously(cmd);
}
Expand Down
2 changes: 1 addition & 1 deletion hardware/arduino/sam/cores/arduino/wiring_digital.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) ;
}
}

Expand Down