Commit 2ce74392 authored by Andrey Filippov's avatar Andrey Filippov

Added Vivado launching, some cleanup of the code

parent 9d3c3811
...@@ -17,68 +17,14 @@ ...@@ -17,68 +17,14 @@
package com.elphel.vdt.core.launching; package com.elphel.vdt.core.launching;
import java.io.File;
import java.io.IOException;
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import org.eclipse.debug.internal.ui.views.console.ProcessConsole;
//import org.eclipse.core.resources.IProject;
//import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.IStreamListener;
//import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.model.IProcess;
//import org.eclipse.debug.ui.DebugUITools;
//import org.eclipse.ui.console.ConsolePlugin;
//import org.eclipse.ui.console.IConsoleManager;
//import org.eclipse.ui.console.IPatternMatchListener;
//import org.eclipse.ui.console.MessageConsole;
import org.eclipse.debug.core.model.IStreamMonitor;
import org.eclipse.debug.core.model.IStreamsProxy;
import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.swt.graphics.Color;
import org.eclipse.ui.console.IConsole; import org.eclipse.ui.console.IConsole;
//import org.eclipse.debug.ui.console.IConsole;
import org.eclipse.ui.console.ConsolePlugin; import org.eclipse.ui.console.ConsolePlugin;
import org.eclipse.ui.console.IConsoleManager; import org.eclipse.ui.console.IConsoleManager;
import org.eclipse.ui.console.IOConsole;
import org.eclipse.ui.console.IOConsoleInputStream;
import org.eclipse.ui.console.IOConsoleOutputStream;
import com.elphel.vdt.Txt;
import com.elphel.vdt.core.tools.contexts.BuildParamsItem;
import com.elphel.vdt.ui.MessageUI;
//import com.elphel.vdt.VDTPlugin;
import com.elphel.vdt.veditor.VerilogPlugin; import com.elphel.vdt.veditor.VerilogPlugin;
import com.elphel.vdt.veditor.parser.OutlineContainer;
import com.elphel.vdt.veditor.preference.PreferenceStrings; import com.elphel.vdt.veditor.preference.PreferenceStrings;
//import com.elphel.vdt.core.Utils;
import org.eclipse.ui.console.IConsoleListener; import org.eclipse.ui.console.IConsoleListener;
public class RunningBuilds { public class RunningBuilds {
...@@ -88,18 +34,24 @@ public class RunningBuilds { ...@@ -88,18 +34,24 @@ public class RunningBuilds {
unfinishedBuilds = new ConcurrentHashMap<String, VDTRunnerConfiguration>(); unfinishedBuilds = new ConcurrentHashMap<String, VDTRunnerConfiguration>();
IConsoleManager manager = ConsolePlugin.getDefault().getConsoleManager(); IConsoleManager manager = ConsolePlugin.getDefault().getConsoleManager();
// This is not used, just for testing // This is not used, just for testing
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING)) {
System.out.println("***Addded console listeners"); System.out.println("***Addded console listeners");
}
manager.addConsoleListener(new IConsoleListener(){ manager.addConsoleListener(new IConsoleListener(){
public void consolesAdded(IConsole[] consoles){ public void consolesAdded(IConsole[] consoles){
for (int i=0;i<consoles.length;i++){ for (int i=0;i<consoles.length;i++){
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING)) {
System.out.println("+++ Added: "+consoles[i].getName()); System.out.println("+++ Added: "+consoles[i].getName());
}
// Only shows added consoles // Only shows added consoles
} }
} }
public void consolesRemoved(IConsole[] consoles){ public void consolesRemoved(IConsole[] consoles){
for (int i=0;i<consoles.length;i++){ for (int i=0;i<consoles.length;i++){
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING)) {
System.out.println("--- Removed: "+consoles[i].getName()); System.out.println("--- Removed: "+consoles[i].getName());
// unfinishedBuilds.remove(consoles[i]); }
// unfinishedBuilds.remove(consoles[i]);
removeConsole(consoles[i]); removeConsole(consoles[i]);
} }
} }
...@@ -108,17 +60,25 @@ public class RunningBuilds { ...@@ -108,17 +60,25 @@ public class RunningBuilds {
public String findConsoleParent(IConsole console){ public String findConsoleParent(IConsole console){
Iterator<String> iter=unfinishedBuilds.keySet().iterator(); Iterator<String> iter=unfinishedBuilds.keySet().iterator();
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING)) {
System.out.println("findConsoleParent("+console.getName()+")"); System.out.println("findConsoleParent("+console.getName()+")");
}
while (iter.hasNext()) { while (iter.hasNext()) {
String consoleName=iter.next(); String consoleName=iter.next();
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING)) {
System.out.print("Got console name:"+consoleName); System.out.print("Got console name:"+consoleName);
}
VDTRunnerConfiguration runConfig=unfinishedBuilds.get(consoleName); VDTRunnerConfiguration runConfig=unfinishedBuilds.get(consoleName);
if (runConfig.hasConsole(console)){ if (runConfig.hasConsole(console)){
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING)) {
System.out.println(consoleName+" -> GOT IT"); System.out.println(consoleName+" -> GOT IT");
}
return consoleName; return consoleName;
} }
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING)) {
System.out.println(consoleName+" -> no luck"); System.out.println(consoleName+" -> no luck");
} }
}
return null; return null;
} }
public void removeConsole(IConsole console){ public void removeConsole(IConsole console){
...@@ -126,15 +86,21 @@ public class RunningBuilds { ...@@ -126,15 +86,21 @@ public class RunningBuilds {
if (consoleName!=null){ if (consoleName!=null){
VDTRunnerConfiguration runConfig=unfinishedBuilds.get(consoleName); VDTRunnerConfiguration runConfig=unfinishedBuilds.get(consoleName);
runConfig.removeConsole(console); runConfig.removeConsole(console);
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING)) {
System.out.println("Removing console "+console.getName()+" from runConfig for "+consoleName); System.out.println("Removing console "+console.getName()+" from runConfig for "+consoleName);
}
if (runConfig.noConsoles()){ if (runConfig.noConsoles()){
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING)) {
System.out.println("No consoles left in unfinished "+consoleName+" - removing it too"); System.out.println("No consoles left in unfinished "+consoleName+" - removing it too");
}
unfinishedBuilds.remove(consoleName); unfinishedBuilds.remove(consoleName);
} }
} else { } else {
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING)) {
System.out.println("Console "+console.getName()+" did not belong here"); System.out.println("Console "+console.getName()+" did not belong here");
} }
} }
}
public boolean isUnfinished(IConsole console){ public boolean isUnfinished(IConsole console){
return unfinishedBuilds.containsKey(console); return unfinishedBuilds.containsKey(console);
} }
......
...@@ -54,35 +54,20 @@ import com.elphel.vdt.veditor.preference.PreferenceStrings; ...@@ -54,35 +54,20 @@ import com.elphel.vdt.veditor.preference.PreferenceStrings;
import com.sun.net.ssl.internal.www.protocol.https.Handler; import com.sun.net.ssl.internal.www.protocol.https.Handler;
public class VDTConsoleRunner{ public class VDTConsoleRunner{
private final VDTRunnerConfiguration runConfig; private final VDTRunnerConfiguration runConfig; //*
private IProcess processErr=null; private IProcess processErr=null; //*
private IProcess processOut=null; private IProcess processOut=null; //*
private IStreamsProxy stdoutStreamProxy=null;
private IStreamsProxy stderrStreamProxy=null;
private IStreamsProxy sendErrorsToStreamProxy=null; private IStreamsProxy sendErrorsToStreamProxy=null;
private Object errorListener=null; //+ private Object errorListener=null; //+
private Object outputListener=null; //+ private Object outputListener=null; //+
private IOConsole iCons=null; private IStreamsProxy consoleInStreamProxy= null; //+
private IProcess process=null; private Timer timer;
private IStreamsProxy consoleInStreamProxy= null;
public VDTConsoleRunner (VDTRunnerConfiguration runConfig){ public VDTConsoleRunner (VDTRunnerConfiguration runConfig){
this.runConfig=runConfig; this.runConfig=runConfig;
} }
/*
* private BuildParamsItem getParser( String parserName){
if (parserName==null) return null;
BuildParamsItem[] buildParamsItems = runConfig.getArgumentsItemsArray(); // uses already calculated
if (buildParamsItems==null) return null;
for (int i=0;i<buildParamsItems.length;i++){
if (parserName.equals(buildParamsItems[i].getNameAsParser()))
return buildParamsItems[i];
}
return null;
}
*/
private int getParserIndex( String parserName){ private int getParserIndex( String parserName){
if (parserName==null) return -1; if (parserName==null) return -1;
BuildParamsItem[] buildParamsItems = runConfig.getArgumentsItemsArray(); // uses already calculated BuildParamsItem[] buildParamsItems = runConfig.getArgumentsItemsArray(); // uses already calculated
...@@ -99,6 +84,8 @@ public class VDTConsoleRunner{ ...@@ -99,6 +84,8 @@ public class VDTConsoleRunner{
, ILaunch launch , ILaunch launch
, IProgressMonitor monitor , IProgressMonitor monitor
) throws CoreException{ ) throws CoreException{
final boolean debugPrint=VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING);
VDTRunner runner = VDTLaunchUtil.getRunner(); VDTRunner runner = VDTLaunchUtil.getRunner();
int numItem=runConfig.getBuildStep(); int numItem=runConfig.getBuildStep();
BuildParamsItem buildParamsItem = runConfig.getArgumentsItemsArray()[numItem]; // uses already calculated BuildParamsItem buildParamsItem = runConfig.getArgumentsItemsArray()[numItem]; // uses already calculated
...@@ -106,8 +93,7 @@ public class VDTConsoleRunner{ ...@@ -106,8 +93,7 @@ public class VDTConsoleRunner{
// Find console with name starting with consolePrefix // Find console with name starting with consolePrefix
IConsoleManager man = ConsolePlugin.getDefault().getConsoleManager(); // debugging IConsoleManager man = ConsolePlugin.getDefault().getConsoleManager(); // debugging
IConsole[] consoles=(IConsole[]) man.getConsoles(); IConsole[] consoles=(IConsole[]) man.getConsoles();
// IOConsole iCons=null; IOConsole iCons=null;
iCons=null;
consoleInStreamProxy=null; consoleInStreamProxy=null;
for (int i=0;i<consoles.length;i++){ for (int i=0;i<consoles.length;i++){
if (consoles[i].getName().startsWith(consolePrefix)){ if (consoles[i].getName().startsWith(consolePrefix)){
...@@ -122,7 +108,7 @@ public class VDTConsoleRunner{ ...@@ -122,7 +108,7 @@ public class VDTConsoleRunner{
// try to send // try to send
String[] arguments = runConfig.getToolArguments(); String[] arguments = runConfig.getToolArguments();
if (arguments == null) arguments=new String[0]; if (arguments == null) arguments=new String[0];
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING)) { if (debugPrint) {
// System.out.println("patternErrors= \""+ runConfig.getPatternErrors()+"\""); // System.out.println("patternErrors= \""+ runConfig.getPatternErrors()+"\"");
// System.out.println("patternWarnings= \""+runConfig.getPatternWarnings()+"\""); // System.out.println("patternWarnings= \""+runConfig.getPatternWarnings()+"\"");
// System.out.println("patternInfo= \"" +runConfig.getPatternInfo()+"\""); // System.out.println("patternInfo= \"" +runConfig.getPatternInfo()+"\"");
...@@ -134,27 +120,21 @@ public class VDTConsoleRunner{ ...@@ -134,27 +120,21 @@ public class VDTConsoleRunner{
} }
runner.log("Writing to console "+iCons.getName()+":", arguments, null, false, true); /* Appears in the console of the target Eclipse (immediately erased) */ runner.log("Writing to console "+iCons.getName()+":", arguments, null, false, true); /* Appears in the console of the target Eclipse (immediately erased) */
runner.log("Writing to console "+iCons.getName()+":", arguments, null, false, false); /* Appears in the console of the parent Eclipse */ runner.log("Writing to console "+iCons.getName()+":", arguments, null, false, false); /* Appears in the console of the parent Eclipse */
// IOConsoleInputStream inStream= iCons.getInputStream();
IOConsoleOutputStream outStream= iCons.newOutputStream(); IOConsoleOutputStream outStream= iCons.newOutputStream();
// IProcess process=((ProcessConsole)iCons).getProcess(); IProcess process=((ProcessConsole)iCons).getProcess();
process=((ProcessConsole)iCons).getProcess();
// IStreamsProxy consoleInStreamProxy= process.getStreamsProxy();
consoleInStreamProxy= process.getStreamsProxy(); consoleInStreamProxy= process.getStreamsProxy();
int stderrParserIndex=getParserIndex(buildParamsItem.getStderr()); int stderrParserIndex=getParserIndex(buildParamsItem.getStderr());
int stdoutParserIndex=getParserIndex(buildParamsItem.getStdout()); int stdoutParserIndex=getParserIndex(buildParamsItem.getStdout());
BuildParamsItem stderrParser=(stderrParserIndex>=0)?runConfig.getArgumentsItemsArray()[stderrParserIndex]:null; BuildParamsItem stderrParser=(stderrParserIndex>=0)?runConfig.getArgumentsItemsArray()[stderrParserIndex]:null;
BuildParamsItem stdoutParser=(stdoutParserIndex>=0)?runConfig.getArgumentsItemsArray()[stdoutParserIndex]:null; BuildParamsItem stdoutParser=(stdoutParserIndex>=0)?runConfig.getArgumentsItemsArray()[stdoutParserIndex]:null;
// BuildParamsItem stderrParser=getParser(buildParamsItem.getStderr()); // re-parses all - why? if (debugPrint) {
// BuildParamsItem stdoutParser=getParser(buildParamsItem.getStdout());
System.out.println("Using parser for stderr: "+((stderrParser!=null)?stderrParser.getNameAsParser():"none")); // actually may be the same as stdout System.out.println("Using parser for stderr: "+((stderrParser!=null)?stderrParser.getNameAsParser():"none")); // actually may be the same as stdout
System.out.println("Using parser for stdout: "+((stdoutParser!=null)?stdoutParser.getNameAsParser():"none")); System.out.println("Using parser for stdout: "+((stdoutParser!=null)?stdoutParser.getNameAsParser():"none"));
}
processErr=null; processErr=null;
processOut=null; processOut=null;
stdoutStreamProxy=null; IStreamsProxy stdoutStreamProxy=null;
stderrStreamProxy=null; IStreamsProxy stderrStreamProxy=null;
if (stdoutParser!=null){ if (stdoutParser!=null){
List<String> toolArgumentsStdout = new ArrayList<String>(); List<String> toolArgumentsStdout = new ArrayList<String>();
List<String> stdoutArguments=stdoutParser.getParamsAsList(); List<String> stdoutArguments=stdoutParser.getParamsAsList();
...@@ -168,7 +148,6 @@ public class VDTConsoleRunner{ ...@@ -168,7 +148,6 @@ public class VDTConsoleRunner{
null, //monitor null, //monitor
stdoutParserIndex); stdoutParserIndex);
stdoutStreamProxy= processOut.getStreamsProxy(); stdoutStreamProxy= processOut.getStreamsProxy();
//TODO: Add error parsers
} }
if (stderrParser!=null){ if (stderrParser!=null){
...@@ -197,22 +176,23 @@ public class VDTConsoleRunner{ ...@@ -197,22 +176,23 @@ public class VDTConsoleRunner{
runConfig.resetConsoleText(); runConfig.resetConsoleText();
String interrupt=buildParamsItem.getInterrupt(); // Not yet used String interrupt=buildParamsItem.getInterrupt(); // Not yet used
runConfig.setConsoleFinish(buildParamsItem.getPrompt()); runConfig.setConsoleFinish(buildParamsItem.getPrompt());
if (debugPrint) {
System.out.println("Using console program termination string: \""+buildParamsItem.getPrompt()+"\""); System.out.println("Using console program termination string: \""+buildParamsItem.getPrompt()+"\"");
}
errorListener=null; errorListener=null;
if (fSendErrorsToStreamProxy!=null){ if (fSendErrorsToStreamProxy!=null){
consoleErrStreamMonitor=consoleInStreamProxy.getErrorStreamMonitor(); consoleErrStreamMonitor=consoleInStreamProxy.getErrorStreamMonitor();
// IStreamListener errorListener=null;
errorListener=new IStreamListener(){ errorListener=new IStreamListener(){
public void streamAppended(String text, IStreamMonitor monitor){ public void streamAppended(String text, IStreamMonitor monitor){
// System.out.println("Err:'"+text+"'");
try { try {
fSendErrorsToStreamProxy.write(text); fSendErrorsToStreamProxy.write(text);
} catch (IOException e) { } catch (IOException e) {
System.out.println("Can not write errors"); //happens for the last prompt got after finish marker if (debugPrint) System.out.println("Can not write errors"); //happens for the last prompt got after finish marker
} }
if (runConfig.addConsoleText(text)){ if (runConfig.addConsoleText(text)){
System.out.println("Got finish sequence"); if (debugPrint) System.out.println("Got finish sequence");
// TODO: launch continuation of the build process // TODO: launch continuation of the build process
finishConsolescript(); finishConsolescript();
} }
...@@ -225,14 +205,13 @@ public class VDTConsoleRunner{ ...@@ -225,14 +205,13 @@ public class VDTConsoleRunner{
consoleOutStreamMonitor=consoleInStreamProxy.getOutputStreamMonitor(); consoleOutStreamMonitor=consoleInStreamProxy.getOutputStreamMonitor();
outputListener=new IStreamListener(){ outputListener=new IStreamListener(){
public void streamAppended(String text, IStreamMonitor monitor){ public void streamAppended(String text, IStreamMonitor monitor){
// System.out.println("Out:'"+text+"'");
try { try {
fSendOutputToStreamProxy.write(text); fSendOutputToStreamProxy.write(text);
} catch (IOException e) { } catch (IOException e) {
System.out.println("Can not write output"); if (debugPrint) System.out.println("Can not write output");
} }
if (runConfig.addConsoleText(text)){ if (runConfig.addConsoleText(text)){
System.out.println("Got finish sequence"); if (debugPrint) System.out.println("Got finish sequence");
// TODO: launch continuation of the build process // TODO: launch continuation of the build process
finishConsolescript(); finishConsolescript();
} }
...@@ -253,13 +232,15 @@ public class VDTConsoleRunner{ ...@@ -253,13 +232,15 @@ public class VDTConsoleRunner{
} }
int timeout=buildParamsItem.getTimeout(); int timeout=buildParamsItem.getTimeout();
if ((timeout==0) && (buildParamsItem.getPrompt()==null)) timeout=1;// should specify at least one of timeout or prompt if ((timeout==0) && (buildParamsItem.getPrompt()==null)) timeout=1;// should specify at least one of timeout or prompt
timer=null;
if (timeout>0){ if (timeout>0){
System.out.println("Setting timeout "+timeout); if (debugPrint) System.out.println("Setting timeout "+timeout);
final int fTimeout = timeout; final int fTimeout = timeout;
new Timer().schedule(new TimerTask() { timer=new Timer();
timer.schedule(new TimerTask() {
@Override @Override
public void run() { public void run() {
System.out.println(">>Timeout<<"); if (debugPrint) System.out.println(">>Timeout<<");
finishConsolescript(); finishConsolescript();
} }
}, fTimeout*1000); }, fTimeout*1000);
...@@ -271,7 +252,11 @@ public class VDTConsoleRunner{ ...@@ -271,7 +252,11 @@ public class VDTConsoleRunner{
// TODO: remove unneeded global vars // TODO: remove unneeded global vars
public void finishConsolescript() { public void finishConsolescript() {
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING))
System.out.println("finishConsolescript()"); System.out.println("finishConsolescript()");
if (timer!=null){
timer.cancel();
}
if (consoleInStreamProxy==null) { if (consoleInStreamProxy==null) {
System.out.println("Bug: consoleInStreamProxy == null"); System.out.println("Bug: consoleInStreamProxy == null");
return; // or continue other commands? return; // or continue other commands?
...@@ -289,19 +274,18 @@ public class VDTConsoleRunner{ ...@@ -289,19 +274,18 @@ public class VDTConsoleRunner{
try { try {
processErr.terminate(); processErr.terminate();
} catch (DebugException e) { } catch (DebugException e) {
System.out.println("Failed to reminate processErr parser process"); System.out.println("Failed to terminate processErr parser process");
} }
} }
if (processOut!=null){ if (processOut!=null){
try { try {
processOut.terminate(); processOut.terminate();
} catch (DebugException e) { } catch (DebugException e) {
System.out.println("Failed to reminate processOut parser process"); System.out.println("Failed to terminate processOut parser process");
} }
} }
// Is that all?
// runConfig.setBuildStep(runConfig.getBuildStep()+1); // next task to run
int thisStep=runConfig.getBuildStep(); int thisStep=runConfig.getBuildStep();
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING))
System.out.println("Finished console task, step was "+thisStep); System.out.println("Finished console task, step was "+thisStep);
runConfig.setBuildStep(thisStep+1); // next task to run runConfig.setBuildStep(thisStep+1); // next task to run
VDTLaunchUtil.getRunner().getRunningBuilds().saveUnfinished(runConfig.getOriginalConsoleName(), runConfig ); VDTLaunchUtil.getRunner().getRunningBuilds().saveUnfinished(runConfig.getOriginalConsoleName(), runConfig );
......
...@@ -42,6 +42,7 @@ import com.elphel.vdt.VDT; ...@@ -42,6 +42,7 @@ import com.elphel.vdt.VDT;
import com.elphel.vdt.VerilogUtils; import com.elphel.vdt.VerilogUtils;
// import com.elphel.vdt.VDTPlugin; // import com.elphel.vdt.VDTPlugin;
import com.elphel.vdt.veditor.VerilogPlugin; import com.elphel.vdt.veditor.VerilogPlugin;
import com.elphel.vdt.veditor.preference.PreferenceStrings;
import com.elphel.vdt.core.tools.ToolsCore; import com.elphel.vdt.core.tools.ToolsCore;
import com.elphel.vdt.core.tools.contexts.BuildParamsItem; import com.elphel.vdt.core.tools.contexts.BuildParamsItem;
import com.elphel.vdt.core.tools.params.Parameter; import com.elphel.vdt.core.tools.params.Parameter;
...@@ -65,11 +66,15 @@ public class VDTLaunchUtil { ...@@ -65,11 +66,15 @@ public class VDTLaunchUtil {
*/ */
public static VDTRunner getRunner() { public static VDTRunner getRunner() {
if (toolRunner == null) { if (toolRunner == null) {
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING)) {
System.out.println ("Created new VDTRunner()"); System.out.println ("Created new VDTRunner()");
}
toolRunner = new VDTRunner(); toolRunner = new VDTRunner();
} else { } else {
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING)) {
System.out.println ("Reused old VDTRunner()"); System.out.println ("Reused old VDTRunner()");
} }
}
return toolRunner; return toolRunner;
} }
//runningBuilds //runningBuilds
......
...@@ -106,13 +106,15 @@ public class VDTRunner { ...@@ -106,13 +106,15 @@ public class VDTRunner {
// make call it when console is closed // make call it when console is closed
private void doResumeLaunch(String consoleName ) throws CoreException { private void doResumeLaunch(String consoleName ) throws CoreException {
final VDTRunnerConfiguration runConfig=runningBuilds.resumeConfiguration(consoleName); final VDTRunnerConfiguration runConfig=runningBuilds.resumeConfiguration(consoleName);
final boolean debugPrint=VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING);
if (runConfig==null){ if (runConfig==null){
System.out.println("Turned out nothing to do. Probably a bug"); System.out.println("Turned out nothing to do. Probably a bug");
return; return;
} }
BuildParamsItem[] argumentsItemsArray = runConfig.getArgumentsItemsArray(); // uses already calculated BuildParamsItem[] argumentsItemsArray = runConfig.getArgumentsItemsArray(); // uses already calculated
int numItem=runConfig.getBuildStep(); int numItem=runConfig.getBuildStep();
System.out.println("--------- resuming "+ consoleName+", numItem="+numItem+" ------------"); if (debugPrint) System.out.println("--------- resuming "+ consoleName+", numItem="+numItem+" ------------");
ILaunch launch=runConfig.getLaunch(); ILaunch launch=runConfig.getLaunch();
IProgressMonitor monitor=runConfig.getMonitor(); IProgressMonitor monitor=runConfig.getMonitor();
for (;numItem<argumentsItemsArray.length;numItem++){ for (;numItem<argumentsItemsArray.length;numItem++){
...@@ -132,7 +134,7 @@ public class VDTRunner { ...@@ -132,7 +134,7 @@ public class VDTRunner {
} }
if (argumentsItemsArray[numItem].getNameAsParser()!=null){ if (argumentsItemsArray[numItem].getNameAsParser()!=null){
// parsers should be launched by the console scripts, in parallel to them // parsers should be launched by the console scripts, in parallel to them
System.out.println("Skipping parser "+argumentsItemsArray[numItem].getNameAsParser()); if (debugPrint) System.out.println("Skipping parser "+argumentsItemsArray[numItem].getNameAsParser());
continue; continue;
} }
// Launch the configuration - 1 unit of work // Launch the configuration - 1 unit of work
...@@ -147,8 +149,6 @@ public class VDTRunner { ...@@ -147,8 +149,6 @@ public class VDTRunner {
); );
//Andrey: if there is a single item - launch asynchronously, if more - verify queue is empty //Andrey: if there is a single item - launch asynchronously, if more - verify queue is empty
// will not change
// String consoleName=renderProcessLabel(runConfig.getToolName());
// check for cancellation // check for cancellation
if (monitor.isCanceled() || (process==null)) { if (monitor.isCanceled() || (process==null)) {
...@@ -163,17 +163,17 @@ public class VDTRunner { ...@@ -163,17 +163,17 @@ public class VDTRunner {
IOConsole iCons= (IOConsole) DebugUITools.getConsole(process); // had non-null fPatternMatcher , fType="org.eclipse.debug.ui.ProcessConsoleType" IOConsole iCons= (IOConsole) DebugUITools.getConsole(process); // had non-null fPatternMatcher , fType="org.eclipse.debug.ui.ProcessConsoleType"
if (iCons==null){ if (iCons==null){
System.out.println("Could not get a console for the specified process"); System.out.println("Could not get console for the specified process");
continue; continue;
} }
System.out.println("originalConsoleName="+consoleName+ if (debugPrint) System.out.println("originalConsoleName="+consoleName+
"\nprocessConsole name="+iCons.getName()); "\nprocessConsole name="+iCons.getName());
final IOConsole fiCons=iCons; final IOConsole fiCons=iCons;
// final String fConsoleName=fiCons.getName(); // actual console name - may be already "<terminated> ... " // final String fConsoleName=fiCons.getName(); // actual console name - may be already "<terminated> ... "
final String fConsoleName=consoleName; // calculated console name - used for launching external program final String fConsoleName=consoleName; // calculated console name - used for launching external program
// if (!fConsoleName.equals(consoleName)){ // terminated before we added listeners // if (!fConsoleName.equals(consoleName)){ // terminated before we added listeners
if (!fConsoleName.equals(fiCons.getName())){ // terminated before we added listeners if (!fConsoleName.equals(fiCons.getName())){ // terminated before we added listeners
System.out.println("Already terminated, proceed to the next item"); if (debugPrint) System.out.println("Already terminated, proceed to the next item");
continue; // proceed with the next item without pausing continue; // proceed with the next item without pausing
} }
/* Prepare to postpone next commands to be resumed by event*/ /* Prepare to postpone next commands to be resumed by event*/
...@@ -184,24 +184,27 @@ public class VDTRunner { ...@@ -184,24 +184,27 @@ public class VDTRunner {
public void propertyChange(PropertyChangeEvent event) { public void propertyChange(PropertyChangeEvent event) {
if (!fConsoleName.equals(fiCons.getName())){ if (!fConsoleName.equals(fiCons.getName())){
fiCons.removePropertyChangeListener(this); fiCons.removePropertyChangeListener(this);
System.out.println(">>> "+fConsoleName+" -> "+fiCons.getName()); if (debugPrint) System.out.println(">>> "+fConsoleName+" -> "+fiCons.getName());
// VDTRunner runner = VDTLaunchUtil.getRunner();
try { try {
resumeLaunch(fConsoleName); // replace with console resumeLaunch(fConsoleName); // replace with console
} catch (CoreException e) { } catch (CoreException e) {
// TODO Auto-generated catch block System.out.println ("Failed to resume launch sequence");
e.printStackTrace();
} }
} }
} }
}); });
if (!fConsoleName.equals(consoleName)){ // terminated before we added listeners if (!fConsoleName.equals(consoleName)){ // terminated before we added listeners
System.out.println("Fire!"); if (debugPrint) System.out.println("Fire!");
iCons.firePropertyChange(fiCons,"org.eclipse.jface.text", consoleName, fConsoleName); iCons.firePropertyChange(fiCons,"org.eclipse.jface.text", consoleName, fConsoleName);
} }
System.out.println("return - waiting to be awaken"); if (debugPrint) System.out.println("return - waiting to be awaken");
int timeout=argumentsItemsArray[numItem].getTimeout(); int timeout=argumentsItemsArray[numItem].getTimeout();
if (timeout>0){ if (timeout>0){
System.out.println ("timeout is only implemented for console scripts");
// implementation will require keeping track of it and canceling if program terminated earlier.
// And for the programs it is easy to kill them manually with a red square button
if (timeout>100000) { //never with no warnings
final int fTimeout = timeout; final int fTimeout = timeout;
final IProcess fProcess=process; final IProcess fProcess=process;
new Timer().schedule(new TimerTask() { new Timer().schedule(new TimerTask() {
...@@ -211,11 +214,12 @@ public class VDTRunner { ...@@ -211,11 +214,12 @@ public class VDTRunner {
try { try {
fProcess.terminate(); fProcess.terminate();
} catch (DebugException e) { } catch (DebugException e) {
System.out.println("Failed to terminate preocess on "+fConsoleName); System.out.println("Failed to terminate process on "+fConsoleName);
} }
} }
}, fTimeout*1000); }, fTimeout*1000);
} }
}
return; return;
...@@ -397,7 +401,9 @@ public class VDTRunner { ...@@ -397,7 +401,9 @@ public class VDTRunner {
if (consoles.length>1){ if (consoles.length>1){
// ((IConsole) consoles[1]).setName("Python Consloe"); // ((IConsole) consoles[1]).setName("Python Consloe");
} }
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING)){
System.out.println(consoles.length+" consoles, processes="+launch.getChildren().length); System.out.println(consoles.length+" consoles, processes="+launch.getChildren().length);
}
return process; return process;
//= consoles //= consoles
//setImageDescriptor //setImageDescriptor
......
...@@ -49,6 +49,14 @@ ...@@ -49,6 +49,14 @@
icon="my_tool.gif" icon="my_tool.gif"
call="RemotePythonCommand"/> call="RemotePythonCommand"/>
<menuitem name="Vivado"
label="Run remote Vivado session"
icon="xilinx.png"
call="Vivado"/>
<menuitem name="Vivado Test"
label="Send a command to the remote Vivado session"
icon="my_tool.gif"
call="VivadoTest"/>
<menu name="XDS" <menu name="XDS"
label="Demo XDS Tools" label="Demo XDS Tools"
......
...@@ -30,9 +30,11 @@ ...@@ -30,9 +30,11 @@
<parameter id="ShellSwitches" label="Shell switches" type="String" <parameter id="ShellSwitches" label="Shell switches" type="String"
format="CopyValue" default="-c" readonly="false" visible="true" /> format="CopyValue" default="-c" readonly="false" visible="true" />
<parameter id="SSHSwitches" label="Remote ssh switches" <parameter id="TerminalMode" type="BoolYesNo" format="None"
type="String" format="CopyValue" default="" readonly="false" visible="true" /> default="false" label="Force termonal mode for remote program" />
<parameter id="SSHSwitches" label="Other ssh switches"
type="String" format="CopyValue" default="" readonly="false" visible="true" />
<parameter id="RemoteCommand" label="Remote ssh command" <parameter id="RemoteCommand" label="Remote ssh command"
type="String" format="CopyValue" default="python -i -u" readonly="false" type="String" format="CopyValue" default="python -i -u" readonly="false"
...@@ -45,6 +47,7 @@ ...@@ -45,6 +47,7 @@
<group name="General"> <group name="General">
"RemoteHost" "RemoteHost"
"RemoteUser" "RemoteUser"
"TerminalMode"
"ShellSwitches" "ShellSwitches"
"PreSSH" "PreSSH"
"SSHSwitches" "SSHSwitches"
...@@ -59,11 +62,13 @@ ...@@ -59,11 +62,13 @@
"%ShellSwitches" "%ShellSwitches"
"%PreSSH" "%PreSSH"
"ssh" "ssh"
"-t" <if TerminalMode = "true">
"-t -t"
</if>
"%SSHSwitches"
"-l" "-l"
"%RemoteUser" "%RemoteUser"
"%RemoteHost" "%RemoteHost"
"%SSHSwitches"
"'" "'"
"%RemoteCommand" "%RemoteCommand"
"'" "'"
......
<?xml version="1.0" encoding="UTF-8"?>
<vdt-project>
<interface name="VivadoInterface" extends="project_interface">
<syntax name="ProgramSyntax" format="%(%%ParamValue%|\n%)" />
</interface>
<tool name="Vivado" project="FPGA_project" label="Launch Vivado"
shell="/bin/bash" interface="VivadoInterface" description="Launching remote Xilinx Vivado in console"
errors="(.*):([0-9]+): [a-z ]*error: (.*)" warnings="(.*):([0-9]+): warning: (.*)"
info="(.*):([0-9]+): info: (.*)"> <!--does not actually exist -->
<extensions-list>
<extension mask="v" />
<extension mask="tf" />
</extensions-list>
<action-menu>
<action label="Launch Vivado" resource="" icon="xilinx.png" />
</action-menu>
<parameter id="RemoteHost" label="Remote Host IP" type="String"
format="CopyValue" default="192.168.0.122" readonly="false" visible="true" />
<parameter id="RemoteUser" label="Remote user name" type="String"
format="CopyValue" default="xilinx" readonly="false" visible="true" />
<parameter id="PreSSH" label="pre-ssh shell parameters"
type="String" format="CopyValue" default="" readonly="false" visible="true" />
<parameter id="ShellSwitches" label="Shell switches" type="String"
format="CopyValue" default="-c" readonly="false" visible="true" />
<parameter id="TerminalMode" type="BoolYesNo" format="None"
default="false" label="Force termonal mode for remote program" />
<parameter id="SSHSwitches" label="Other ssh switches"
type="String" format="CopyValue" default="" readonly="false" visible="true" />
<parameter id="RemoteCommand" label="Remote ssh command"
type="String" format="CopyValue" default="/opt/Xilinx/Vivado/2013.4/bin/vivado -mode tcl" readonly="false"
visible="true" />
<parameter id="SSHExtra" label="ssh extra parameters" type="String"
format="CopyValue" default="" readonly="false" visible="true" />
<input>
<group name="General">
"RemoteHost"
"RemoteUser"
"TerminalMode"
"ShellSwitches"
"PreSSH"
"SSHSwitches"
"RemoteCommand"
"SSHExtra"
</group>
</input>
<output>
<line name="vivado_launch"
interrupt="\x03">
"%ShellSwitches"
"%PreSSH"
"ssh"
<if TerminalMode = "true">
"-t -t"
</if>
"%SSHSwitches"
"-l"
"%RemoteUser"
"%RemoteHost"
"'"
"%RemoteCommand"
"'"
"%SSHExtra"
</line>
</output>
</tool>
<tool name="VivadoTest" project="FPGA_project" label="VivadoCommand"
shell="/bin/bash" interface="VivadoInterface"
description="Sending command to a remote Vivado session" errors="(.*):([0-9]+): [a-z ]*error: (.*)"
warnings="(.*):([0-9]+): warning: (.*)" info="(.*):([0-9]+): info: (.*)"> <!--does not actually exist -->
<extensions-list>
<extension mask="v" />
<extension mask="tf" />
</extensions-list>
<action-menu>
<action label="Vivado Command" resource="" icon="xilinx.png" />
</action-menu>
<parameter id="RemoteCommand" label="Remote Command to send"
type="Stringlist" format="ProgramSyntax" default="puts &quot;Hello, World!&quot;"
readonly="false" visible="true" />
<parameter id="vivado_console" default="Vivado"
type="String" format="CopyValue" visible="false" />
<parameter id="Timeout" label="Script timeout(sec)" type="Cardinal"
format="CopyValue" default="10" readonly="false" visible="true" />
<input>
<group name="General">
"RemoteCommand"
"Timeout"
</group>
</input>
<output>
<line name="pre_tcl">
"-c"
"echo 'scp files here' ;"
"sleep 2 ;"
</line>
<!-- TODO: Make it OK to ose just strings, not parameters in dest (for console names) -->
<line name="vivado_line_01"
dest="vivado_console"
mark="``"
sep="\n"
prompt="@@FINISH@@"
stdout="parser_001"
timeout="Timeout">
"%RemoteCommand"
"puts '@@FINISH@@'"
"``"`" <!-- two new lines should generate a pair of prompts from the remote -->
</line>
<line name="command_line_02">
"-c"
"echo 'Will scp result files back here' ;"
"sleep 2 ;"
</line>
<!-- parser_01 being referenced should be launched in an asynchronous process/console, removed from the launch sequence -->
<line name="parser_001"
errors="(.*):([0-9]+): [a-z ]*error: (.*)"
warnings="(.*):([0-9]+): warning: (.*)"
info="(.*):([0-9]+): info: (.*)">
"-c"
"cat"
</line>
</output>
</tool>
</vdt-project>
<!-- /opt/Xilinx/Vivado/2013.4/bin/vivado -mode tcl -->
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment