MCPcopy Index your code
hub / github.com/processing/processing / compile

Method compile

java/src/processing/mode/java/Compiler.java:59–317  ·  view source on GitHub ↗

Compile with ECJ. See http://j.mp/8paifz for documentation. @param sketch Sketch object to be compiled, used for placing exceptions @param buildPath Where the temporary files live and will be built from. @return true if successful. @throws SketchException Only if there's a problem. Only then.

(JavaBuild build)

Source from the content-addressed store, hash-verified

57 * @throws SketchException Only if there's a problem. Only then.
58 */
59 static public boolean compile(JavaBuild build) throws SketchException {
60
61 // This will be filled in if anyone gets angry
62 SketchException exception = null;
63 boolean success = false;
64
65 String baseCommand[] = new String[] {
66 "-g",
67 "-Xemacs",
68 //"-noExit", // not necessary for ecj
69 "-source", "1.7",
70 "-target", "1.7",
71 "-encoding", "utf8",
72 "-classpath", build.getClassPath(),
73 "-nowarn", // we're not currently interested in warnings (works in ecj)
74 "-d", build.getBinFolder().getAbsolutePath() // output the classes in the buildPath
75 };
76 //PApplet.println(baseCommand);
77
78 String[] sourceFiles = Util.listFiles(build.getSrcFolder(), false, ".java");
79 String[] command = PApplet.concat(baseCommand, sourceFiles);
80 //PApplet.println(command);
81
82 try {
83 // Load errors into a local StringBuilder
84 final StringBuilder errorBuffer = new StringBuilder();
85
86 // Create single method dummy writer class to slurp errors from ecj
87 Writer internalWriter = new Writer() {
88 public void write(char[] buf, int off, int len) {
89 errorBuffer.append(buf, off, len);
90 }
91
92 public void flush() { }
93
94 public void close() { }
95 };
96 // Wrap as a PrintWriter since that's what compile() wants
97 PrintWriter writer = new PrintWriter(internalWriter);
98
99 //result = com.sun.tools.javac.Main.compile(command, writer);
100
101 PrintWriter outWriter = new PrintWriter(System.out);
102
103 // Version that's not dynamically loaded
104 //CompilationProgress progress = null;
105 //success = BatchCompiler.compile(command, outWriter, writer, progress);
106
107 // Version that *is* dynamically loaded. First gets the mode class loader
108 // so that it can grab the compiler JAR files from it.
109 ClassLoader loader = build.mode.getClassLoader();
110 try {
111 Class<?> batchClass =
112 Class.forName("org.eclipse.jdt.core.compiler.batch.BatchCompiler", false, loader);
113 Class<?> progressClass =
114 Class.forName("org.eclipse.jdt.core.compiler.CompilationProgress", false, loader);
115 Class<?>[] compileArgs =
116 new Class<?>[] { String[].class, PrintWriter.class, PrintWriter.class, progressClass };

Callers 15

buildMethod · 0.95
PdePreprocessorClass · 0.45
matchMethodMethod · 0.45
writeMethod · 0.45
addAllDecimalNumbersMethod · 0.45
addAllHexNumbersMethod · 0.45
addAllWebColorNumbersMethod · 0.45
createColorBoxesMethod · 0.45
getVoidFunctionStartMethod · 0.45

Calls 15

listFilesMethod · 0.95
concatMethod · 0.95
matchMethod · 0.95
hideStackTraceMethod · 0.95
parseIntMethod · 0.95
setMessageMethod · 0.95
handleCrustyCodeMethod · 0.95
getBinFolderMethod · 0.80
getSrcFolderMethod · 0.80
getClassLoaderMethod · 0.80
getMethodMethod · 0.80
placeExceptionMethod · 0.80

Tested by

no test coverage detected