Skip to content

Commit a71e46f

Browse files
ffissorecmaglie
authored andcommitted
recursive library compilation triggered on multiplatform libraries
1 parent 9fdb047 commit a71e46f

File tree

1 file changed

+39
-17
lines changed

1 file changed

+39
-17
lines changed

app/src/processing/app/debug/Compiler.java

Lines changed: 39 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import processing.app.SketchCode;
4141
import processing.app.helpers.PreferencesMap;
4242
import processing.app.helpers.StringReplacer;
43+
import processing.app.helpers.filefilters.OnlyDirs;
4344
import processing.core.PApplet;
4445

4546
public class Compiler implements MessageConsumer {
@@ -578,26 +579,47 @@ void compileSketch(List<String> includePaths) throws RunnerException {
578579
// 2. compile the libraries, outputting .o files to:
579580
// <buildPath>/<library>/
580581
void compileLibraries(List<String> includePaths) throws RunnerException {
581-
582+
File outputPath = new File(prefs.get("build.path"));
582583
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+
}
598589
}
599590
}
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+
601623
// 3. compile the core, outputting .o files to <buildPath> and then
602624
// collecting them into the core.a library file.
603625
void compileCore()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy