|
40 | 40 | import processing.app.SketchCode;
|
41 | 41 | import processing.app.helpers.PreferencesMap;
|
42 | 42 | import processing.app.helpers.StringReplacer;
|
| 43 | +import processing.app.helpers.filefilters.OnlyDirs; |
43 | 44 | import processing.core.PApplet;
|
44 | 45 |
|
45 | 46 | public class Compiler implements MessageConsumer {
|
@@ -578,26 +579,47 @@ void compileSketch(List<String> includePaths) throws RunnerException {
|
578 | 579 | // 2. compile the libraries, outputting .o files to:
|
579 | 580 | // <buildPath>/<library>/
|
580 | 581 | void compileLibraries(List<String> includePaths) throws RunnerException {
|
581 |
| - |
| 582 | + File outputPath = new File(prefs.get("build.path")); |
582 | 583 | for (File libraryFolder : sketch.getImportedLibraries()) {
|
583 |
| - String outputPath = prefs.get("build.path"); |
584 |
| - File outputFolder = new File(outputPath, libraryFolder.getName()); |
585 |
| - File utilityFolder = new File(libraryFolder, "utility"); |
586 |
| - createFolder(outputFolder); |
587 |
| - // this library can use includes in its utility/ folder |
588 |
| - includePaths.add(utilityFolder.getAbsolutePath()); |
589 |
| - |
590 |
| - objectFiles.addAll(compileFiles(outputFolder.getAbsolutePath(), |
591 |
| - libraryFolder, false, includePaths)); |
592 |
| - outputFolder = new File(outputFolder, "utility"); |
593 |
| - createFolder(outputFolder); |
594 |
| - objectFiles.addAll(compileFiles(outputFolder.getAbsolutePath(), |
595 |
| - utilityFolder, false, includePaths)); |
596 |
| - // other libraries should not see this library's utility/ folder |
597 |
| - includePaths.remove(includePaths.size() - 1); |
| 584 | + if (new File(libraryFolder.getParentFile(), "library.properties").exists()) { |
| 585 | + recursiveCompileLibrary(outputPath, libraryFolder, includePaths); |
| 586 | + } else { |
| 587 | + compileLibrary(outputPath, libraryFolder, includePaths); |
| 588 | + } |
598 | 589 | }
|
599 | 590 | }
|
600 |
| - |
| 591 | + |
| 592 | + private void recursiveCompileLibrary(File outputPath, File libraryFolder, List<String> includePaths) throws RunnerException { |
| 593 | + File newOutputPath = compileFilesInFolder(outputPath, libraryFolder, includePaths); |
| 594 | + for (File subFolder : libraryFolder.listFiles(new OnlyDirs())) { |
| 595 | + recursiveCompileLibrary(newOutputPath, subFolder, includePaths); |
| 596 | + } |
| 597 | + } |
| 598 | + |
| 599 | + private File compileFilesInFolder(File outputPath, File libraryFolder, List<String> includePaths) throws RunnerException { |
| 600 | + File outputFolder = new File(outputPath, libraryFolder.getName()); |
| 601 | + createFolder(outputFolder); |
| 602 | + objectFiles.addAll(compileFiles(outputFolder.getAbsolutePath(), libraryFolder, false, includePaths)); |
| 603 | + return outputFolder; |
| 604 | + } |
| 605 | + |
| 606 | + private void compileLibrary(File outputPath, File libraryFolder, List<String> includePaths) throws RunnerException { |
| 607 | + File outputFolder = new File(outputPath, libraryFolder.getName()); |
| 608 | + File utilityFolder = new File(libraryFolder, "utility"); |
| 609 | + createFolder(outputFolder); |
| 610 | + // this library can use includes in its utility/ folder |
| 611 | + includePaths.add(utilityFolder.getAbsolutePath()); |
| 612 | + |
| 613 | + objectFiles.addAll(compileFiles(outputFolder.getAbsolutePath(), |
| 614 | + libraryFolder, false, includePaths)); |
| 615 | + outputFolder = new File(outputFolder, "utility"); |
| 616 | + createFolder(outputFolder); |
| 617 | + objectFiles.addAll(compileFiles(outputFolder.getAbsolutePath(), |
| 618 | + utilityFolder, false, includePaths)); |
| 619 | + // other libraries should not see this library's utility/ folder |
| 620 | + includePaths.remove(includePaths.size() - 1); |
| 621 | + } |
| 622 | + |
601 | 623 | // 3. compile the core, outputting .o files to <buildPath> and then
|
602 | 624 | // collecting them into the core.a library file.
|
603 | 625 | void compileCore()
|
|
0 commit comments