Commit d8bf8483 authored by Andrey Filippov's avatar Andrey Filippov

Tool dependency, sequencing, wait for VEditor database

parent e166573a
...@@ -158,5 +158,7 @@ public class VDT { ...@@ -158,5 +158,7 @@ public class VDT {
public static final String GENERATOR_ID_STATE_DIR = "StateDir"; public static final String GENERATOR_ID_STATE_DIR = "StateDir";
public static final String GENERATOR_ID_STATE_FILE = "StateFile"; public static final String GENERATOR_ID_STATE_FILE = "StateFile";
public static final String TIME_STAMP_FORMAT = "yyyyMMddHHmmssSSS";
} // class VDT } // class VDT
...@@ -24,8 +24,10 @@ import java.util.Iterator; ...@@ -24,8 +24,10 @@ import java.util.Iterator;
import java.util.Set; import java.util.Set;
import java.util.Vector; import java.util.Vector;
import com.elphel.vdt.ui.variables.SelectedResourceManager;
import com.elphel.vdt.veditor.VerilogPlugin; import com.elphel.vdt.veditor.VerilogPlugin;
import com.elphel.vdt.veditor.document.HdlDocument; import com.elphel.vdt.veditor.document.HdlDocument;
import com.elphel.vdt.veditor.document.VerilogDocument;
import com.elphel.vdt.veditor.parser.OutlineContainer; import com.elphel.vdt.veditor.parser.OutlineContainer;
import com.elphel.vdt.veditor.parser.OutlineDatabase; import com.elphel.vdt.veditor.parser.OutlineDatabase;
//import com.elphel.vdt.veditor.parser.vhdl.VhdlOutlineElementFactory.PackageDeclElement; //import com.elphel.vdt.veditor.parser.vhdl.VhdlOutlineElementFactory.PackageDeclElement;
...@@ -67,7 +69,9 @@ public class VerilogUtils { ...@@ -67,7 +69,9 @@ public class VerilogUtils {
e.printStackTrace(); e.printStackTrace();
} }
if (hdlDocument!=null) return hdlDocument.getOutlineDatabase(); /* will create a new one if does not exist */ if (hdlDocument!=null) return hdlDocument.getOutlineDatabase(); /* will create a new one if does not exist */
return null; // Create HdlDocument from selected/restored HDLfile
hdlDocument=new VerilogDocument(project, (IFile) SelectedResourceManager.getDefault().getChosenVerilogFile());
return hdlDocument.getOutlineDatabase(); /* will create a new one if does not exist */
} }
public static String [] getExtList(String str){ public static String [] getExtList(String str){
......
...@@ -39,7 +39,7 @@ public class ParamBasedListOption extends ParamBasedOption { ...@@ -39,7 +39,7 @@ public class ParamBasedListOption extends ParamBasedOption {
/** /**
* Set the option value * Set the option value
* *
* @param value the sequnce of the list items separated by SEPARATOR. * @param value the sequence of the list items separated by SEPARATOR.
*/ */
public void setValue(String value) { public void setValue(String value) {
List<String> list = OptionsUtils.convertStringToList(value); List<String> list = OptionsUtils.convertStringToList(value);
......
...@@ -46,7 +46,7 @@ public class ValueBasedListOption extends Option { ...@@ -46,7 +46,7 @@ public class ValueBasedListOption extends Option {
/** /**
* Set the option value * Set the option value
* *
* @param value the sequnce of the list items separated by SEPARATOR. * @param value the sequence of the list items separated by SEPARATOR.
*/ */
public void setValue(String value) { public void setValue(String value) {
List<String> list = OptionsUtils.convertStringToList(value); List<String> list = OptionsUtils.convertStringToList(value);
......
...@@ -114,6 +114,7 @@ public class XMLConfig extends Config { ...@@ -114,6 +114,7 @@ public class XMLConfig extends Config {
static final String CONTEXT_TOOL_DEPENDS_LIST_TAG = "depends-list"; static final String CONTEXT_TOOL_DEPENDS_LIST_TAG = "depends-list";
static final String CONTEXT_TOOL_DEPENDS_TAG = "depends"; static final String CONTEXT_TOOL_DEPENDS_TAG = "depends";
static final String CONTEXT_TOOL_DEPENDS_STATE_TAG = "state"; static final String CONTEXT_TOOL_DEPENDS_STATE_TAG = "state";
static final String CONTEXT_TOOL_DEPENDS_FILES_TAG = "files";
// TODO: May add other types of dependencies // TODO: May add other types of dependencies
static final String CONTEXT_TOOL_DFLT_ACTION_LABEL = "Run for"; static final String CONTEXT_TOOL_DFLT_ACTION_LABEL = "Run for";
...@@ -663,7 +664,8 @@ public class XMLConfig extends Config { ...@@ -663,7 +664,8 @@ public class XMLConfig extends Config {
List<String> toolExtensionsList = readToolExtensionsList(contextNode, contextName); List<String> toolExtensionsList = readToolExtensionsList(contextNode, contextName);
List<RunFor> toolRunfor= readToolRunForList(contextNode, contextName); List<RunFor> toolRunfor= readToolRunForList(contextNode, contextName);
List<String> toolDepends= readToolDependsList(contextNode, contextName); List<String> toolDependsStates= readToolDependsList(contextNode, contextName,false);
List<String> toolDependsFiles= readToolDependsList(contextNode, contextName,true);
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER)) { if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER)) {
System.out.println("contextNode.getNodeValue()="+contextNode.getNodeValue()); System.out.println("contextNode.getNodeValue()="+contextNode.getNodeValue());
...@@ -692,7 +694,8 @@ public class XMLConfig extends Config { ...@@ -692,7 +694,8 @@ public class XMLConfig extends Config {
toolInfo, toolInfo,
toolRunfor, toolRunfor,
ignoreFilter, ignoreFilter,
toolDepends, toolDependsStates,
toolDependsFiles,
logDir, logDir,
stateDir, stateDir,
disabled, disabled,
...@@ -1045,9 +1048,12 @@ public class XMLConfig extends Config { ...@@ -1045,9 +1048,12 @@ public class XMLConfig extends Config {
return extList; return extList;
} }
private List<String> readToolDependsList(Node toolNode, String toolName) private List<String> readToolDependsList(Node toolNode, String toolName, boolean filesNotStates)
throws ConfigException throws ConfigException
{ {
String filesStateTag= filesNotStates?CONTEXT_TOOL_DEPENDS_FILES_TAG:CONTEXT_TOOL_DEPENDS_STATE_TAG;
String otherTag= (!filesNotStates)?CONTEXT_TOOL_DEPENDS_FILES_TAG:CONTEXT_TOOL_DEPENDS_STATE_TAG;
String toolInfo = "Tool '" + toolName + "'"; String toolInfo = "Tool '" + toolName + "'";
List<String> depList = new ArrayList<String>(); List<String> depList = new ArrayList<String>();
...@@ -1066,10 +1072,14 @@ public class XMLConfig extends Config { ...@@ -1066,10 +1072,14 @@ public class XMLConfig extends Config {
// TODO: allow here other types of dependencies (conditionals(source files) // TODO: allow here other types of dependencies (conditionals(source files)
for(Iterator<Node> n = depNodes.iterator(); n.hasNext();) { for(Iterator<Node> n = depNodes.iterator(); n.hasNext();) {
Node node = (Node)n.next(); Node node = (Node)n.next();
String dep = getAttributeValue(node, CONTEXT_TOOL_DEPENDS_STATE_TAG); String dep = getAttributeValue(node, filesStateTag);
if(dep == null) if (dep != null) {
throw new ConfigException(toolInfo + ": Attribute '" + CONTEXT_TOOL_DEPENDS_STATE_TAG + "' is absent"); depList.add(dep);
depList.add(dep); } else if (getAttributeValue(node, otherTag)==null){
throw new ConfigException(toolInfo + ": Both alternative attributes '" + CONTEXT_TOOL_DEPENDS_FILES_TAG +
" and '"+CONTEXT_TOOL_DEPENDS_STATE_TAG +"' are absent");
}
} }
return depList; return depList;
} }
......
...@@ -262,6 +262,9 @@ public abstract class Context { ...@@ -262,6 +262,9 @@ public abstract class Context {
createdControlFiles.clear(); createdControlFiles.clear();
currentHash=0; currentHash=0;
// if (name.equals("VivadoSynthesis")){
// System.out.println("1. Check here: VivadoSynthesis");
// }
while(commandLinesBlockIter.hasNext()) { while(commandLinesBlockIter.hasNext()) {
CommandLinesBlock commandLinesBlock = (CommandLinesBlock)commandLinesBlockIter.next(); CommandLinesBlock commandLinesBlock = (CommandLinesBlock)commandLinesBlockIter.next();
...@@ -398,15 +401,23 @@ public abstract class Context { ...@@ -398,15 +401,23 @@ public abstract class Context {
String [] params=item.getParams(); String [] params=item.getParams();
if (params!=null) for (int i=0;i<params.length;i++){ if (params!=null) for (int i=0;i<params.length;i++){
currentHash += params[i].hashCode(); currentHash += params[i].hashCode();
// if (name.equals("VivadoSynthesis")){
// System.out.println(params[i]+": "+currentHash);
// }
} }
} }
} }
// System.out.println("BildParam("+dryRun+"), name="+name+" currentHash="+currentHash); // System.out.println("BildParam("+dryRun+"), name="+name+" currentHash="+currentHash);
// Seems that during build it worked on a working copy of the tool, so calculated parameter did not get back // Seems that during build it worked on a working copy of the tool, so calculated parameter did not get back
Tool proto=ToolsCore.getConfig().getContextManager().findTool(name); Tool proto=ToolsCore.getConfig().getContextManager().findTool(name);
// System.out.println("Calculated currentHash for "+name+"="+currentHash);
// if (name.equals("VivadoSynthesis")){
// System.out.println("Check here: VivadoSynthesis");
// }
if (proto!=null){ if (proto!=null){
if (proto!=this){ if (proto!=this){
System.out.println("++++ Updating tool's currentHas from working copy, name="+name); System.out.println("++++ Updating tool's currentHash from working copy, name="+name);
proto.setCurrentHash(currentHash); proto.setCurrentHash(currentHash);
} }
......
...@@ -49,6 +49,8 @@ public class Tool extends Context implements Cloneable, Inheritable { ...@@ -49,6 +49,8 @@ public class Tool extends Context implements Cloneable, Inheritable {
private static final String TAG_TOOL_STATE = ".toolstate.state"; private static final String TAG_TOOL_STATE = ".toolstate.state";
private static final String TAG_TOOL_TIMESTAMP = ".toolstate.timeStamp"; private static final String TAG_TOOL_TIMESTAMP = ".toolstate.timeStamp";
private static final String TAG_TOOL_LASTRUNHASH = ".toolstate.lastRunHash"; private static final String TAG_TOOL_LASTRUNHASH = ".toolstate.lastRunHash";
private static final String TAG_TOOL_FILEDEPSTAMP = ".toolstate.fileDependency.";
private static final String TAG_TOOL_STATEDEPSTAMP = ".toolstate.stateDependency.";
private String baseToolName; private String baseToolName;
...@@ -76,26 +78,31 @@ public class Tool extends Context implements Cloneable, Inheritable { ...@@ -76,26 +78,31 @@ public class Tool extends Context implements Cloneable, Inheritable {
private boolean initialized = false; private boolean initialized = false;
private String [] imageKeysActions = null; private String [] imageKeysActions = null;
private List<String> depends=null; // list of tools this one depends on -> list of files (states) and strings (name of sessions) private List<String> dependStateNames=null; // list of tools this one depends on -> list of files (source files) and strings (name state files)
private String logDirString=null; // directory to store this tool log files private List<String> dependFileNames=null; // list of tools this one depends on -> list of files (source files) and strings (name state files)
private String stateDirString=null; // directory to store this tool log files
private Parameter logDir=null; // directory to store this tool log files private String logDirString=null; // directory to store this tool log files
private Parameter stateDir=null; // directory to store this tool log files private String stateDirString=null; // directory to store this tool log files
private String disabledString=null; // to disable tools from automatic running private Parameter logDir=null; // directory to store this tool log files
private String resultString=null; // parameter name of kind of file that represents state after running this tool private Parameter stateDir=null; // directory to store this tool log files
private String restoreString=null; // name of tool that restores the state of this tool ran (has own dependencies) private String disabledString=null; // to disable tools from automatic running
private String saveString=null; // name of tool that saves the state of this tool run private String resultString=null; // parameter name of kind of file that represents state after running this tool
private String autoSaveString=null; // name of boolean that turns on/off auto-save after the tool run private String restoreString=null; // name of tool that restores the state of this tool ran (has own dependencies)
private boolean abstractTool; // abstract tools can only be used for inheritance, not directly (so they will not be private String saveString=null; // name of tool that saves the state of this tool run
// considered when looking for solution to run private String autoSaveString=null; // name of boolean that turns on/off auto-save after the tool run
private boolean abstractTool; // abstract tools can only be used for inheritance, not directly (so they will not be
// considered when looking for solution to run
private Parameter disabled; private Parameter disabled;
private Tool restoreTool; private Tool restoreTool;
private Parameter result; private Parameter result;
// TODO: Compare dependFiles with literary result of other tools, if match - these are states, not files // TODO: Compare dependFiles with literary result of other tools, if match - these are states, not files
private List<Parameter> dependSessions; private List<Parameter> dependStates; // snapshot names
private List<Parameter> dependFiles; private List<Parameter> dependFiles;
private Map <String,String> dependStatesTimestamps;
private Map <String,String> dependFilesTimestamps;
// private boolean toolIsRestore; // this tool is referenced by other as restore="this-tool" // private boolean toolIsRestore; // this tool is referenced by other as restore="this-tool"
private boolean dirty=false; // tool ran before its sources (runtime value) private boolean dirty=false; // tool ran before its sources (runtime value)
private boolean pinned=false; // tool ran before its sources (runtime value) private boolean pinned=false; // tool ran before its sources (runtime value)
...@@ -105,6 +112,7 @@ public class Tool extends Context implements Cloneable, Inheritable { ...@@ -105,6 +112,7 @@ public class Tool extends Context implements Cloneable, Inheritable {
// private boolean running=false; // private boolean running=false;
// private long finishTimeStamp=0; // private long finishTimeStamp=0;
private String timeStamp=null; private String timeStamp=null;
private String restoreTimeStamp=null;
private DesignFlowView designFlowView; private DesignFlowView designFlowView;
private String resultFile; // used to overwrite name of the default result file that normally private String resultFile; // used to overwrite name of the default result file that normally
...@@ -122,7 +130,7 @@ public class Tool extends Context implements Cloneable, Inheritable { ...@@ -122,7 +130,7 @@ public class Tool extends Context implements Cloneable, Inheritable {
private TOOL_MODE runMode; private TOOL_MODE runMode;
private TOOL_MODE lastRunMode; // last running (not STOP) mode private TOOL_MODE lastRunMode; // last running (not STOP) mode
private int lastRunHash; // hash code of the last run private int lastRunHash; // hash code of the last run
private ToolWaitingArguments toolWaitingArguments; // save here launch parameters wjhen tool need to wait for other tools to run/get restored private ToolWaitingArguments toolWaitingArguments; // save here launch parameters when tool need to wait for other tools to run/get restored
public Tool(String name, public Tool(String name,
String controlInterfaceName, String controlInterfaceName,
...@@ -140,7 +148,8 @@ public class Tool extends Context implements Cloneable, Inheritable { ...@@ -140,7 +148,8 @@ public class Tool extends Context implements Cloneable, Inheritable {
String toolInfo, String toolInfo,
List<RunFor> runfor, List<RunFor> runfor,
String ignoreFilter, String ignoreFilter,
List<String> depends, List<String> toolDependsStates,
List<String> toolDependsFiles,
String logDirString, String logDirString,
String stateDirString, String stateDirString,
String disabledString, // to disable tools from automatic running String disabledString, // to disable tools from automatic running
...@@ -174,7 +183,11 @@ public class Tool extends Context implements Cloneable, Inheritable { ...@@ -174,7 +183,11 @@ public class Tool extends Context implements Cloneable, Inheritable {
this.toolErrors = toolErrors; this.toolErrors = toolErrors;
this.toolWarnings = toolWarnings; this.toolWarnings = toolWarnings;
this.toolInfo = toolInfo; this.toolInfo = toolInfo;
this.depends= depends;
this.dependStateNames=toolDependsStates; // list of tools this one depends on -> list of files (source files) and strings (name state files)
this.dependFileNames= toolDependsFiles; // list of tools this one depends on -> list of files (source files) and strings (name state files)
// this.depends= depends;
this.logDirString= logDirString; this.logDirString= logDirString;
this.stateDirString= stateDirString; this.stateDirString= stateDirString;
...@@ -188,7 +201,7 @@ public class Tool extends Context implements Cloneable, Inheritable { ...@@ -188,7 +201,7 @@ public class Tool extends Context implements Cloneable, Inheritable {
disabled=null; disabled=null;
restoreTool=null; restoreTool=null;
result=null; result=null;
dependSessions=null; dependStates=null;
dependFiles=null; dependFiles=null;
pinned=false; pinned=false;
...@@ -197,6 +210,7 @@ public class Tool extends Context implements Cloneable, Inheritable { ...@@ -197,6 +210,7 @@ public class Tool extends Context implements Cloneable, Inheritable {
choice=0; choice=0;
designFlowView =null; designFlowView =null;
timeStamp=null; timeStamp=null;
restoreTimeStamp=null;
logDir=null; logDir=null;
stateDir=null; stateDir=null;
resultFile=null; resultFile=null;
...@@ -206,6 +220,9 @@ public class Tool extends Context implements Cloneable, Inheritable { ...@@ -206,6 +220,9 @@ public class Tool extends Context implements Cloneable, Inheritable {
autoSave=null; autoSave=null;
runMode=TOOL_MODE.STOP; runMode=TOOL_MODE.STOP;
lastRunMode=TOOL_MODE.STOP; lastRunMode=TOOL_MODE.STOP;
dependStatesTimestamps=new Hashtable<String,String>();
dependFilesTimestamps= new Hashtable<String,String>();
} }
public enum TOOL_STATE { public enum TOOL_STATE {
NEW, NEW,
...@@ -245,10 +262,42 @@ public class Tool extends Context implements Cloneable, Inheritable { ...@@ -245,10 +262,42 @@ public class Tool extends Context implements Cloneable, Inheritable {
public String getIgnoreFilter(){ return ignoreFilter;} public String getIgnoreFilter(){ return ignoreFilter;}
} }
public void clearDependStamps(){
dependStatesTimestamps.clear();
dependFilesTimestamps.clear();
}
public void setStateTimeStamp(String state, String stamp){
dependStatesTimestamps.put(state,stamp);
}
public void setFileTimeStamp(String file, String stamp){
dependFilesTimestamps.put(file,stamp);
}
public String getStateTimeStamp(String state){
return dependStatesTimestamps.get(state);
}
public String getFileTimeStamp(String state){
return dependFilesTimestamps.get(state);
}
public List<String> getDepends() { return depends; } public Map <String,String> getDependStatesTimestamps(){
public boolean isDirty() { return dirty; } return dependStatesTimestamps;
}
public Map <String,String> getDependFilesTimestamps(){
return dependFilesTimestamps;
}
public List<String> getDependStateNames() { return dependStateNames; }
public List<String> getDependFileNames() { return dependFileNames; }
public boolean isDirty() { return dirty || !hashMatch(); }
public boolean isDirtyOrChanged() {
return isDirty() || !hashMatch();
}
public boolean isRunning() { return (runMode!=TOOL_MODE.STOP) && ((runMode!=TOOL_MODE.WAIT)); } public boolean isRunning() { return (runMode!=TOOL_MODE.STOP) && ((runMode!=TOOL_MODE.WAIT)); }
public boolean isWaiting() { return runMode==TOOL_MODE.WAIT; } public boolean isWaiting() { return runMode==TOOL_MODE.WAIT; }
...@@ -301,10 +350,16 @@ public class Tool extends Context implements Cloneable, Inheritable { ...@@ -301,10 +350,16 @@ public class Tool extends Context implements Cloneable, Inheritable {
if (mode!=TOOL_MODE.STOP) lastRunMode=mode; if (mode!=TOOL_MODE.STOP) lastRunMode=mode;
if (mode == TOOL_MODE.RUN) { // Only RUN if (mode == TOOL_MODE.RUN) { // Only RUN
setTimeStamp(); // copy current time to tool timestamp setTimeStamp(); // copy current time to tool timestamp
restoreTimeStamp=null;
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) { if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) {
System.out.println(":::: Tool "+name+": setTimeStamp="+timeStamp); System.out.println(":::: Tool "+name+": setTimeStamp="+timeStamp);
} }
} else if (mode == TOOL_MODE.RESTORE){
if (restoreMaster!=null){
restoreMaster.setRestoreTimeStamp(); // copy current time to tool restore timestamp will be used when calculating dependencies
} else {
System.out.println("Restore mode, but no restoreMaster for "+name);
}
} }
// toolFinished(); // toolFinished();
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) { if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) {
...@@ -426,7 +481,10 @@ public class Tool extends Context implements Cloneable, Inheritable { ...@@ -426,7 +481,10 @@ public class Tool extends Context implements Cloneable, Inheritable {
if (toolInfo== null) toolInfo = baseTool.toolInfo; if (toolInfo== null) toolInfo = baseTool.toolInfo;
if (runfor== null) runfor = baseTool.runfor; if (runfor== null) runfor = baseTool.runfor;
if (ignoreFilter== null) ignoreFilter = baseTool.ignoreFilter; if (ignoreFilter== null) ignoreFilter = baseTool.ignoreFilter;
if (depends== null) depends = baseTool.depends;
if (dependStateNames== null) dependStateNames = baseTool.dependStateNames;
if (dependStateNames== null) dependStateNames = baseTool.dependStateNames;
if (logDirString== null) logDirString = baseTool.logDirString; if (logDirString== null) logDirString = baseTool.logDirString;
if (stateDirString== null) stateDirString = baseTool.stateDirString; if (stateDirString== null) stateDirString = baseTool.stateDirString;
if (disabledString== null) disabledString = baseTool.disabledString; if (disabledString== null) disabledString = baseTool.disabledString;
...@@ -460,35 +518,62 @@ public class Tool extends Context implements Cloneable, Inheritable { ...@@ -460,35 +518,62 @@ public class Tool extends Context implements Cloneable, Inheritable {
} }
public void initDepends() throws ConfigException{ public void initDepends() throws ConfigException{
if (depends==null) return; // Verify definitions for state dependency
dependSessions=new ArrayList<Parameter>(); if (dependStateNames!=null) {
dependFiles= new ArrayList<Parameter>(); dependStates=new ArrayList<Parameter>();
for(Iterator<String> iter = depends.iterator(); iter.hasNext();) { for(Iterator<String> iter = dependStateNames.iterator(); iter.hasNext();) {
String paramID=iter.next(); String paramID=iter.next();
Parameter param=findParam(paramID); Parameter param=findParam(paramID);
if(param == null) { if(param == null) {
throw new ConfigException("Parameter depends='" + paramID + throw new ConfigException("Parameter dependStateNames='" + paramID +
"' used for tool '" + name + "' used for tool '" + name +
"' is absent"); "' is absent");
} else if(!(param.getType() instanceof ParamTypeString)) { } else if(!(param.getType() instanceof ParamTypeString)) {
throw new ConfigException("Parameter depends='" + paramID + throw new ConfigException("Parameter dependStateNames='" + paramID +
"' defined in "+param.getSourceXML()+" used for tool '" + name + "' defined in "+param.getSourceXML()+" used for tool '" + name +
"' must be of type '" + ParamTypeString.NAME + "' must be of type '" + ParamTypeString.NAME +
"'"); "'");
} else {
KIND kind=((ParamTypeString)param.getType()).getKind();
if (kind == ParamTypeString.KIND.FILE) {
dependFiles.add(param);
} else if (kind == ParamTypeString.KIND.TEXT) {
dependSessions.add(param);
} else { } else {
throw new ConfigException("Parameter depends='" + paramID + KIND kind=((ParamTypeString)param.getType()).getKind();
"' of type '" + ParamTypeString.NAME + if (kind == ParamTypeString.KIND.TEXT) {
dependStates.add(param);
} else {
throw new ConfigException("Parameter dependStateNames='" + paramID +
"' of type '" + ParamTypeString.NAME +
"' defined in "+param.getSourceXML()+" used for tool '" + name +
"' must be of kind '" + ParamTypeString.KIND_TEXT_ID + "', it is '"+kind+"'");
}
}
}
}
// Verify definitions for source file dependency
if (dependFileNames!=null) {
dependFiles= new ArrayList<Parameter>();
for(Iterator<String> iter = dependFileNames.iterator(); iter.hasNext();) {
String paramID=iter.next();
Parameter param=findParam(paramID);
if(param == null) {
throw new ConfigException("Parameter dependFileNames='" + paramID +
"' used for tool '" + name +
"' is absent");
} else if(!(param.getType() instanceof ParamTypeString)) {
throw new ConfigException("Parameter dependFileNames='" + paramID +
"' defined in "+param.getSourceXML()+" used for tool '" + name + "' defined in "+param.getSourceXML()+" used for tool '" + name +
"' must be of kind '" + ParamTypeString.KIND_FILE_ID + "' (for snapshot fiels) "+ "' must be of type '" + ParamTypeString.NAME +
" or '" + ParamTypeString.KIND_TEXT_ID + "' (for tool name of the open session)"+ "'");
", it is '"+kind+"'"); } else {
KIND kind=((ParamTypeString)param.getType()).getKind();
if (kind == ParamTypeString.KIND.FILE) {
dependFiles.add(param);
} else {
throw new ConfigException("Parameter depends='" + paramID +
"' of type '" + ParamTypeString.NAME +
"' defined in "+param.getSourceXML()+" used for tool '" + name +
"' must be of kind '" + ParamTypeString.KIND_FILE_ID + "', it is '"+kind+"'");
}
} }
} }
} }
...@@ -498,17 +583,29 @@ public class Tool extends Context implements Cloneable, Inheritable { ...@@ -498,17 +583,29 @@ public class Tool extends Context implements Cloneable, Inheritable {
List<String> list = new ArrayList<String>(); List<String> list = new ArrayList<String>();
for (Iterator<Parameter> iter= dependFiles.iterator(); iter.hasNext();) { for (Iterator<Parameter> iter= dependFiles.iterator(); iter.hasNext();) {
List<String> vList=iter.next().getValue(); List<String> vList=iter.next().getValue();
if (vList!=null) list.addAll(vList); if (vList!=null) {
for (String item:vList){
if ((item!=null) && (item.trim().length()>0)){
list.add(item.trim());
}
}
// list.addAll(vList);
}
} }
return list; return list;
} }
public List<String> getDependSessions(){ public List<String> getDependStates(){
if ((dependSessions == null) || (dependSessions.size()==0)) return null; if ((dependStates == null) || (dependStates.size()==0)) return null;
List<String> list = new ArrayList<String>(); List<String> list = new ArrayList<String>();
for (Iterator<Parameter> iter= dependSessions.iterator(); iter.hasNext();) { for (Iterator<Parameter> iter= dependStates.iterator(); iter.hasNext();) {
List<String> vList=iter.next().getValue(); List<String> vList=iter.next().getValue();
if (vList!=null) list.addAll(vList); for (String item:vList){
if ((item!=null) && (item.trim().length()>0)){
list.add(item.trim());
}
}
// if (vList!=null) list.addAll(vList);
} }
return list; return list;
} }
...@@ -528,11 +625,13 @@ public class Tool extends Context implements Cloneable, Inheritable { ...@@ -528,11 +625,13 @@ public class Tool extends Context implements Cloneable, Inheritable {
"'"); "'");
} else { } else {
KIND kind=((ParamTypeString)result.getType()).getKind(); KIND kind=((ParamTypeString)result.getType()).getKind();
if(kind != ParamTypeString.KIND.FILE) { // if(kind != ParamTypeString.KIND.FILE) {
if(kind != ParamTypeString.KIND.TEXT) {
throw new ConfigException("Parameter result='" + resultString + throw new ConfigException("Parameter result='" + resultString +
"' of type '" + ParamTypeString.NAME + "' of type '" + ParamTypeString.NAME +
"' defined in "+result.getSourceXML()+" used for tool '" + name + "' defined in "+result.getSourceXML()+" used for tool '" + name +
"' must be of kind '" + ParamTypeString.KIND_FILE_ID + "'"+ // "' must be of kind '" + ParamTypeString.KIND_FILE_ID + "'"+
"' must be of kind '" + ParamTypeString.KIND_TEXT_ID + "'"+
" (it is '"+kind+"')"); " (it is '"+kind+"')");
} }
} }
...@@ -719,9 +818,13 @@ public class Tool extends Context implements Cloneable, Inheritable { ...@@ -719,9 +818,13 @@ public class Tool extends Context implements Cloneable, Inheritable {
return null; return null;
} }
public void setTimeStamp(){ public void setTimeStamp(){
timeStamp=SelectedResourceManager.getDefault().getBuildStamp(); timeStamp=SelectedResourceManager.getDefault().getBuildStamp();
} }
public void setRestoreTimeStamp(){
restoreTimeStamp=SelectedResourceManager.getDefault().getBuildStamp();
}
public void setTimeStamp(String timeStamp){ public void setTimeStamp(String timeStamp){
this.timeStamp=timeStamp; this.timeStamp=timeStamp;
} }
...@@ -734,7 +837,21 @@ public class Tool extends Context implements Cloneable, Inheritable { ...@@ -734,7 +837,21 @@ public class Tool extends Context implements Cloneable, Inheritable {
if (saveMaster != null) return saveMaster.getTimeStamp(false); if (saveMaster != null) return saveMaster.getTimeStamp(false);
return null; return null;
} }
/**
* Use to compare dependencies, when the snapshot is restored, it will have have restore time (latest),
* and the timeStamp (and getStateFile) will still use original one (for hash calculation)
* @return restore time stamp (if available), otherwise just a timestamp. Will look at restoreMaster.
*/
public String getRestoreTimeStamp() {return getRestoreTimeStamp(true); } // With timestamp or as specified in resultFile
public String getRestoreTimeStamp(boolean first){
if (first && (restoreMaster != null)) return restoreMaster.getRestoreTimeStamp(false);
if (restoreTimeStamp!=null) return restoreTimeStamp;
if (timeStamp!=null) return timeStamp;
return null;
}
public String getStateLink() {return getStateLink(true); } // No timestamp, link name (or null) public String getStateLink() {return getStateLink(true); } // No timestamp, link name (or null)
public String getStateLink(boolean first) { public String getStateLink(boolean first) {
...@@ -766,7 +883,14 @@ public class Tool extends Context implements Cloneable, Inheritable { ...@@ -766,7 +883,14 @@ public class Tool extends Context implements Cloneable, Inheritable {
memento.putString(name+TAG_TOOL_STATE, this.state.toString()); memento.putString(name+TAG_TOOL_STATE, this.state.toString());
if (timeStamp!=null) memento.putString(name+TAG_TOOL_TIMESTAMP, timeStamp); if (timeStamp!=null) memento.putString(name+TAG_TOOL_TIMESTAMP, timeStamp);
if (lastRunHash!=0) memento.putInteger(name+TAG_TOOL_LASTRUNHASH, lastRunHash); if (lastRunHash!=0) memento.putInteger(name+TAG_TOOL_LASTRUNHASH, lastRunHash);
for(String state:dependStatesTimestamps.keySet()){
String stamp=dependStatesTimestamps.get(state);
memento.putString(name+TAG_TOOL_STATEDEPSTAMP+state, stamp);
}
for(String file:dependFilesTimestamps.keySet()){
String stamp=dependFilesTimestamps.get(file);
memento.putString(name+TAG_TOOL_FILEDEPSTAMP+file, stamp);
}
} }
public void restoreState(IMemento memento) { public void restoreState(IMemento memento) {
...@@ -786,6 +910,22 @@ public class Tool extends Context implements Cloneable, Inheritable { ...@@ -786,6 +910,22 @@ public class Tool extends Context implements Cloneable, Inheritable {
if (timestamp!=null) this.timeStamp=timestamp; if (timestamp!=null) this.timeStamp=timestamp;
Integer hc=memento.getInteger(name+TAG_TOOL_LASTRUNHASH); Integer hc=memento.getInteger(name+TAG_TOOL_LASTRUNHASH);
if (hc!=null) lastRunHash=hc; if (hc!=null) lastRunHash=hc;
clearDependStamps();
String[] mementoKeys=memento.getAttributeKeys();
String prefix=name+TAG_TOOL_STATEDEPSTAMP;
for (String key:mementoKeys){
if (key.startsWith(prefix)) {
String value=memento.getString(key);
setStateTimeStamp(key.substring(prefix.length()), value);
}
}
prefix=name+TAG_TOOL_FILEDEPSTAMP;
for (String key:mementoKeys){
if (key.startsWith(prefix)) {
String value=memento.getString(key);
setFileTimeStamp(key.substring(prefix.length()), value);
}
}
} }
...@@ -971,7 +1111,8 @@ public class Tool extends Context implements Cloneable, Inheritable { ...@@ -971,7 +1111,8 @@ public class Tool extends Context implements Cloneable, Inheritable {
return results.get(0); return results.get(0);
} }
private void updateContextOptions (IProject project){ // private void updateContextOptions (IProject project){
public void updateContextOptions (IProject project){ // public to be able to update parameters before setting "dirty" flags
PackageContext packageContext = getParentPackage(); PackageContext packageContext = getParentPackage();
if (packageContext != null) { if (packageContext != null) {
OptionsCore.doLoadContextOptions(packageContext); OptionsCore.doLoadContextOptions(packageContext);
...@@ -1077,6 +1218,14 @@ public class Tool extends Context implements Cloneable, Inheritable { ...@@ -1077,6 +1218,14 @@ public class Tool extends Context implements Cloneable, Inheritable {
// public String[] buildParams() throws ToolException { // public String[] buildParams() throws ToolException {
public BuildParamsItem[] buildParams() throws ToolException { public BuildParamsItem[] buildParams() throws ToolException {
return buildParams(false);
}
public BuildParamsItem[] buildParams(boolean dryRun) throws ToolException {
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) {
System.out.println("tool "+getName()+" state="+getState()+" dirty="+isDirty()+" pinned="+isPinned()+" dryRun="+dryRun);
}
if(parentPackage != null) if(parentPackage != null)
parentPackage.buildParams(); parentPackage.buildParams();
...@@ -1088,7 +1237,7 @@ public class Tool extends Context implements Cloneable, Inheritable { ...@@ -1088,7 +1237,7 @@ public class Tool extends Context implements Cloneable, Inheritable {
if(installation != null) if(installation != null)
installation.buildParams(); installation.buildParams();
return super.buildParams(); return super.buildParams(dryRun);
} }
......
...@@ -22,13 +22,15 @@ import org.eclipse.core.resources.IFolder; ...@@ -22,13 +22,15 @@ import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.QualifiedName; import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.jface.viewers.AbstractTreeViewer;
import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IMemento;
import com.elphel.vdt.Txt; import com.elphel.vdt.Txt;
import com.elphel.vdt.VDT; import com.elphel.vdt.VDT;
import com.elphel.vdt.VerilogUtils;
import com.elphel.vdt.core.launching.LaunchCore; import com.elphel.vdt.core.launching.LaunchCore;
import com.elphel.vdt.core.launching.ToolLogFile; import com.elphel.vdt.core.launching.ToolLogFile;
import com.elphel.vdt.core.tools.ToolsCore; import com.elphel.vdt.core.tools.ToolsCore;
...@@ -43,21 +45,64 @@ import com.elphel.vdt.veditor.preference.PreferenceStrings; ...@@ -43,21 +45,64 @@ import com.elphel.vdt.veditor.preference.PreferenceStrings;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Hashtable;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
public class ToolSequence { public class ToolSequence {
public static final QualifiedName OPTION_TOOL_HASHCODE = new QualifiedName(VDT.ID_VDT, "OPTION_TOOL_HASHCODE"); public static final QualifiedName OPTION_TOOL_HASHCODE = new QualifiedName(VDT.ID_VDT, "OPTION_TOOL_HASHCODE");
public static final QualifiedName OPTION_TOOL_TIMESTAMP = new QualifiedName(VDT.ID_VDT, "OPTION_TOOL_TIMESTAMP"); public static final QualifiedName OPTION_TOOL_TIMESTAMP = new QualifiedName(VDT.ID_VDT, "OPTION_TOOL_TIMESTAMP");
// same state may be after different tools
public static final QualifiedName OPTION_TOOL_NAME = new QualifiedName(VDT.ID_VDT, "OPTION_TOOL_NAME");
public static final String TOOL_FILEDEPSTAMP = "OPTION_TOOL_FILEDEPSTAMP_";
public static final String TOOL_STATEDEPSTAMP = "OPTION_TOOL_STATEDEPSTAMP_";
private static final String TAG_CURRENTSTATE_TOOLNAME = ".currentState.toolName.";
private static final String TAG_CURRENTSTATE_STATEFILE = ".currentState.stateFile.";
private static final String TAG_CURRENTSTATE_TOOLSTAMP = ".currentState.toolStamp.";
private boolean shiftPressed=false; private boolean shiftPressed=false;
private DesignFlowView designFlowView; private DesignFlowView designFlowView;
private boolean stopOn; // Stop button is pressed private boolean stopOn; // Stop button is pressed
private boolean saveOn; // save button is on private boolean saveOn; // save button is on
private Map<String,Tool> stateProvides;
private Map<String,ToolStateStamp> currentStates;
private IMemento unfinishedMemento=null;
private String menuName=null;
// private IProgressMonitor monitor;
public ToolSequence(DesignFlowView designFlowView){ public ToolSequence(DesignFlowView designFlowView){
this.designFlowView=designFlowView; this.designFlowView=designFlowView;
this.currentStates=new Hashtable<String,ToolStateStamp>();
}
public void setUnfinishedBoot(IMemento memento){
unfinishedMemento=memento;
if (memento!=null){
// Does not seem to work:
IActionBars bars = designFlowView.getViewSite().getActionBars();
bars.getStatusLineManager().setMessage("Waiting for VEditor database to be built...");
menuName=designFlowView.getPartName();
System.out.println("Menu name:"+menuName);
designFlowView.changeMenuTitle("Waiting for VEditor database...");
}
} }
public void finalizeBootAfterVEditor(){
if (unfinishedMemento!=null) {
// Does not seem to work:
IActionBars bars = designFlowView.getViewSite().getActionBars();
bars.getStatusLineManager().setMessage("");
// designFlowView.changeMenuTitle(menuName);
designFlowView.finalizeAfterVEditorDB(unfinishedMemento);
}
}
public void toolFinished(Tool tool){ public void toolFinished(Tool tool){
doToolFinished(tool); doToolFinished(tool);
if (designFlowView!=null){ if (designFlowView!=null){
...@@ -84,8 +129,21 @@ public class ToolSequence { ...@@ -84,8 +129,21 @@ public class ToolSequence {
System.out.println("updateSessionTools("+tool.getName()+"tool)-> "+sessionUpdated); System.out.println("updateSessionTools("+tool.getName()+"tool)-> "+sessionUpdated);
} }
if (tool.getLastMode()==TOOL_MODE.RESTORE){ if (tool.getLastMode()==TOOL_MODE.RESTORE){
restoreToolProperties(tool);// set last run hashcode and timestamp for the tool just restored restoreToolProperties(tool);// set last run hashcode and timestamp for the tool just restored
if (tool.getRestoreMaster()!=null) tool.setPinned(true);
else {
System.out.println("Pribably a bug - tool.getRestoreMaster()==null for "+tool.getName()+", while state is "+tool.getState());
tool.setPinned(true); // restored state should be pinned?
}
}
// add/update current state produced by the finished tool
putCurrentState(tool);
// Set tool timestamps for states and source files
if (tool.getLastMode()==TOOL_MODE.RUN) {
setDependState(tool);
} }
setToolsDirtyFlag(false); // no need to recalculate all parameters here
// Check for stop here // Check for stop here
if ((tool.getLastMode()==TOOL_MODE.RUN) || (tool.getLastMode()==TOOL_MODE.SAVE)){ if ((tool.getLastMode()==TOOL_MODE.RUN) || (tool.getLastMode()==TOOL_MODE.SAVE)){
updateLinkLatest(tool); // Do not update link if the session was just restored. Or should it be updated updateLinkLatest(tool); // Do not update link if the session was just restored. Or should it be updated
...@@ -120,6 +178,40 @@ public class ToolSequence { ...@@ -120,6 +178,40 @@ public class ToolSequence {
} }
/**
* Setup what tools can provide needed states
*/
public void setStateProvides(){
stateProvides=new ConcurrentHashMap<String,Tool>();
for (Tool tool : ToolsCore.getConfig().getContextManager().getToolList()){
System.out.println("Looking for all states defined, tool= "+tool.getName());
if (!tool.isDisabled()){
String state=tool.getStateLink(); // some tools (like reports) do not change states
if (state!=null) stateProvides.put(state,tool);
}
}
// Verify that each dependent state has a provider
for (Tool tool : ToolsCore.getConfig().getContextManager().getToolList()){
// System.out.println("Looking for all states defined, tool= "+tool.getName());
if (!tool.isDisabled()){
List<String> dependStates=tool.getDependStates();
if ((dependStates!=null) && (dependStates.size()>0)){
for (String state:dependStates){
if (!stateProvides.containsKey(state)){
MessageUI.error("No tool provide output state '"+state+"' needed to satisfy dependency of the tool "+tool.getName());
System.out.println("No tool provide output state '"+state+"' needed to satisfy dependency of the tool "+tool.getName());
}
}
}
}
}
// List<String> list = new ArrayList<String>(hashset);
System.out.println("Got "+stateProvides.keySet().size()+" different states, number of mappings="+stateProvides.keySet().size());
// For each state - find latest tool that made it
}
public void launchToolSequence( public void launchToolSequence(
Tool tool, Tool tool,
...@@ -128,6 +220,9 @@ public class ToolSequence { ...@@ -128,6 +220,9 @@ public class ToolSequence {
String fullPath, String fullPath,
String ignoreFilter) throws CoreException { String ignoreFilter) throws CoreException {
if (!okToRun()) return; if (!okToRun()) return;
setStateProvides(); // just testing
// tool.setDesignFlowView(designFlowView); // tool.setDesignFlowView(designFlowView);
tool.setDesignFlowView(designFlowView); // maybe will not be needed with ToolSequencing class tool.setDesignFlowView(designFlowView); // maybe will not be needed with ToolSequencing class
tool.setMode(mode) ; //TOOL_MODE.RUN); tool.setMode(mode) ; //TOOL_MODE.RUN);
...@@ -358,6 +453,41 @@ public class ToolSequence { ...@@ -358,6 +453,41 @@ public class ToolSequence {
tool.setLastRunHash(hashCode); tool.setLastRunHash(hashCode);
System.out.println("Restored lastRunHashCode="+hashCode+" for tool"+tool.getName()); System.out.println("Restored lastRunHashCode="+hashCode+" for tool"+tool.getName());
} }
// restore dependencies
// 1. See if it was saved by the same tool
String stateToolName=null;
try {
stateToolName=target.getPersistentProperty(OPTION_TOOL_NAME);
System.out.println("Got stateToolName="+stateToolName+" in "+target.getLocation().toOSString());
} catch (CoreException e) {
System.out.println("No stateToolName in "+target.getLocation().toOSString());
return false;
}
if ((stateToolName==null) || !tool.getName().equals(stateToolName)){
System.out.println("State file "+target.getLocation().toOSString()+" was saved for tool "+stateToolName+
", while restoring tool is "+tool.getName()+" - ivalidating all dependencies timestamps.");
tool.clearDependStamps();
return false;
}
// 2. Read timestmaps for state file(s) and source files
tool.clearDependStamps(); // clear old dependency timestamps
Map<QualifiedName, String> properties=null;
try {
properties = target.getPersistentProperties();
} catch (CoreException e) {
System.out.println("Failed to get persisten properties from "+target.getLocation().toOSString());
return false;
}
for (QualifiedName qName: properties.keySet()){
if (qName.getLocalName().startsWith(TOOL_FILEDEPSTAMP)){
String value=properties.get(qName);
tool.setFileTimeStamp(qName.getLocalName().substring(TOOL_FILEDEPSTAMP.length()), value);
} else if (qName.getLocalName().startsWith(TOOL_STATEDEPSTAMP)){
String value=properties.get(qName);
tool.setStateTimeStamp(qName.getLocalName().substring(TOOL_STATEDEPSTAMP.length()), value);
}
}
return (timestamp!=null) && (hashCode!=0); return (timestamp!=null) && (hashCode!=0);
} }
...@@ -496,6 +626,42 @@ public class ToolSequence { ...@@ -496,6 +626,42 @@ public class ToolSequence {
System.out.println("Failed to setPersistentProperty("+OPTION_TOOL_HASHCODE+","+sHash+ System.out.println("Failed to setPersistentProperty("+OPTION_TOOL_HASHCODE+","+sHash+
" on "+target.getLocation().toOSString()); " on "+target.getLocation().toOSString());
} }
// Save dependencies:
// Set toll name (same state may be result of running different tool (not yet used)
try {
target.setPersistentProperty(OPTION_TOOL_NAME, tool.getName());
System.out.println("setPersistentProperty("+OPTION_TOOL_NAME+","+tool.getName()+
" on "+target.getLocation().toOSString());
} catch (CoreException e) {
System.out.println("Failed to setPersistentProperty("+OPTION_TOOL_NAME+","+tool.getName()+
" on "+target.getLocation().toOSString());
}
// Save dependencies on states (snapshot file names)
for(String state:tool.getDependStatesTimestamps().keySet()){
String stamp=tool.getStateTimeStamp(state);
QualifiedName qn=new QualifiedName(VDT.ID_VDT,TOOL_STATEDEPSTAMP+state);
try {
target.setPersistentProperty(qn, stamp);
System.out.println("setPersistentProperty("+qn+","+tool.getName()+
" on "+target.getLocation().toOSString());
} catch (CoreException e) {
System.out.println("Failed to setPersistentProperty("+qn+","+tool.getName()+
" on "+target.getLocation().toOSString());
}
}
// Save dependencies on files (source file names)
for(String depfile:tool.getDependFilesTimestamps().keySet()){
String stamp=tool.getFileTimeStamp(depfile);
QualifiedName qn=new QualifiedName(VDT.ID_VDT,TOOL_FILEDEPSTAMP+depfile);
try {
target.setPersistentProperty(qn, stamp);
System.out.println("setPersistentProperty("+qn+","+stamp+
" on "+target.getLocation().toOSString());
} catch (CoreException e) {
System.out.println("Failed to setPersistentProperty("+qn+","+stamp+
" on "+target.getLocation().toOSString());
}
}
} }
/** /**
...@@ -609,6 +775,216 @@ public class ToolSequence { ...@@ -609,6 +775,216 @@ public class ToolSequence {
return result; return result;
} }
public class ToolStateStamp{
private String toolName;
private String toolStateFile; //
private String toolStamp; // after restore differs from stamp in stateFile
public ToolStateStamp(
String toolName,
String stateFile,
String toolStamp
){
this.toolName=toolName;
this.toolStateFile=stateFile;
this.toolStamp=toolStamp;
}
public ToolStateStamp(Tool tool){
this.toolName= tool.getName();
this.toolStateFile= tool.getStateFile();
this.toolStamp= tool.getRestoreTimeStamp();
}
public String getToolName(){
return toolName;
}
public String getToolStamp(){
return toolStamp;
}
public String getToolStateFile(){
return toolStateFile;
}
public boolean after(ToolStateStamp after, ToolStateStamp before){
return SelectedResourceManager.afterStamp(after.getToolStamp(), before.getToolStamp());
}
}
public void saveCurrentStates(IMemento memento) {
for (String state:currentStates.keySet()){
ToolStateStamp tss=currentStates.get(state);
memento.putString(state+TAG_CURRENTSTATE_TOOLNAME, tss.getToolName());
memento.putString(state+TAG_CURRENTSTATE_STATEFILE, tss.getToolStateFile());
memento.putString(state+TAG_CURRENTSTATE_TOOLSTAMP, tss.getToolStamp());
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) {
System.out.println("Saving state "+state+
", toolName="+tss.getToolName()+
", toolStateFile="+tss.getToolStateFile()+
", toolStamp="+tss.getToolStamp());
}
}
}
/**
* Restore states (snaphot files status) from persistent storage
* Should be called after tools are restored
* @param memento
*/
public void restoreCurrentStates(IMemento memento) {
currentStates.clear();
String[] mementoKeys=memento.getAttributeKeys();
Map<String,String> mementoKeysMap=new Hashtable<String,String>();
for (String key:mementoKeys){
if (
key.contains(TAG_CURRENTSTATE_TOOLNAME)||
key.contains(TAG_CURRENTSTATE_STATEFILE)||
key.contains(TAG_CURRENTSTATE_TOOLSTAMP)
) mementoKeysMap.put(key,memento.getString(key));
}
setStateProvides(); // Can be called just once - during initialization?
for (String state:stateProvides.keySet()){
if ( mementoKeysMap.containsKey(state+TAG_CURRENTSTATE_TOOLNAME)) {
currentStates.put(state,new ToolStateStamp(
memento.getString(state+TAG_CURRENTSTATE_TOOLNAME),
memento.getString(state+TAG_CURRENTSTATE_STATEFILE),
memento.getString(state+TAG_CURRENTSTATE_TOOLSTAMP)
));
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) {
System.out.println("Restoring state "+state+
", toolName="+memento.getString(state+TAG_CURRENTSTATE_TOOLNAME)+
", toolStateFile="+memento.getString(state+TAG_CURRENTSTATE_STATEFILE)+
", toolStamp="+memento.getString(state+TAG_CURRENTSTATE_TOOLSTAMP));
}
}
}
// Set all tool dirty flags according to restored states and tools dendencies
// updateContextOptions(project); // Fill in parameters - it parses here too - at least some parameters? (not in menu mode)
// setToolsDirtyFlag(true) initiates Verilog database rebuild, let's trigger it intentionally
//VerilogUtils.getTopModuleNames((IFile)resource);
setToolsDirtyFlag(true); // recalculate each successful tool's parameters
}
public void putCurrentState(Tool tool){
String linkString=tool.getStateLink(); // name of the state file w/o timestamp
if (linkString!=null) currentStates.put(linkString, new ToolStateStamp(tool));
}
/**
* Scan all succeeded tools and set "dirty" flag if their dependencies do not match stored ones
*
*/
public void setToolsDirtyFlag(boolean update){
IProject project = SelectedResourceManager.getDefault().getSelectedProject(); // should not be null when we got here
for (Tool tool : ToolsCore.getConfig().getContextManager().getToolList()){
if (tool.getState()==TOOL_STATE.SUCCESS){
if (update){
// tool.updateContextOptions(project) recalculates parameters, but not the hashcodes
tool.updateContextOptions(project); // Fill in parameters - it parses here too - at least some parameters? (not in menu mode)
try {
tool.buildParams(true); // dryRun
} catch (ToolException e) {
System.out.println("setToolsDirtyFlag(): failed to buildParams() for tool "+tool.getName());
}
}
tool.setDirty(!matchDependState(tool));
}
}
}
/**
* Set state files (full names with timestamps) and source files timestamps for the tool
* so they can be compared later to determine if the tool state is current or "dirty" (will
* use parameters-defined hashcodes too
* @param tool Reference to a tool to process
*/
public void setDependState(Tool tool){
tool.clearDependStamps(); // is it needed?
Map <String,String> depStates=makeDependStates(tool);
for (String state:depStates.keySet()){
tool.setStateTimeStamp(state,depStates.get(state)); // name of the state file including timestamp
}
Map <String,String> depFiles=makeDependFiles(tool);
for (String file:depFiles.keySet()){
tool.setFileTimeStamp(file,depFiles.get(file));
}
}
/**
* Compare current timestamps of the source files and state(s) filenames (that include timestamps)
* against ones stored for the tool (when it ran or was restored)
* @param tool tool to process
* @return true if all timestamps matched, false otherwise
*/
public boolean matchDependState(Tool tool){
Map <String,String> depStates=makeDependStates(tool);
Map <String,String> depFiles=makeDependFiles(tool);
Map <String,String> storedDepStates = tool.getDependStatesTimestamps();
Map <String,String> storedDepFiles = tool.getDependFilesTimestamps();
if (depStates.size()!=storedDepStates.size()) {
System.out.println("matchDependState("+tool.getName()+") :"+
" depStates.size()!=storedDepStates.size() - "+depStates.size()+"!="+storedDepStates.size());
return false;
}
if (depFiles.size()!=storedDepFiles.size()) {
System.out.println("matchDependState("+tool.getName()+") :"+
" depFiles.size()!=storedDepFiles.size() - "+depFiles.size()+"!="+storedDepFiles.size());
return false;
}
for (String state:depStates.keySet()){
if (!storedDepStates.containsKey(state) || !depStates.get(state).equals(storedDepStates.get(state))){
System.out.println("matchDependState("+tool.getName()+") :"+
state+ ": "+depStates.get(state)+" <-> "+storedDepStates.get(state));
return false;
}
}
for (String file:depFiles.keySet()){
if (!storedDepFiles.containsKey(file) || !depFiles.get(file).equals(storedDepFiles.get(file))){
System.out.println("matchDependState("+tool.getName()+") :"+
file+ ": "+depFiles.get(file)+" <-> "+storedDepFiles.get(file));
return false;
}
}
System.out.println("matchDependState("+tool.getName()+") : full match!");
return true;
}
private Map <String,String> makeDependStates(Tool tool){
Map <String,String> depStates=new Hashtable<String,String>();
List<String> dependStates=tool.getDependStates();
if (dependStates!=null) for (String state: dependStates){
if (currentStates.containsKey(state)){
ToolStateStamp tss=currentStates.get(state);
depStates.put(state,tss.getToolStateFile()); // name of the state file including timestamp
} else {
System.out.println("Seems a BUG: no information for state "+state+" on which tool "+tool.getName()+" depends");
}
}
return depStates;
}
private Map <String,String> makeDependFiles(Tool tool){
Map <String,String> depFiles=new Hashtable<String,String>();
List<String> dependFileNames=tool.getDependFiles();
if (dependFileNames!=null) {
IProject project = SelectedResourceManager.getDefault().getSelectedProject(); // should not be null when we got here
for (String depFile: dependFileNames){
if (depFile.length()==0){
System.out.println("makeDependFiles(): depFile is empty");
continue;
}
IFile sourceFile=project.getFile(depFile); //Path must include project and resource name: /npmtest
if (sourceFile.exists()) {
depFiles.put(depFile, String.format("%d",sourceFile.getModificationStamp()));
} else {
System.out.println("Seems a BUG: source file "+sourceFile.getLocation()+" on which tool "+
tool.getName()+" depends does not exist");
depFiles.put(depFile, ""); // empty stamp for non-existent files?
}
}
}
return depFiles;
}
} }
...@@ -38,9 +38,25 @@ public class ParamRepeaterRecognizer extends RepeaterRecognizer { ...@@ -38,9 +38,25 @@ public class ParamRepeaterRecognizer extends RepeaterRecognizer {
String repSuffix, String repSuffix,
String separator) String separator)
{ {
if(genName.equals(ParamFormatRecognizer.FORMAT_PARAM_VALUE_MARK)) // TODO make repetitor to accept several pattern generators with only one generating a list
return new ValueGenerator(param, repPrefix, repSuffix, separator); /*
/* Trying to put these here */ if(genName.equals(ParamFormatRecognizer.FORMAT_PARAM_NAME_MARK)) {
return new AbstractGenerator() {
public String getName() {
return "ParamName (parameter '" + param.getID() +
"' of context '" + param.getContext().getName() +
"')";
}
protected String[] getStringValues() {
return new String[]{param.getOutID()};
}
};
}
*/
if(genName.equals(ParamFormatRecognizer.FORMAT_PARAM_VALUE_MARK))
return new ValueGenerator(param, repPrefix, repSuffix, separator);
/* Trying to put these here */
if(genName.equals(FilteredSourceListGenerator.NAME)) if(genName.equals(FilteredSourceListGenerator.NAME))
return new FilteredSourceListGenerator(repPrefix, repSuffix, separator); return new FilteredSourceListGenerator(repPrefix, repSuffix, separator);
else if(genName.equals(SourceListGenerator.NAME)) else if(genName.equals(SourceListGenerator.NAME))
......
...@@ -39,7 +39,9 @@ public class SimpleGeneratorRecognizer implements Recognizer { ...@@ -39,7 +39,9 @@ public class SimpleGeneratorRecognizer implements Recognizer {
new UserNameGenerator(), new UserNameGenerator(),
new StateDirGenerator(), new StateDirGenerator(),
new StateFileGenerator(), new StateFileGenerator(),
new StateBaseGenerator() new StateBaseGenerator(),
new SourceListGenerator("","",""),
new FilteredSourceListGenerator("","","")
}; };
public SimpleGeneratorRecognizer(){ public SimpleGeneratorRecognizer(){
......
...@@ -17,12 +17,15 @@ ...@@ -17,12 +17,15 @@
*******************************************************************************/ *******************************************************************************/
package com.elphel.vdt.ui.variables; package com.elphel.vdt.ui.variables;
import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.Stack; import java.util.Stack;
import com.elphel.vdt.VDT;
import com.elphel.vdt.VerilogUtils; import com.elphel.vdt.VerilogUtils;
import com.elphel.vdt.core.tools.params.Tool; import com.elphel.vdt.core.tools.params.Tool;
import com.elphel.vdt.core.tools.params.ToolSequence;
import com.elphel.vdt.veditor.VerilogPlugin; import com.elphel.vdt.veditor.VerilogPlugin;
import com.elphel.vdt.veditor.preference.PreferenceStrings; import com.elphel.vdt.veditor.preference.PreferenceStrings;
...@@ -39,6 +42,7 @@ import org.eclipse.jface.viewers.ISelection; ...@@ -39,6 +42,7 @@ import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IMemento;
import org.eclipse.ui.IPageLayout; import org.eclipse.ui.IPageLayout;
import org.eclipse.ui.ISelectionListener; import org.eclipse.ui.ISelectionListener;
import org.eclipse.ui.ISelectionService; import org.eclipse.ui.ISelectionService;
...@@ -59,9 +63,9 @@ import org.eclipse.ui.PlatformUI; ...@@ -59,9 +63,9 @@ import org.eclipse.ui.PlatformUI;
*/ */
public class SelectedResourceManager implements IWindowListener, ISelectionListener { public class SelectedResourceManager implements IWindowListener, ISelectionListener {
// singleton // singleton
private static SelectedResourceManager fgDefault = new SelectedResourceManager(); private static SelectedResourceManager fgDefault = new SelectedResourceManager();
private IResource fSelectedResource = null; private IResource fSelectedResource = null;
private IResource fSelectedVerilogFile = null; private IResource fSelectedVerilogFile = null;
private ITextSelection fSelectedText = null; private ITextSelection fSelectedText = null;
...@@ -76,6 +80,7 @@ public class SelectedResourceManager implements IWindowListener, ISelectionListe ...@@ -76,6 +80,7 @@ public class SelectedResourceManager implements IWindowListener, ISelectionListe
private String timestamp; private String timestamp;
private String ignoreFilter=null; private String ignoreFilter=null;
private boolean toolsLinked=true; private boolean toolsLinked=true;
private ToolSequence toolSequence=null; // to be able to reach toolSequence instance from VEditor
// private Tool selectedTool=null; // last selected tool // private Tool selectedTool=null; // last selected tool
// //
...@@ -117,6 +122,14 @@ public class SelectedResourceManager implements IWindowListener, ISelectionListe ...@@ -117,6 +122,14 @@ public class SelectedResourceManager implements IWindowListener, ISelectionListe
return toolsLinked; return toolsLinked;
} }
public void setToolSequence (ToolSequence toolSequence){
this.toolSequence=toolSequence;
}
public ToolSequence getToolSequence(){
return toolSequence;
}
/** /**
* @see org.eclipse.ui.IWindowListener#windowActivated(org.eclipse.ui.IWorkbenchWindow) * @see org.eclipse.ui.IWindowListener#windowActivated(org.eclipse.ui.IWorkbenchWindow)
*/ */
...@@ -161,7 +174,7 @@ public class SelectedResourceManager implements IWindowListener, ISelectionListe ...@@ -161,7 +174,7 @@ public class SelectedResourceManager implements IWindowListener, ISelectionListe
/** /**
* Returns the currently selected resource in the active workbench window, * Returns the currently selected resource in the active workbench window,
* or <code>null</code> if none. If an editor is active, the resource adapater * or <code>null</code> if none. If an editor is active, the resource adapter
* associated with the editor is returned. * associated with the editor is returned.
* *
* @return selected resource or <code>null</code> * @return selected resource or <code>null</code>
...@@ -181,7 +194,7 @@ public class SelectedResourceManager implements IWindowListener, ISelectionListe ...@@ -181,7 +194,7 @@ public class SelectedResourceManager implements IWindowListener, ISelectionListe
return fSelectedVerilogFile; return fSelectedVerilogFile;
} }
/** /**
* Returns resource by selection in the active workbench window, * Returns resource by selection in the active workbench window,
* or <code>null</code> if none. If an editor is active, the resource adapater * or <code>null</code> if none. If an editor is active, the resource adapater
* associated with the editor is returned. * associated with the editor is returned.
...@@ -286,17 +299,37 @@ public class SelectedResourceManager implements IWindowListener, ISelectionListe ...@@ -286,17 +299,37 @@ public class SelectedResourceManager implements IWindowListener, ISelectionListe
} }
} }
// Build stamp/date methods
public String setBuildStamp(){ public String setBuildStamp(){
// timestamp=System.nanoTime(); timestamp=getBuildStamp(new Date());
//String fileName = new SimpleDateFormat("yyyyMMddHHmmssSSS'.txt'").format(new Date()));
timestamp= new SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date());
return getBuildStamp(); return getBuildStamp();
} }
public String getBuildStamp(){ public String getBuildStamp(){
return timestamp; return timestamp;
} }
public static String getBuildStamp(Date date){
return new SimpleDateFormat(VDT.TIME_STAMP_FORMAT).format(date);
}
public static Date parseStamp(String stamp){
Date d;
try {
d = new SimpleDateFormat(VDT.TIME_STAMP_FORMAT).parse(stamp);
} catch (ParseException e) {
d=new Date(0);
System.out.println("Date format '"+stamp+"' not recognized, using beginning of all of times: "+
new SimpleDateFormat(VDT.TIME_STAMP_FORMAT).format(d));
return d; // 1970
}
return d;
}
public static boolean afterStamp(String after, String before){
return parseStamp(before).after(parseStamp(after));
}
public String getChosenTarget() { public String getChosenTarget() {
return fChosenTarget; return fChosenTarget;
...@@ -304,10 +337,17 @@ public class SelectedResourceManager implements IWindowListener, ISelectionListe ...@@ -304,10 +337,17 @@ public class SelectedResourceManager implements IWindowListener, ISelectionListe
public String getChosenShort() { public String getChosenShort() {
return fChosenShort; return fChosenShort;
} }
public IResource getChosenVerilogFile() { public IResource getChosenVerilogFile() {
return (fChosenVerilogFile!=null)?fChosenVerilogFile:fSelectedVerilogFile; return (fChosenVerilogFile!=null)?fChosenVerilogFile:fSelectedVerilogFile;
} }
// Used when restoring from memento
public void setChosenVerilogFile(IResource file) {
fChosenVerilogFile=file;
if (fSelectedResource==null) fSelectedResource=file;
}
public int getChosenAction() { public int getChosenAction() {
return fChosenAction; return fChosenAction;
...@@ -320,6 +360,9 @@ public class SelectedResourceManager implements IWindowListener, ISelectionListe ...@@ -320,6 +360,9 @@ public class SelectedResourceManager implements IWindowListener, ISelectionListe
public String getFilter(){ public String getFilter(){
return ignoreFilter; return ignoreFilter;
} }
public void setFilter(String filter){
ignoreFilter=filter;
}
......
...@@ -58,6 +58,7 @@ import com.elphel.vdt.core.tools.params.ToolSequence; ...@@ -58,6 +58,7 @@ import com.elphel.vdt.core.tools.params.ToolSequence;
import com.elphel.vdt.core.tools.params.types.RunFor; import com.elphel.vdt.core.tools.params.types.RunFor;
import com.elphel.vdt.Txt; import com.elphel.vdt.Txt;
import com.elphel.vdt.VDT; import com.elphel.vdt.VDT;
import com.elphel.vdt.VerilogUtils;
import com.elphel.vdt.veditor.VerilogPlugin; import com.elphel.vdt.veditor.VerilogPlugin;
import com.elphel.vdt.veditor.preference.PreferenceStrings; import com.elphel.vdt.veditor.preference.PreferenceStrings;
import com.elphel.vdt.ui.MessageUI; import com.elphel.vdt.ui.MessageUI;
...@@ -94,7 +95,9 @@ import org.eclipse.debug.ui.DebugUITools; ...@@ -94,7 +95,9 @@ import org.eclipse.debug.ui.DebugUITools;
public class DesignFlowView extends ViewPart implements ISelectionListener { public class DesignFlowView extends ViewPart implements ISelectionListener {
// Persistance tags. // Persistance tags.
private static final String TAG_SELECTED_RESOURCE = "SelectedProject"; private static final String TAG_SELECTED_RESOURCE = "SelectedProject";
private static final String TAG_SELECTED_HDL_FILE = "SelectedHdlFile";
private static final String TAG_SELECTED_HDL_FILTER = "SelectedHdlFilter";
private static final String TAG_LINKED_TOOLS = "LinkedTools"; private static final String TAG_LINKED_TOOLS = "LinkedTools";
private TreeViewer viewer; private TreeViewer viewer;
...@@ -267,6 +270,10 @@ public class DesignFlowView extends ViewPart implements ISelectionListener { ...@@ -267,6 +270,10 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
setTitleToolTip(null); setTitleToolTip(null);
} }
} }
public void changeMenuTitle(String title){
setPartName(title);
}
private void hookContextMenu() { private void hookContextMenu() {
MenuManager menuMgr = new MenuManager("#PopupMenu"); MenuManager menuMgr = new MenuManager("#PopupMenu");
...@@ -973,6 +980,7 @@ public class DesignFlowView extends ViewPart implements ISelectionListener { ...@@ -973,6 +980,7 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
DesignMenu newDesignMenu = dialog.getSelectedDesignMenu(); DesignMenu newDesignMenu = dialog.getSelectedDesignMenu();
String newDesignMenuName = newDesignMenu == null ? null String newDesignMenuName = newDesignMenu == null ? null
: newDesignMenu.getName(); : newDesignMenu.getName();
desigMenuName.setValue(newDesignMenuName); // ??? Andrey
OptionsCore.doStoreOption(desigMenuName, project); OptionsCore.doStoreOption(desigMenuName, project);
doLoadDesignMenu(newDesignMenuName); doLoadDesignMenu(newDesignMenuName);
} }
...@@ -1112,19 +1120,51 @@ public class DesignFlowView extends ViewPart implements ISelectionListener { ...@@ -1112,19 +1120,51 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
* @since 2.0 * @since 2.0
*/ */
protected void restoreState(IMemento memento) { protected void restoreState(IMemento memento) {
SelectedResourceManager.getDefault().setToolSequence(toolSequence); // to enable access through static method
Boolean linkedTools= memento.getBoolean(TAG_LINKED_TOOLS); Boolean linkedTools= memento.getBoolean(TAG_LINKED_TOOLS);
ToolsCore.restoreToolsState(memento); ToolsCore.restoreToolsState(memento);
if (linkedTools==null) linkedTools=true;
SelectedResourceManager.getDefault().setToolsLinked(linkedTools);
toggleLinkedTools.setChecked(!SelectedResourceManager.getDefault().isToolsLinked());
String location = memento.getString(TAG_SELECTED_RESOURCE); String location = memento.getString(TAG_SELECTED_RESOURCE);
if (location == null) if (location == null) {
System.out.println("No project selected");
return; return;
}
selectedResource = ResourcesPlugin.getWorkspace().getRoot().findMember(Path.fromPortableString(location)); selectedResource = ResourcesPlugin.getWorkspace().getRoot().findMember(Path.fromPortableString(location));
String HDLLocation=memento.getString(TAG_SELECTED_HDL_FILE);
if (HDLLocation!=null) {
IResource HDLFile=ResourcesPlugin.getWorkspace().getRoot().findMember(Path.fromPortableString(HDLLocation));
SelectedResourceManager.getDefault().setChosenVerilogFile(HDLFile);
System.out.println("Setting HDL file to "+HDLFile.toString());
}
String HDLFilter=memento.getString(TAG_SELECTED_HDL_FILTER); //SelectedResourceManager.getDefault().getFilter();
if (HDLFilter!=null){
SelectedResourceManager.getDefault().setFilter(HDLFilter);
System.out.println("Setting HDL filter to "+HDLFilter);
}
if (linkedTools==null) linkedTools=true;
SelectedResourceManager.getDefault().setToolsLinked(linkedTools);
toggleLinkedTools.setChecked(!SelectedResourceManager.getDefault().isToolsLinked());
// Initialize VEditor database build
IResource HDLFile=SelectedResourceManager.getDefault().getChosenVerilogFile();
if ((HDLFile!=null) && HDLFile.exists()){
toolSequence.setUnfinishedBoot(memento);
VerilogUtils.getTopModuleNames((IFile) HDLFile);
} else {
toolSequence.setUnfinishedBoot(null);
finalizeAfterVEditorDB(memento);
}
}
public void finalizeAfterVEditorDB(IMemento memento){
toolSequence.restoreCurrentStates(memento); // restore states and recalc "dirty" flags - should be after tools themselves
doLoadDesignMenu(); doLoadDesignMenu();
updateLaunchAction(); updateLaunchAction();
} }
/** /**
* @see ViewPart#saveState * @see ViewPart#saveState
...@@ -1139,9 +1179,19 @@ public class DesignFlowView extends ViewPart implements ISelectionListener { ...@@ -1139,9 +1179,19 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
String location = selectedResource.getFullPath().toPortableString(); String location = selectedResource.getFullPath().toPortableString();
memento.putString(TAG_SELECTED_RESOURCE, location); memento.putString(TAG_SELECTED_RESOURCE, location);
} }
IResource HDLFile=SelectedResourceManager.getDefault().getChosenVerilogFile();
if (HDLFile!=null){
memento.putString(TAG_SELECTED_HDL_FILE,HDLFile.getFullPath().toPortableString());
System.out.println("memento.putString("+TAG_SELECTED_HDL_FILE+","+HDLFile.getFullPath().toPortableString()+")");
}
String HDLFilter=SelectedResourceManager.getDefault().getFilter();
if (HDLFilter!=null){
memento.putString(TAG_SELECTED_HDL_FILTER,HDLFilter);
System.out.println("memento.putString("+TAG_SELECTED_HDL_FILTER+","+HDLFilter+")");
}
memento.putBoolean(TAG_LINKED_TOOLS, new Boolean(SelectedResourceManager.getDefault().isToolsLinked())); memento.putBoolean(TAG_LINKED_TOOLS, new Boolean(SelectedResourceManager.getDefault().isToolsLinked()));
ToolsCore.saveToolsState(memento); ToolsCore.saveToolsState(memento);
toolSequence.saveCurrentStates(memento);
} }
} // class DesignFlowView } // class DesignFlowView
\ No newline at end of file
...@@ -303,7 +303,6 @@ public class DesignMenuModel { ...@@ -303,7 +303,6 @@ public class DesignMenuModel {
public void measureItem (Event event){ public void measureItem (Event event){
super.measureItem (event); super.measureItem (event);
boolean dirty=tool.isDirty();
boolean pinned=tool.isPinned() || !SelectedResourceManager.getDefault().isToolsLinked(); boolean pinned=tool.isPinned() || !SelectedResourceManager.getDefault().isToolsLinked();
String iconName,key; String iconName,key;
if (tool.isRunning()){ if (tool.isRunning()){
...@@ -325,7 +324,7 @@ public class DesignMenuModel { ...@@ -325,7 +324,7 @@ public class DesignMenuModel {
key= VDTPluginImages.KEY_TOOLSTATE_NEW; key= VDTPluginImages.KEY_TOOLSTATE_NEW;
break; break;
case FAILURE: case FAILURE:
if (dirty){ if (tool.isDirtyOrChanged()){
iconName=VDTPluginImages.ICON_TOOLSTATE_BAD_OLD; iconName=VDTPluginImages.ICON_TOOLSTATE_BAD_OLD;
key= VDTPluginImages.KEY_TOOLSTATE_BAD_OLD; key= VDTPluginImages.KEY_TOOLSTATE_BAD_OLD;
} else { } else {
...@@ -338,7 +337,7 @@ public class DesignMenuModel { ...@@ -338,7 +337,7 @@ public class DesignMenuModel {
iconName=VDTPluginImages.ICON_TOOLSTATE_PINNED; iconName=VDTPluginImages.ICON_TOOLSTATE_PINNED;
key= VDTPluginImages.KEY_TOOLSTATE_PINNED; key= VDTPluginImages.KEY_TOOLSTATE_PINNED;
} else { } else {
if (dirty){ if (tool.isDirtyOrChanged()){
iconName=VDTPluginImages.ICON_TOOLSTATE_GOOD_OLD; iconName=VDTPluginImages.ICON_TOOLSTATE_GOOD_OLD;
key= VDTPluginImages.KEY_TOOLSTATE_GOOD_OLD; key= VDTPluginImages.KEY_TOOLSTATE_GOOD_OLD;
} else { } else {
...@@ -352,7 +351,7 @@ public class DesignMenuModel { ...@@ -352,7 +351,7 @@ public class DesignMenuModel {
key= VDTPluginImages.KEY_TOOLSTATE_KEPT_OPEN; key= VDTPluginImages.KEY_TOOLSTATE_KEPT_OPEN;
break; break;
default: default:
if (dirty){ if (tool.isDirtyOrChanged()){
iconName=VDTPluginImages.ICON_TOOLSTATE_WTF_OLD; iconName=VDTPluginImages.ICON_TOOLSTATE_WTF_OLD;
key= VDTPluginImages.KEY_TOOLSTATE_WTF_OLD; key= VDTPluginImages.KEY_TOOLSTATE_WTF_OLD;
} else { } else {
......
...@@ -94,6 +94,11 @@ ...@@ -94,6 +94,11 @@
<syntax name="DashListIndividual" format="%(-%%ParamName %%ParamValue%| %)" /> <syntax name="DashListIndividual" format="%(-%%ParamName %%ParamValue%| %)" />
<syntax name="DashListCommon" format="-%%ParamName %(%%ParamValue%| %)" /> <syntax name="DashListCommon" format="-%%ParamName %(%%ParamValue%| %)" />
<syntax name="DashName" format=" -%%ParamName" /> <syntax name="DashName" format=" -%%ParamName" />
<!--
Does not work according to 2.2.1. "Inside text-repetitor, one and only one pattern-generator is mandatory".
<syntax name="RepeatCommandSyntax" format="%(%%ParamName %%ParamValue%|\n%)" /> -->
</interface> </interface>
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
<vdt-project> <vdt-project>
<interface name="FPGAPprojectInterface"> <interface name="FPGAPprojectInterface">
<syntax name="RemoteRootSyntax" format="%%ParamValue/%%ProjectName" /> <syntax name="RemoteRootSyntax" format="%%ParamValue/%%ProjectName" />
<syntax name="SourceListSyntax" format="%(%%SourceList%| %)" /> <!-- <syntax name="SourceListSyntax" format="%(%%SourceList%| %)" />
<syntax name="FilteredSourceListSyntax" format="%(%%FilteredSourceList%| %)" /> <syntax name="FilteredSourceListSyntax" format="%(%%FilteredSourceList%| %)" /> -->
<syntax name="ProgramSyntax" format="%(%%ParamValue%|\n%)" /> <syntax name="ProgramSyntax" format="%(%%ParamValue%|\n%)" />
<!-- typedef --> <!-- typedef -->
</interface> </interface>
...@@ -129,37 +129,37 @@ ...@@ -129,37 +129,37 @@
<parameter id="SnapshotSynth" <parameter id="SnapshotSynth"
label="Synthesis snapshot" tooltip="Name of Vivado snapshot archive after synthesis" label="Synthesis snapshot" tooltip="Name of Vivado snapshot archive after synthesis"
default="%%ProjectName-synth.dcp" default="%%ProjectName-synth.dcp"
type="Filename" format="CopyValue" /> type="String" format="CopyValue" />
<parameter id="SnapshotOptPlace" <parameter id="SnapshotOptPlace"
label="Placement snapshot" tooltip="Name of Vivado snapshot archive after optimization/placement" label="Placement snapshot" tooltip="Name of Vivado snapshot archive after optimization/placement"
default="%%ProjectName-opt-place.dcp" default="%%ProjectName-opt-place.dcp"
type="Filename" format="CopyValue" /> type="String" format="CopyValue" />
<parameter id="SnapshotOpt" <parameter id="SnapshotOpt"
label="Optimization snapshot" tooltip="Name of Vivado snapshot archive after optimization" label="Optimization snapshot" tooltip="Name of Vivado snapshot archive after optimization"
default="%%ProjectName-opt.dcp" default="%%ProjectName-opt.dcp"
type="Filename" format="CopyValue" /> type="String" format="CopyValue" />
<parameter id="SnapshotOptPower" <parameter id="SnapshotOptPower"
label="Power optimization snapshot" tooltip="Name of Vivado snapshot archive after power optimization" label="Power optimization snapshot" tooltip="Name of Vivado snapshot archive after power optimization"
default="%%ProjectName-opt-power.dcp" default="%%ProjectName-opt-power.dcp"
type="Filename" format="CopyValue" /> type="String" format="CopyValue" />
<parameter id="SnapshotPlace" <parameter id="SnapshotPlace"
label="Placement snapshot" tooltip="Name of Vivado snapshot archive after placement" label="Placement snapshot" tooltip="Name of Vivado snapshot archive after placement"
default="%%ProjectName-place.dcp" default="%%ProjectName-place.dcp"
type="Filename" format="CopyValue" /> type="String" format="CopyValue" />
<parameter id="SnapshotOptPhys" <parameter id="SnapshotOptPhys"
label="Physical optimization snapshot" tooltip="Name of Vivado snapshot archive after physical optimization" label="Physical optimization snapshot" tooltip="Name of Vivado snapshot archive after physical optimization"
default="%%ProjectName-opt-phys.dcp" default="%%ProjectName-opt-phys.dcp"
type="Filename" format="CopyValue" /> type="String" format="CopyValue" />
<parameter id="SnapshotRoute" <parameter id="SnapshotRoute"
label="Routing snapshot" tooltip="Name of Vivado snapshot archive after routing" label="Routing snapshot" tooltip="Name of Vivado snapshot archive after routing"
default="%%ProjectName-route.dcp" default="%%ProjectName-route.dcp"
type="Filename" format="CopyValue" /> type="String" format="CopyValue" />
<parameter id="DisableVivadoSynth" <parameter id="DisableVivadoSynth"
label="Disable Vivado synthesis" tooltip="Disable tool Vivado Synthesis" label="Disable Vivado synthesis" tooltip="Disable tool Vivado Synthesis"
......
...@@ -119,9 +119,11 @@ ...@@ -119,9 +119,11 @@
<parameter id="v" type="SwitchType" format="SwitchSyntax" <parameter id="v" type="SwitchType" format="SwitchSyntax"
default="true" label="Verbose" /> default="true" label="Verbose" />
<parameter id="Param_SourceList" label="Param_SourceList" <!-- <parameter id="Param_SourceList" label="Param_SourceList"
type="Stringlist" format="SourceListSyntax" default="" readonly="true" type="Stringlist" format="SourceListSyntax" default="" readonly="true"
visible="true" /> visible="true" /> -->
<parameter id="SourceListPar" label="Param_SourceList" type="Filelist"
format="ParamListSyntax" default="%%FilteredSourceList" readonly="true" visible="false" />
<parameter id="ShowNoProblem" type="BoolYesNo" format="None" <parameter id="ShowNoProblem" type="BoolYesNo" format="None"
...@@ -199,8 +201,10 @@ ...@@ -199,8 +201,10 @@
<parameter id="IVerilogActionIndex" default="%%ChosenActionIndex" <parameter id="IVerilogActionIndex" default="%%ChosenActionIndex"
type="String" format="CopyValue" visible="false" /> type="String" format="CopyValue" visible="false" />
<parameter id="SourceList" format="SourceListSyntax" <!-- <parameter id="SourceList" format="SourceListSyntax"
type="Stringlist" default="" readonly="true" visible="false" /> type="Stringlist" default="" readonly="true" visible="false" /> -->
<parameter id="SourceListPar" label="Param_SourceList" type="Filelist"
format="ParamListSyntax" default="%%FilteredSourceList" readonly="true" visible="false" />
<parameter id="iverilog_include_file" default="IVERILOG_INCLUDE.v" <parameter id="iverilog_include_file" default="IVERILOG_INCLUDE.v"
type="Filename" format="CopyValue" visible="false" /> type="Filename" format="CopyValue" visible="false" />
...@@ -300,7 +304,7 @@ ...@@ -300,7 +304,7 @@
"%legacy_model" "%legacy_model"
"%no_specify" "%no_specify"
"%v" "%v"
"%SourceList" "%SourceListPar"
"%ExtraFiles" "%ExtraFiles"
<if ShowNoProblem="false"> <if ShowNoProblem="false">
"2&gt;&amp;1" "2&gt;&amp;1"
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<vdt-project> <vdt-project>
<interface name="VivadoSynthesisInterface" extends="VivadoInterface"> <interface name="VivadoSynthesisInterface" extends="VivadoInterface">
<syntax name="read_xdc_syntax" format="%(read_xdc %%ParamValue%|\n%)" /> <syntax name="read_xdc_syntax" format="%(read_xdc %%ParamValue%|\n%)" />
<typedef name="FlattenHierarchyType"> <typedef name="FlattenHierarchyType">
<paramtype kind= "enum" base="String"> <paramtype kind= "enum" base="String">
<item value="rebuilt" label="Attempt to rebuild hierarchy after synthesis is completed"/> <item value="rebuilt" label="Attempt to rebuild hierarchy after synthesis is completed"/>
...@@ -75,10 +75,17 @@ ...@@ -75,10 +75,17 @@
<action label="Check by Vivado Synthesis:" resource="%%SelectedFile" <action label="Check by Vivado Synthesis:" resource="%%SelectedFile"
check-extension="true" check-existence="true" icon="IconTestTube.png" /> check-extension="true" check-existence="true" icon="IconTestTube.png" />
</action-menu> </action-menu>
<!-- TODO: find out, how to reset state and make a tool to depend on-->
<depends-list>
<depends files="FilteredSourceListPar"/>
<depends files="ConstraintsFiles"/>
</depends-list>
<parameter id="ConstraintsFiles" type="Filelist" format="ParamListSyntax" <parameter id="ConstraintsFiles" type="Filelist" format="ParamListSyntax"
default="" label="Constraints files" tooltip="Select constraint files to load to Vivado" readonly="false" default="" label="Constraints files" tooltip="Select constraint files to load to Vivado" readonly="false"
visible="true" /> visible="true" />
<parameter id="SkipSnapshotSynth" label="Skip snapshot" tooltip="Do not create snapshot after synthesis" <parameter id="SkipSnapshotSynth" label="Skip snapshot" tooltip="Do not create snapshot after synthesis"
default="false" default="false"
type= "Boolean" format="None"/> type= "Boolean" format="None"/>
...@@ -149,12 +156,19 @@ ...@@ -149,12 +156,19 @@
default="false" visible="true" omit="false" type="Boolean" format="DashName"/> default="false" visible="true" omit="false" type="Boolean" format="DashName"/>
<!-- hidden (calculated) parameters --> <!-- hidden (calculated) parameters -->
<parameter id="FilteredSourceList" type="Stringlist" <!-- <parameter id="FilteredSourceList" type="Filelist"
format="FilteredSourceListSyntax" default="" readonly="true" visible="false" /> format="FilteredSourceListSyntax" default="" readonly="true" visible="false" /> -->
<parameter id="FilteredSourceListPar" type="Filelist"
format="ParamListSyntax" default="%%FilteredSourceList" readonly="true" visible="false" />
<!-- Parameter read_xdc just copies parameter ConstraintsFiles, but they have different syntax (output representation) --> <!-- Parameter read_xdc just copies parameter ConstraintsFiles, but they have different syntax (output representation) -->
<parameter id="read_xdc" type="Filelist" format="read_xdc_syntax" label="" tooltip="read_xdc"
<parameter id="read_xdc" type="Filelist" format="read_xdc_syntax"
default="%ConstraintsFiles" visible="false" /> default="%ConstraintsFiles" visible="false" />
<!-- <parameter id="read_xdc" type="Filelist" format="read_xdc_syntax" label="" tooltip="read_xdc"
default="%ConstraintsFiles" visible="false" /> -->
<!-- <parameter id="top" label="" tooltip= "Top module of the design" <!-- <parameter id="top" label="" tooltip= "Top module of the design"
default="%%TopModule" visible="false" omit="" type="String" format="Dash"/> --> default="%%TopModule" visible="false" omit="" type="String" format="Dash"/> -->
<parameter id="VivadoSynthActionIndex" default="%%ChosenActionIndex" <parameter id="VivadoSynthActionIndex" default="%%ChosenActionIndex"
...@@ -190,7 +204,8 @@ ...@@ -190,7 +204,8 @@
<!-- invisible/calculated parameters --> <!-- invisible/calculated parameters -->
<parameter id="AutosaveVivadoSynthesis" default="?%%ChosenActionIndex=0 ^ %SkipSnapshotSynth=false : true, false" <parameter id="AutosaveVivadoSynthesis" default="?%%ChosenActionIndex=0 ^ %SkipSnapshotSynth=false : true, false"
visible="false" type="Boolean" format="None"/> visible="false" type="Boolean" format="None"/>
<parameter id="condConstraintsFiles" default="?%%ChosenActionIndex=0 : %ConstraintsFiles, "
visible="false" type="Filelist" format="None"/>
<input> <input>
<group name="General"> <group name="General">
...@@ -257,7 +272,7 @@ ...@@ -257,7 +272,7 @@
"%VivadoProjectRoot" "%VivadoProjectRoot"
"' ;" "' ;"
"rsync -avrR -e ssh" "rsync -avrR -e ssh"
"%FilteredSourceList" "%FilteredSourceListPar"
<if VivadoSynthActionIndex="0"> <if VivadoSynthActionIndex="0">
"%ConstraintsFiles" "%ConstraintsFiles"
</if> </if>
...@@ -279,13 +294,14 @@ ...@@ -279,13 +294,14 @@
"reset_project -quiet\n" "reset_project -quiet\n"
</if> </if>
"file mkdir $outputDir\n" "file mkdir $outputDir\n"
"read_verilog %FilteredSourceList\n" "read_verilog "
"%FilteredSourceListPar\n"
<if VivadoSynthActionIndex="0"> <if VivadoSynthActionIndex="0">
<if ConstraintsFiles=""> <if ConstraintsFiles="">
"puts \"No constraints files specified, skipping read_xdc command\";\n" "puts \"No constraints files specified, skipping read_xdc command\";\n"
</if> </if>
<if-not ConstraintsFiles=""> <if-not ConstraintsFiles="">
"%read_xdc\n" "%read_xdc\n"
</if-not> </if-not>
</if> </if>
"synth_design" "synth_design"
......
...@@ -25,8 +25,10 @@ ...@@ -25,8 +25,10 @@
<parameter id="Timeout" label="Script timeout(sec)" type="Cardinal" <parameter id="Timeout" label="Script timeout(sec)" type="Cardinal"
format="CopyValue" default="10" readonly="false" visible="true" /> format="CopyValue" default="10" readonly="false" visible="true" />
<!-- hidden (calculated) parameters --> <!-- hidden (calculated) parameters -->
<parameter id="FilteredSourceList" type="Stringlist" <!-- <parameter id="FilteredSourceList" type="Stringlist"
format="FilteredSourceListSyntax" default="" readonly="true" visible="false" /> format="FilteredSourceListSyntax" default="" readonly="true" visible="false" /> -->
<parameter id="FilteredSourceListPar" type="Filelist"
format="ParamListSyntax" default="%%FilteredSourceList" readonly="true" visible="false" />
<input> <input>
<group name="General"> <group name="General">
...@@ -40,7 +42,7 @@ ...@@ -40,7 +42,7 @@
"-c" "-c"
"echo 'scp files here' ;" "echo 'scp files here' ;"
"echo '" "echo '"
"%FilteredSourceList" "%FilteredSourceListPar"
"' ;" "' ;"
"sleep 2 ;" "sleep 2 ;"
</line> </line>
......
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