1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-09-10 12:03:16 +02:00
This commit is contained in:
Alain Magloire 2003-10-17 01:39:50 +00:00
parent 451fe038af
commit 4fda51818b

View file

@ -15,7 +15,7 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.OutputStream; import java.io.OutputStream;
import java.io.StringReader; import java.util.ArrayList;
import org.eclipse.cdt.utils.spawner.ProcessFactory; import org.eclipse.cdt.utils.spawner.ProcessFactory;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
@ -29,33 +29,52 @@ public class MakeRecon extends OutputStream {
IPath directory; IPath directory;
IProgressMonitor monitor; IProgressMonitor monitor;
OutputStream console; OutputStream console;
BufferedReader log; MyList log;
StringBuffer currentLine; StringBuffer currentLine;
String expectation;
public MakeRecon( class MyList extends ArrayList {
IPath buildCommand, public void removeInterval (int start, int len) {
String[] buildArguments, removeRange(start, len);
String[] env,
IPath workingDirectory,
IProgressMonitor mon,
OutputStream cos) {
make = buildCommand;
if (buildArguments != null) {
args = new String[buildArguments.length + 1];
args[0] = "-n";
System.arraycopy(buildArguments, 0, args, 1, buildArguments.length);
} else {
args = new String[] { "-n" };
} }
}
public MakeRecon(IPath buildCommand, String[] buildArguments,
String[] env, IPath workingDirectory, IProgressMonitor mon, OutputStream cos) {
this(buildCommand, new String[]{"-n"}, buildArguments, env, workingDirectory, mon, cos);
}
public MakeRecon(IPath buildCommand, String[] options, String[] buildArguments,
String[] env, IPath workingDirectory, IProgressMonitor mon, OutputStream cos) {
make = buildCommand;
args = new String[0];
if (options != null) {
String[]array = new String[args.length + options.length];
System.arraycopy(args, 0, array, 0, args.length);
System.arraycopy(options, 0, array, args.length, options.length);
args = array;
}
if (buildArguments != null) {
String[] array = new String[args.length + buildArguments.length];
System.arraycopy(args, 0, array, 0, args.length);
System.arraycopy(buildArguments, 0, array, args.length, buildArguments.length);
args = array;
}
environ = env; environ = env;
directory = workingDirectory; directory = workingDirectory;
monitor = mon; monitor = mon;
console = cos; console = cos;
currentLine = new StringBuffer(); currentLine = new StringBuffer();
log = new MyList();
// Get the buffer log.
invokeMakeRecon();
} }
public void invokeMakeRecon() { private void invokeMakeRecon() {
int i = 0; int i = 0;
String[] array = new String[args.length + 1]; String[] array = new String[args.length + 1];
array[0] = make.toOSString(); array[0] = make.toOSString();
@ -67,10 +86,9 @@ public class MakeRecon extends OutputStream {
BufferedReader reader = new BufferedReader(new InputStreamReader(in)); BufferedReader reader = new BufferedReader(new InputStreamReader(in));
// Swallow the output // Swallow the output
String line; String line;
StringBuffer sb = new StringBuffer();
try { try {
while ((line = reader.readLine()) != null) { while ((line = reader.readLine()) != null) {
sb.append(line).append('\n'); log.add(line);
i++; i++;
} }
} catch (IOException e) { } catch (IOException e) {
@ -80,13 +98,11 @@ public class MakeRecon extends OutputStream {
} catch (IOException e) { } catch (IOException e) {
} }
p.destroy(); p.destroy();
log = new BufferedReader(new StringReader(sb.toString())); log.trimToSize();
} catch (IOException e1) { } catch (IOException e1) {
i = IProgressMonitor.UNKNOWN; i = IProgressMonitor.UNKNOWN;
} }
if (monitor != null) { monitor.beginTask("", i);
monitor.beginTask("", i);
}
} }
/** /**
@ -96,6 +112,7 @@ public class MakeRecon extends OutputStream {
if (console != null) { if (console != null) {
console.close(); console.close();
} }
monitor.done();
} }
/** /**
@ -155,29 +172,23 @@ public class MakeRecon extends OutputStream {
} }
private void processLine(String line) { private void processLine(String line) {
if (expectation == null) { int found = -1;
try { for (int i = 0; i < log.size(); i++) {
expectation = log.readLine(); String s = (String)log.get(i);
if (expectation != null) { if (s.startsWith(line)) {
String show; found = i;
if (expectation.length() > 150) { break;
show = expectation.substring(0, 150);
} else {
show = expectation;
}
monitor.subTask(show);
}
} catch (IOException e) {
}
if (expectation == null) {
expectation = "";
} }
} }
if (expectation.startsWith(line)) {
expectation = null; if (found != -1) {
if (monitor != null) { String show = (String)log.get(found);
monitor.worked(1); if (show.length() > 50) {
show = show.substring(0, 50);
} }
} monitor.subTask(show);
monitor.worked(found + 1);
log.removeInterval(0, found + 1);
}
} }
} }