Commit f2a02373 authored by Andrey Filippov's avatar Andrey Filippov

Fixing tool dependencies, dirty flag

parent 8bd2c99b
...@@ -188,7 +188,7 @@ public class VerilogUtils { ...@@ -188,7 +188,7 @@ public class VerilogUtils {
} // getDependencies() } // getDependencies()
public static IFile[] getDependencies(IFile topFile, String toolDefine) { public static IFile[] getDependencies(IFile topFile, String toolDefine) {
/// System.out.println("===VerilogUtils.getDependencies("+topFile+")"); // System.out.println("===VerilogUtils.getDependencies("+topFile+")");
IProject project = topFile.getProject(); IProject project = topFile.getProject();
if (toolDefine != null) { if (toolDefine != null) {
OutlineDatabase outlineDatabase=new OutlineDatabase(project); // new OutlineDatabase just for this scan OutlineDatabase outlineDatabase=new OutlineDatabase(project); // new OutlineDatabase just for this scan
...@@ -200,7 +200,7 @@ public class VerilogUtils { ...@@ -200,7 +200,7 @@ public class VerilogUtils {
IFile[] topFiles = {topFile}; IFile[] topFiles = {topFile};
return outlineDatabase.getClosureSorted(topFiles); return outlineDatabase.getClosureSorted(topFiles);
} else { } else {
/// System.out.println("===---VerilogUtils.getDependencies("+topFile+") - using editor depends"); // System.out.println("===---VerilogUtils.getDependencies("+topFile+") - using editor depends");
return getDependencies(new IFile [] {topFile}); return getDependencies(new IFile [] {topFile});
} }
} }
......
...@@ -687,7 +687,7 @@ public class Tool extends Context implements Cloneable, Inheritable { ...@@ -687,7 +687,7 @@ public class Tool extends Context implements Cloneable, Inheritable {
} }
} }
for (String item:list){ for (String item:list){
System.out.println("-----> "+getName()+".getDependFiles()->"+item); DEBUG_PRINT("-----> "+getName()+".getDependFiles()->"+item);
} }
return list; return list;
} }
...@@ -1035,7 +1035,8 @@ public class Tool extends Context implements Cloneable, Inheritable { ...@@ -1035,7 +1035,8 @@ public class Tool extends Context implements Cloneable, Inheritable {
try {project.setPersistentProperty(qn, dependFilesTimestamps.get(file));} try {project.setPersistentProperty(qn, dependFilesTimestamps.get(file));}
catch (CoreException e) {System.out.println(project+"Failed setPersistentProperty("+qn+", "+dependFilesTimestamps.get(file)+", e="+e);} catch (CoreException e) {System.out.println(project+"Failed setPersistentProperty("+qn+", "+dependFilesTimestamps.get(file)+", e="+e);}
} }
DEBUG_PRINT("*** Updated persistent properties for tool "+getName()+ " in the project "+project.toString()); DEBUG_PRINT("*** Updated persistent properties for tool "+getName()+ " in the project "+project.toString()+
", state="+getState().toString());
} }
public void restoreState(IProject project) { public void restoreState(IProject project) {
...@@ -1137,6 +1138,7 @@ public class Tool extends Context implements Cloneable, Inheritable { ...@@ -1137,6 +1138,7 @@ public class Tool extends Context implements Cloneable, Inheritable {
// if (getName().equals("ISExst")){ // if (getName().equals("ISExst")){
// System.out.println("restoreState(memento): Debugging ISExst"); // System.out.println("restoreState(memento): Debugging ISExst");
// } // }
DEBUG_PRINT(name+" isDirty() == "+isDirty());
IMemento[] toolMementos=memento.getChildren(MEMENTO_TOOL_TYPE); IMemento[] toolMementos=memento.getChildren(MEMENTO_TOOL_TYPE);
IMemento toolMemento=null; IMemento toolMemento=null;
for (IMemento tm:toolMementos){ for (IMemento tm:toolMementos){
...@@ -1155,7 +1157,10 @@ public class Tool extends Context implements Cloneable, Inheritable { ...@@ -1155,7 +1157,10 @@ public class Tool extends Context implements Cloneable, Inheritable {
String state=toolMemento.getString(MEMENTO_TOOL_STATE); String state=toolMemento.getString(MEMENTO_TOOL_STATE);
if (state!=null){ if (state!=null){
try { try {
setStateJustThis(TOOL_STATE.valueOf(state)); setStateJustThis(TOOL_STATE.valueOf(state));
DEBUG_PRINT("Got memento data for "+name+" state="+state.toString());
} catch (IllegalArgumentException e){ } catch (IllegalArgumentException e){
System.out.println("Invalid tool state: "+state+" for tool "+name+" in memento"); System.out.println("Invalid tool state: "+state+" for tool "+name+" in memento");
} }
...@@ -1191,7 +1196,9 @@ public class Tool extends Context implements Cloneable, Inheritable { ...@@ -1191,7 +1196,9 @@ public class Tool extends Context implements Cloneable, Inheritable {
setFileTimeStamp(depName, value); setFileTimeStamp(depName, value);
// DEBUG_PRINT("Got memento data for "+name+":" + MEMENTO_TOOL_FILEDEPSTAMP+": name="+depName+" stamp="+value); // DEBUG_PRINT("Got memento data for "+name+":" + MEMENTO_TOOL_FILEDEPSTAMP+": name="+depName+" stamp="+value);
} }
} }
DEBUG_PRINT(name+" isDirty() == "+isDirty());
} }
public void checkBaseTool() throws ConfigException { public void checkBaseTool() throws ConfigException {
...@@ -1498,10 +1505,13 @@ public class Tool extends Context implements Cloneable, Inheritable { ...@@ -1498,10 +1505,13 @@ public class Tool extends Context implements Cloneable, Inheritable {
} }
public BuildParamsItem[] buildParams(boolean dryRun) throws ToolException { public BuildParamsItem[] buildParams(boolean dryRun) throws ToolException {
return buildParams(dryRun, !dryRun);
}
public BuildParamsItem[] buildParams(boolean dryRun, boolean reParse) throws ToolException {
DEBUG_PRINT("buildParams("+dryRun+"): tool "+getName()+" state="+getState()+" dirty="+isDirty()+" hashMatch()="+hashMatch()+" pinned="+isPinned()); DEBUG_PRINT("buildParams("+dryRun+", "+reParse+"): tool "+getName()+" state="+getState()+" dirty="+isDirty()+" hashMatch()="+hashMatch()+" pinned="+isPinned());
setTreeReparse(!dryRun); setTreeReparse(reParse);
if(parentPackage != null) if(parentPackage != null)
parentPackage.buildParams(); parentPackage.buildParams();
......
...@@ -29,6 +29,10 @@ import org.eclipse.core.resources.IFile; ...@@ -29,6 +29,10 @@ import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder; 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.resources.IResourceChangeEvent;
import org.eclipse.core.resources.IResourceChangeListener;
import org.eclipse.core.resources.IResourceDelta;
import org.eclipse.core.resources.IResourceDeltaVisitor;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.QualifiedName; import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Display;
...@@ -88,6 +92,9 @@ public class ToolSequence { ...@@ -88,6 +92,9 @@ public class ToolSequence {
private Map<String,ToolStateStamp> currentStates; private Map<String,ToolStateStamp> currentStates;
private IMemento unfinishedMemento=null; private IMemento unfinishedMemento=null;
private String menuName=null; private String menuName=null;
private DependChangeListener dependChangeListener;
// private IProgressMonitor monitor; // private IProgressMonitor monitor;
private static void DEBUG_PRINT(String msg){ private static void DEBUG_PRINT(String msg){
...@@ -99,6 +106,7 @@ public class ToolSequence { ...@@ -99,6 +106,7 @@ public class ToolSequence {
public ToolSequence(DesignFlowView designFlowView){ public ToolSequence(DesignFlowView designFlowView){
this.designFlowView=designFlowView; this.designFlowView=designFlowView;
this.currentStates=new Hashtable<String,ToolStateStamp>(); this.currentStates=new Hashtable<String,ToolStateStamp>();
this.dependChangeListener = new DependChangeListener();
} }
public void clearToolStates(){ public void clearToolStates(){
...@@ -230,9 +238,20 @@ public class ToolSequence { ...@@ -230,9 +238,20 @@ public class ToolSequence {
bars.getStatusLineManager().setMessage(""); bars.getStatusLineManager().setMessage("");
// designFlowView.changeMenuTitle(menuName); // designFlowView.changeMenuTitle(menuName);
designFlowView.finalizeAfterVEditorDB(unfinishedMemento); designFlowView.finalizeAfterVEditorDB(unfinishedMemento);
DEBUG_PRINT("==============finalizeBootAfterVEditor()");
addResourceChangeListener();
// } // }
} }
public void addResourceChangeListener(){
VerilogPlugin.getWorkspace().addResourceChangeListener(
dependChangeListener, IResourceChangeEvent.POST_CHANGE);
DEBUG_PRINT("==============addResourceChangeListener()");
}
public void toolFinished(Tool tool){ public void toolFinished(Tool tool){
if (tool!=null) doToolFinished(tool); if (tool!=null) doToolFinished(tool);
if (designFlowView!=null){ if (designFlowView!=null){
...@@ -1517,7 +1536,7 @@ java.lang.NullPointerException ...@@ -1517,7 +1536,7 @@ java.lang.NullPointerException
// tool.updateContextOptions(project) recalculates parameters, but not the hashcodes // 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) tool.updateContextOptions(project); // Fill in parameters - it parses here too - at least some parameters? (not in menu mode)
try { try {
tool.buildParams(true); // dryRun tool.buildParams(true, true); // dryRun and re-parse for dependencies
} catch (ToolException e) { } catch (ToolException e) {
System.out.println("setToolsDirtyFlag(): failed to buildParams() for tool "+tool.getName()); System.out.println("setToolsDirtyFlag(): failed to buildParams() for tool "+tool.getName());
} }
...@@ -1590,6 +1609,7 @@ java.lang.NullPointerException ...@@ -1590,6 +1609,7 @@ java.lang.NullPointerException
if (!met) { if (!met) {
tool.setDirty(true); tool.setDirty(true);
newDirty=true; newDirty=true;
DEBUG_PRINT("propagateDirty(): Setting dirty flag for "+tool.getName());
} }
} }
} }
...@@ -1701,7 +1721,7 @@ java.lang.NullPointerException ...@@ -1701,7 +1721,7 @@ java.lang.NullPointerException
private Map <String,String> makeDependFiles(Tool tool, boolean failOnMissing){ private Map <String,String> makeDependFiles(Tool tool, boolean failOnMissing){
DEBUG_PRINT("++++++ makeDependFiles("+tool.getName()+")"); DEBUG_PRINT("++++++ makeDependFiles("+tool.getName()+")");
Map <String,String> depFiles=new Hashtable<String,String>(); Map <String,String> depFiles=new Hashtable<String,String>();
List<String> dependFileNames=tool.getDependFiles(); // files on which this tool depends List<String> dependFileNames=tool.getDependFiles(); // files on which this tool depends - make cached version
if (dependFileNames!=null) { if (dependFileNames!=null) {
IProject project = SelectedResourceManager.getDefault().getSelectedProject(); // should not be null when we got here IProject project = SelectedResourceManager.getDefault().getSelectedProject(); // should not be null when we got here
for (String depFile: dependFileNames){ for (String depFile: dependFileNames){
...@@ -1729,5 +1749,64 @@ java.lang.NullPointerException ...@@ -1729,5 +1749,64 @@ java.lang.NullPointerException
} }
return depFiles; return depFiles;
} }
class DeltaPrinter implements IResourceDeltaVisitor {
public boolean visit(IResourceDelta delta) {
IResource res = delta.getResource();
if ((res instanceof IFile) && (delta.getFlags() != IResourceDelta.MARKERS)) {
IFile file = (IFile) res;
switch (delta.getKind()) {
case IResourceDelta.ADDED:
break;
case IResourceDelta.REMOVED:
DEBUG_PRINT("=====>>> DependChangeListener: removed "+file);
setToolsDirtyFlag(false);
break;
case IResourceDelta.CHANGED:
DEBUG_PRINT("=====>>> DependChangeListener: changed "+file+String.format("0x%x", delta.getFlags()));
setToolsDirtyFlag(false);
break;
}
}
return true; // visit the children
}
}
// Check dependency on resource change event
/**
* Class used to keep track of workspace resources
*/
class DependChangeListener implements IResourceChangeListener {
/**
* Called when a resource is changed
*/
public void resourceChanged(IResourceChangeEvent event) {
// if (isAnyToolRunnigOrWaiting()) {
// DEBUG_PRINT("=====DependChangeListener.resourceChanged(): Tool is running");
// return;
// }
// DEBUG_PRINT("=====DependChangeListener.resourceChanged() start: "+event.getType());
switch (event.getType()) {
case IResourceChangeEvent.PRE_CLOSE:
break;
case IResourceChangeEvent.PRE_DELETE:
break;
case IResourceChangeEvent.POST_CHANGE:
try {
event.getDelta().accept(new DeltaPrinter());
} catch (CoreException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
break;
case IResourceChangeEvent.PRE_BUILD:
break;
case IResourceChangeEvent.POST_BUILD:
break;
}
}
}
} }
...@@ -1298,9 +1298,9 @@ public class DesignFlowView extends ViewPart implements ISelectionListener { ...@@ -1298,9 +1298,9 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
IResource HDLFile=SelectedResourceManager.getDefault().getChosenVerilogFile(); IResource HDLFile=SelectedResourceManager.getDefault().getChosenVerilogFile();
if ((HDLFile!=null) && HDLFile.exists()){ if ((HDLFile!=null) && HDLFile.exists()){
toolSequence.setToolsDirtyFlag(true); // recalculate each successful tool's parameters - does it trigger Database rebuild? toolSequence.setToolsDirtyFlag(true); // recalculate each successful tool's parameters - does it trigger Database rebuild?
} }
doLoadDesignMenu(); doLoadDesignMenu();
updateLaunchAction(true); // true? updateLaunchAction(true); // true?
} }
private void restoreCurrentState(IProject project){ private void restoreCurrentState(IProject project){
......
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