mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
Replace Kjc compiler with jikes
This commit is contained in:
+62
-13
@@ -20,35 +20,63 @@ public class PdeCompiler implements PdeMessageConsumer{
|
||||
public boolean compileJava(PrintStream leechErr) {
|
||||
String command[] = new String[] {
|
||||
"jikes",
|
||||
"-nowarn", // we're not currently interested in warnings
|
||||
"+E", // output errors in machine-parsable format
|
||||
"-d", buildPath, // output the classes in the buildPath
|
||||
buildPath + File.separator + className + ".java" // file to compile
|
||||
};
|
||||
|
||||
int result;
|
||||
// XXXdmose try/catch should be separate
|
||||
try {
|
||||
Process process = Runtime.getRuntime().exec(command);
|
||||
// XXXdmose race condition?
|
||||
new PdeMessageSiphon(process.getInputStream(),
|
||||
process.getErrorStream(),
|
||||
this);
|
||||
firstErrorFound = false; // haven't found any errors yet
|
||||
secondErrorFound = false;
|
||||
|
||||
int result=0; // pre-initialized to quiet a bogus warning from jikes
|
||||
try {
|
||||
|
||||
// execute the compiler, and create threads to deal with the input
|
||||
// and error streams
|
||||
//
|
||||
Process process = Runtime.getRuntime().exec(command);
|
||||
new PdeMessageSiphon(process.getInputStream(), this);
|
||||
new PdeMessageSiphon(process.getErrorStream(), this);
|
||||
|
||||
// wait for the process to finish. if we get interrupted before waitFor
|
||||
// returns, continue waiting
|
||||
//
|
||||
boolean compiling = true;
|
||||
while (compiling) {
|
||||
try {
|
||||
result = process.waitFor();
|
||||
compiling = false;
|
||||
} catch (InterruptedException intExc) {
|
||||
}
|
||||
}
|
||||
|
||||
result = process.waitFor();
|
||||
} catch (Exception e) {
|
||||
result = -1;
|
||||
}
|
||||
//System.err.println("result = " + result);
|
||||
|
||||
// if we hit either of these conditions, it means that something is
|
||||
// fairly wrong, one possibility is that jikes has crashed.
|
||||
//
|
||||
if (result != 0 && result != 1 ) {
|
||||
exception = new PdeException("Error while compiling, " +
|
||||
"please send code to bugs@proce55ing.net");
|
||||
editor.error(exception);
|
||||
}
|
||||
|
||||
return result == 0 ? true : false;
|
||||
}
|
||||
|
||||
boolean firstErrorFound;
|
||||
boolean secondErrorFound;
|
||||
|
||||
// part of the PdeMessageConsumer interface
|
||||
//
|
||||
public void message(String s) {
|
||||
|
||||
// as in: lib\build\Temporary_5476_6442.java:88: caution:Assignment of an expression to itself [KOPI]
|
||||
if (s.indexOf("caution") != -1) return;
|
||||
// ignore cautions
|
||||
if (s.indexOf("Caution") != -1) return;
|
||||
|
||||
// jikes always uses a forward slash character as its separator, so
|
||||
// we need to replace any platform-specific separator characters before
|
||||
@@ -66,10 +94,21 @@ public class PdeCompiler implements PdeMessageConsumer{
|
||||
//String s2 = s1.substring(colon + 2);
|
||||
int err = s1.indexOf("Error:");
|
||||
if (err != -1) {
|
||||
|
||||
// if the first error has already been found, then this must be
|
||||
// (at least) the second error found
|
||||
if (firstErrorFound) {
|
||||
secondErrorFound = true;
|
||||
return;
|
||||
}
|
||||
|
||||
// if we're here at all, this is at least the first error
|
||||
firstErrorFound = true;
|
||||
|
||||
//err += "error:".length();
|
||||
String description = s1.substring(err + "Error:".length());
|
||||
description = description.trim();
|
||||
System.out.println("description = " + description);
|
||||
//System.out.println("description = " + description);
|
||||
exception = new PdeException(description, lineNumber-1);
|
||||
editor.error(exception);
|
||||
|
||||
@@ -78,8 +117,18 @@ public class PdeCompiler implements PdeMessageConsumer{
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
// this isn't the start of an error line, so don't attempt to parse
|
||||
// a line number out of it
|
||||
// a line number out of it.
|
||||
|
||||
// if we're not yet at the second error, these lines are probably
|
||||
// associated with the first error message, which is already in the
|
||||
// status bar, and are likely to be of interest to the user, so
|
||||
// spit them to the console.
|
||||
//
|
||||
if (!secondErrorFound) {
|
||||
System.err.println(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+8
-7
@@ -649,13 +649,13 @@ afterwards, some of these steps need a cleanup function
|
||||
|
||||
// compile the program
|
||||
//
|
||||
PdeCompiler compilerKjc = new PdeCompilerKjc(buildPath, className, this);
|
||||
PdeCompiler compiler = new PdeCompiler(buildPath, className, this);
|
||||
|
||||
// this will catch and parse errors during compilation
|
||||
messageStream = new PdeMessageStream(this, compilerKjc);
|
||||
messageStream = new PdeMessageStream(this, compiler);
|
||||
leechErr = new PrintStream(messageStream);
|
||||
|
||||
boolean result = compilerKjc.compileJava(leechErr);
|
||||
boolean result = compiler.compileJava(leechErr);
|
||||
|
||||
// if the compilation worked, run the applet
|
||||
//
|
||||
@@ -1367,17 +1367,18 @@ afterwards, some of these steps need a cleanup function
|
||||
//
|
||||
PdePreprocessor preprocessorOro =
|
||||
new PdePreprocessorOro(program, appletDir.getPath());
|
||||
|
||||
exportSketchName =
|
||||
preprocessorOro.writeJava(exportSketchName,
|
||||
base.normalItem.getState(), true);
|
||||
PdeCompiler compilerKjc =
|
||||
new PdeCompilerKjc(appletDir.getPath(), exportSketchName, this);
|
||||
PdeCompiler compiler =
|
||||
new PdeCompiler(appletDir.getPath(), exportSketchName, this);
|
||||
|
||||
// this will catch and parse errors during compilation
|
||||
messageStream = new PdeMessageStream(this, compilerKjc);
|
||||
messageStream = new PdeMessageStream(this, compiler);
|
||||
leechErr = new PrintStream(messageStream);
|
||||
|
||||
if (!compilerKjc.compileJava(leechErr)) {
|
||||
if (!compiler.compileJava(leechErr)) {
|
||||
//throw new Exception("error while compiling, couldn't export");
|
||||
// message() will already have error message in this case
|
||||
return;
|
||||
|
||||
+17
-34
@@ -2,21 +2,17 @@
|
||||
|
||||
import java.io.*;
|
||||
|
||||
// XXXdmose error checking
|
||||
|
||||
class PdeMessageSiphon implements Runnable {
|
||||
BufferedReader stdout, stderr;
|
||||
PrintStream leechErr;
|
||||
BufferedReader streamReader;
|
||||
Thread thread;
|
||||
PdeMessageConsumer consumer;
|
||||
|
||||
public PdeMessageSiphon(InputStream stdout, InputStream stderr,
|
||||
PdeMessageConsumer consumer) {
|
||||
public PdeMessageSiphon(InputStream stream, PdeMessageConsumer consumer) {
|
||||
|
||||
// XXXdmose error checking here
|
||||
|
||||
this.stdout = new BufferedReader(new InputStreamReader(stdout));
|
||||
this.stderr = new BufferedReader(new InputStreamReader(stderr));
|
||||
// we use a BufferedReader in order to be able to read a line
|
||||
// at a time
|
||||
//
|
||||
this.streamReader = new BufferedReader(new InputStreamReader(stream));
|
||||
this.consumer = consumer;
|
||||
|
||||
thread = new Thread(this);
|
||||
@@ -27,31 +23,18 @@ class PdeMessageSiphon implements Runnable {
|
||||
|
||||
String currentLine;
|
||||
|
||||
while (Thread.currentThread() == thread) {
|
||||
|
||||
// XXX put back while loops
|
||||
|
||||
try {
|
||||
if (stderr.ready()) {
|
||||
currentLine = stderr.readLine();
|
||||
System.err.println(currentLine);
|
||||
consumer.message(currentLine);
|
||||
}
|
||||
|
||||
if (stdout.ready()) {
|
||||
currentLine = stdout.readLine();
|
||||
System.err.println(currentLine);
|
||||
consumer.message(currentLine);
|
||||
}
|
||||
|
||||
Thread.sleep(10);
|
||||
|
||||
} catch (Exception e) {
|
||||
System.err.println("PdeMessageSiphon err " + e);
|
||||
|
||||
thread.stop();
|
||||
thread = null;
|
||||
try {
|
||||
// process data until we hit EOF; this may block
|
||||
//
|
||||
while ((currentLine = streamReader.readLine()) != null) {
|
||||
consumer.message(currentLine);
|
||||
//System.err.println(currentLine);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.err.println("PdeMessageSiphon err " + e);
|
||||
thread.stop();
|
||||
}
|
||||
|
||||
//System.err.println("siphon thread exiting");
|
||||
}
|
||||
}
|
||||
|
||||
+2
-4
@@ -44,10 +44,8 @@ public class PdeRuntime implements PdeMessageConsumer {
|
||||
process = Runtime.getRuntime().exec(cmd + " " + className +
|
||||
" " + className +
|
||||
" " + x1 + " " + y1);
|
||||
new PdeMessageSiphon(process.getInputStream(),
|
||||
process.getErrorStream(),
|
||||
this);
|
||||
|
||||
new PdeMessageSiphon(process.getInputStream(), this);
|
||||
new PdeMessageSiphon(process.getErrorStream(), this);
|
||||
} else {
|
||||
Class c = Class.forName(className);
|
||||
|
||||
|
||||
Vendored
-3
@@ -1,3 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
./java/bin/java -cp lib:lib/build:lib/pde.jar:lib/kjc.jar:lib/oro.jar PdeBase
|
||||
+2
-2
@@ -87,5 +87,5 @@ cd ../..
|
||||
|
||||
### -- BUILD STUB -----------------------------------------------
|
||||
|
||||
gcc -o work/Proce55ing stub.cpp
|
||||
chmod 777 work/Proce55ing
|
||||
install -m 755 stub.sh work/Processing
|
||||
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
int main() {
|
||||
system("java/bin/java -cp lib:lib/build:lib/pde.jar:lib/kjc.jar:lib/oro.jar:java/lib/ext/comm.jar PdeBase");
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
CLASSPATH=java/lib/rt.jar:lib:lib/build:lib/pde.jar:lib/kjc.jar:lib/oro.jar:java/lib/ext/comm.jar
|
||||
export CLASSPATH
|
||||
|
||||
exec java/bin/java PdeBase
|
||||
@@ -48,6 +48,12 @@ cp work/lib/pde.jar processing/lib/
|
||||
cp -r work/lib/export processing/lib/
|
||||
rm -rf processing/lib/export/CVS
|
||||
|
||||
# get jikes and depedencies
|
||||
cp /usr/bin/cygwin1.dll processing/
|
||||
cp /usr/bin/cygiconv-2.dll processing/
|
||||
gunzip < jikes.exe.gz > processing/jikes.exe
|
||||
chmod +x processing/jikes.exe
|
||||
|
||||
# get platform-specific goodies from the dist dir
|
||||
cp dist/Proce55ing.exe processing/
|
||||
cp dist/run.bat processing/
|
||||
|
||||
Vendored
+6
-1
@@ -3,4 +3,9 @@
|
||||
REM --- if you need more ram, change the 64m (which means
|
||||
REM --- 64 megabytes) to something higher.
|
||||
|
||||
java -ms64m -mx64m -cp lib;lib\build;lib\pde.jar;lib\kjc.jar;lib\oro.jar;lib\comm.jar;c:\winnt\system32\qtjava.zip;c:\windows\system32\qtjava.zip PdeBase
|
||||
set SAVEDCP=%CLASSPATH%
|
||||
set CLASSPATH=%CLASSPATH%;java\lib\rt.jar;lib;lib\build;lib\pde.jar;lib\kjc.jar;lib\oro.jar;lib\comm.jar;c:\winnt\system32\qtjava.zip;c:\windows\system32\qtjava.zip
|
||||
|
||||
java -ms64m -mx64m PdeBase
|
||||
|
||||
set CLASSPATH=%SAVEDCP%
|
||||
|
||||
@@ -12,6 +12,6 @@ fi
|
||||
#QT_JAVA_PATH=..\\build\\shared\\lib\\qtjava.zip
|
||||
|
||||
|
||||
CLASSPATH=lib\;lib\\build\;lib\\pde.jar\;lib\\kjc.jar\;lib\\oro.jar\;java\\lib\\ext\\comm.jar\;${QT_JAVA_PATH}
|
||||
CLASSPATH=java\\lib\\rt.jar\;lib\;lib\\build\;lib\\pde.jar\;lib\\kjc.jar\;lib\\oro.jar\;java\\lib\\ext\\comm.jar\;${QT_JAVA_PATH}
|
||||
|
||||
cd work && ./java/bin/java -cp ${CLASSPATH} PdeBase
|
||||
|
||||
@@ -1,2 +1,6 @@
|
||||
#!/bin/sh
|
||||
cd work && ./java/bin/java -Djava.compiler=NONE -cp lib\;lib\\build\;lib\\pde.jar\;lib\\kjc.jar\;lib\\oro.jar\;java\\lib\\ext\\comm.jar PdeBase
|
||||
|
||||
CLASSPATH=java\\lib\\rt.jar\;lib\;lib\\build\;lib\\pde.jar\;lib\\kjc.jar\;lib\\oro.jar\;java\\lib\\ext\\comm.jar
|
||||
export CLASSPATH
|
||||
|
||||
cd work && ./java/bin/java -Djava.compiler=NONE PdeBase
|
||||
|
||||
Reference in New Issue
Block a user