mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-30 19:52:13 +01:00
recursive library compilation triggered on multiplatform libraries
This commit is contained in:
parent
9fdb047197
commit
a71e46f94c
@ -40,6 +40,7 @@ import processing.app.Sketch;
|
|||||||
import processing.app.SketchCode;
|
import processing.app.SketchCode;
|
||||||
import processing.app.helpers.PreferencesMap;
|
import processing.app.helpers.PreferencesMap;
|
||||||
import processing.app.helpers.StringReplacer;
|
import processing.app.helpers.StringReplacer;
|
||||||
|
import processing.app.helpers.filefilters.OnlyDirs;
|
||||||
import processing.core.PApplet;
|
import processing.core.PApplet;
|
||||||
|
|
||||||
public class Compiler implements MessageConsumer {
|
public class Compiler implements MessageConsumer {
|
||||||
@ -578,26 +579,47 @@ public class Compiler implements MessageConsumer {
|
|||||||
// 2. compile the libraries, outputting .o files to:
|
// 2. compile the libraries, outputting .o files to:
|
||||||
// <buildPath>/<library>/
|
// <buildPath>/<library>/
|
||||||
void compileLibraries(List<String> includePaths) throws RunnerException {
|
void compileLibraries(List<String> includePaths) throws RunnerException {
|
||||||
|
File outputPath = new File(prefs.get("build.path"));
|
||||||
for (File libraryFolder : sketch.getImportedLibraries()) {
|
for (File libraryFolder : sketch.getImportedLibraries()) {
|
||||||
String outputPath = prefs.get("build.path");
|
if (new File(libraryFolder.getParentFile(), "library.properties").exists()) {
|
||||||
File outputFolder = new File(outputPath, libraryFolder.getName());
|
recursiveCompileLibrary(outputPath, libraryFolder, includePaths);
|
||||||
File utilityFolder = new File(libraryFolder, "utility");
|
} else {
|
||||||
createFolder(outputFolder);
|
compileLibrary(outputPath, libraryFolder, includePaths);
|
||||||
// this library can use includes in its utility/ folder
|
}
|
||||||
includePaths.add(utilityFolder.getAbsolutePath());
|
|
||||||
|
|
||||||
objectFiles.addAll(compileFiles(outputFolder.getAbsolutePath(),
|
|
||||||
libraryFolder, false, includePaths));
|
|
||||||
outputFolder = new File(outputFolder, "utility");
|
|
||||||
createFolder(outputFolder);
|
|
||||||
objectFiles.addAll(compileFiles(outputFolder.getAbsolutePath(),
|
|
||||||
utilityFolder, false, includePaths));
|
|
||||||
// other libraries should not see this library's utility/ folder
|
|
||||||
includePaths.remove(includePaths.size() - 1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void recursiveCompileLibrary(File outputPath, File libraryFolder, List<String> includePaths) throws RunnerException {
|
||||||
|
File newOutputPath = compileFilesInFolder(outputPath, libraryFolder, includePaths);
|
||||||
|
for (File subFolder : libraryFolder.listFiles(new OnlyDirs())) {
|
||||||
|
recursiveCompileLibrary(newOutputPath, subFolder, includePaths);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private File compileFilesInFolder(File outputPath, File libraryFolder, List<String> includePaths) throws RunnerException {
|
||||||
|
File outputFolder = new File(outputPath, libraryFolder.getName());
|
||||||
|
createFolder(outputFolder);
|
||||||
|
objectFiles.addAll(compileFiles(outputFolder.getAbsolutePath(), libraryFolder, false, includePaths));
|
||||||
|
return outputFolder;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void compileLibrary(File outputPath, File libraryFolder, List<String> includePaths) throws RunnerException {
|
||||||
|
File outputFolder = new File(outputPath, 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(outputFolder.getAbsolutePath(),
|
||||||
|
libraryFolder, false, includePaths));
|
||||||
|
outputFolder = new File(outputFolder, "utility");
|
||||||
|
createFolder(outputFolder);
|
||||||
|
objectFiles.addAll(compileFiles(outputFolder.getAbsolutePath(),
|
||||||
|
utilityFolder, false, includePaths));
|
||||||
|
// other libraries should not see this library's utility/ folder
|
||||||
|
includePaths.remove(includePaths.size() - 1);
|
||||||
|
}
|
||||||
|
|
||||||
// 3. compile the core, outputting .o files to <buildPath> and then
|
// 3. compile the core, outputting .o files to <buildPath> and then
|
||||||
// collecting them into the core.a library file.
|
// collecting them into the core.a library file.
|
||||||
void compileCore()
|
void compileCore()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user