Commit 8bd2c99b authored by Andrey Filippov's avatar Andrey Filippov
Browse files

Working on per-tool defines adn closures

parent b0a62607
Loading
Loading
Loading
Loading
+37 −7
Original line number Original line Diff line number Diff line
@@ -27,7 +27,9 @@
package com.elphel.vdt;
package com.elphel.vdt;


import java.util.ArrayList;
import java.util.ArrayList;
//import java.util.HashMap;
import java.util.List;
import java.util.List;
//import java.util.Map;


import com.elphel.vdt.ui.variables.SelectedResourceManager;
import com.elphel.vdt.ui.variables.SelectedResourceManager;
import com.elphel.vdt.veditor.VerilogPlugin;
import com.elphel.vdt.veditor.VerilogPlugin;
@@ -185,24 +187,52 @@ public class VerilogUtils {
    	return outlineDatabase.getClosureSorted(topFiles);
    	return outlineDatabase.getClosureSorted(topFiles);
    } // getDependencies()
    } // getDependencies()
    
    
    public static IFile[] getDependencies(IFile topFile) {
    public static IFile[] getDependencies(IFile topFile, String toolDefine) {
///		System.out.println("===VerilogUtils.getDependencies("+topFile+")");
        IProject project = topFile.getProject();
        if (toolDefine != null) {
            OutlineDatabase outlineDatabase=new OutlineDatabase(project); // new OutlineDatabase just for this scan
            outlineDatabase.scanFilesWithDefine(topFile,toolDefine);
//    		System.out.println("-->>>VerilogUtils.getDependencies number of files="+outlineDatabase.getDatabaseFileList().length);
//    		for (int i=0; i<outlineDatabase.getDatabaseFileList().length; i++){
//    			System.out.println(i+": "+outlineDatabase.getDatabaseFileList()[i]);
//    		}
    		IFile[] topFiles = {topFile}; 
    		return outlineDatabase.getClosureSorted(topFiles);
        } else {
///    		System.out.println("===---VerilogUtils.getDependencies("+topFile+") - using editor depends");
        	return getDependencies(new IFile [] {topFile});	
        	return getDependencies(new IFile [] {topFile});	
        }
        }
    }    


    /**
    /**
     * Returns included files dependency closure for given verilog file.
     * Returns included files dependency closure for given verilog file.
     */
     */


    public static IFile[] getIncludedDependencies(IFile topFile, String toolDefine) {
//		System.out.println("===VerilogUtils.getIncludedDependencies("+topFile+", "+toolDefine+")");
        IProject project = topFile.getProject();
        if (toolDefine != null) {
            OutlineDatabase outlineDatabase=new OutlineDatabase(project); // new OutlineDatabase just for this scan
            outlineDatabase.scanFilesWithDefine(topFile,toolDefine);
//    		System.out.println("-->>>VerilogUtils.getDependencies number of files="+outlineDatabase.getDatabaseFileList().length);
//    		for (int i=0; i<outlineDatabase.getDatabaseFileList().length; i++){
//    			System.out.println(i+": "+outlineDatabase.getDatabaseFileList()[i]);
//    		}
    		IFile[] topFiles = {topFile}; 
    		return outlineDatabase.getClosureIncludes(topFiles);
        } else {
        	return getIncludedDependencies(new IFile [] {topFile});
        }
    }    
    
    public static IFile[] getIncludedDependencies(IFile [] topFiles) {
    public static IFile[] getIncludedDependencies(IFile [] topFiles) {
    	if (topFiles==null) return null;
    	if (topFiles==null) return null;
        IProject project = topFiles[0].getProject();
        IProject project = topFiles[0].getProject();
        OutlineDatabase outlineDatabase=getVeditorOutlineDatabase(project);
        OutlineDatabase outlineDatabase=getVeditorOutlineDatabase(project);
    	return outlineDatabase.getCLosureIncludes(topFiles);
    	return outlineDatabase.getClosureIncludes(topFiles);
    } // getDependencies()
    } // getDependencies()
    
    
    public static IFile[] getIncludedDependencies(IFile topFile) {
    	return getIncludedDependencies(new IFile [] {topFile});
    }    


    /* for now all modules, including library ones */
    /* for now all modules, including library ones */
    
    
+7 −5
Original line number Original line Diff line number Diff line
@@ -66,7 +66,7 @@ import com.elphel.vdt.ui.MessageUI;
import com.elphel.vdt.ui.dialogs.PackageLocationDialog;
import com.elphel.vdt.ui.dialogs.PackageLocationDialog;
import com.elphel.vdt.ui.dialogs.ToolLocationDialog;
import com.elphel.vdt.ui.dialogs.ToolLocationDialog;
import com.elphel.vdt.ui.preferences.PreferencePage;
import com.elphel.vdt.ui.preferences.PreferencePage;
import com.elphel.vdt.ui.views.DesignFlowView;
//import com.elphel.vdt.ui.views.DesignFlowView;


/**
/**
 * Support for launching verilog development tools programmatically.
 * Support for launching verilog development tools programmatically.
@@ -134,8 +134,9 @@ public class LaunchCore {
    public static void updateLaunchConfiguration( ILaunchConfigurationWorkingCopy workingCopy
    public static void updateLaunchConfiguration( ILaunchConfigurationWorkingCopy workingCopy
                                                , Tool tool ) throws CoreException
                                                , Tool tool ) throws CoreException
    {
    {
        for (Iterator i = tool.getParams().iterator(); i.hasNext(); ) {

            Parameter param = (Parameter)i.next();
        for (Iterator<Parameter> i = tool.getParams().iterator(); i.hasNext(); ) {
            Parameter param = i.next();
            String valueAttrName = LaunchCore.getValueAttributeName(param);
            String valueAttrName = LaunchCore.getValueAttributeName(param);


            if(param.getType().isList())
            if(param.getType().isList())
@@ -159,6 +160,7 @@ public class LaunchCore {
    } // updateLaunchConfiguration()
    } // updateLaunchConfiguration()
    
    
    public static void updateContextOptions(Tool tool, IProject project) throws ToolException, CoreException {
    public static void updateContextOptions(Tool tool, IProject project) throws ToolException, CoreException {
        tool.setTreeReparse(true);
        PackageContext packageContext = tool.getParentPackage();
        PackageContext packageContext = tool.getParentPackage();
        if (packageContext != null) {
        if (packageContext != null) {
            OptionsCore.doLoadContextOptions(packageContext);
            OptionsCore.doLoadContextOptions(packageContext);
+20 −9
Original line number Original line Diff line number Diff line
@@ -145,12 +145,13 @@ public class VDTLaunchUtil {
//     public static List<String> getArguments(ILaunchConfiguration configuration) throws CoreException {
//     public static List<String> getArguments(ILaunchConfiguration configuration) throws CoreException {
       public static BuildParamsItem[] getArguments(ILaunchConfiguration configuration) throws CoreException {
       public static BuildParamsItem[] getArguments(ILaunchConfiguration configuration) throws CoreException {
        Tool tool = obtainTool(configuration);
        Tool tool = obtainTool(configuration);
        tool.setTreeReparse(true);


        // Replaces tool parameter values with the ones passed through configuration, then uses tool.buildParams;
        // Replaces tool parameter values with the ones passed through configuration, then uses tool.buildParams;
        // that causes conflicts in multi-threaded operation. Or is it just a working copy?
        // that causes conflicts in multi-threaded operation. Or is it just a working copy?
        
        
        for (Iterator i = tool.getParams().iterator(); i.hasNext(); ) {
        for (Iterator<Parameter> i = tool.getParams().iterator(); i.hasNext(); ) {
            Parameter param = (Parameter)i.next();
            Parameter param = i.next();
            String valueAttrName = LaunchCore.getValueAttributeName(param); // "ATTR_VALUE_" + toolParameter.getID();     
            String valueAttrName = LaunchCore.getValueAttributeName(param); // "ATTR_VALUE_" + toolParameter.getID();     
            try {
            try {
                if(param.getType().isList()) {
                if(param.getType().isList()) {
@@ -205,6 +206,16 @@ public class VDTLaunchUtil {
         return tool.getName();
         return tool.getName();
     }
     }


     public static String getToolDefine(ILaunchConfiguration configuration) throws CoreException {
         Tool tool = obtainTool(configuration);
         return tool.getDefine();
     }

     public static String getToolTopFile(ILaunchConfiguration configuration) throws CoreException {
         Tool tool = obtainTool(configuration);
         return tool.getTopFile();
     }

     
     
     public static String getPatternWarnings(ILaunchConfiguration configuration) throws CoreException {
     public static String getPatternWarnings(ILaunchConfiguration configuration) throws CoreException {
         Tool tool = obtainTool(configuration);
         Tool tool = obtainTool(configuration);
@@ -249,7 +260,7 @@ public class VDTLaunchUtil {
//                return resources;
//                return resources;
//                return parseVerilogFile(resource);
//                return parseVerilogFile(resource);
                if (resource instanceof IFile) { 
                if (resource instanceof IFile) { 
                        List<String> resourcesLocation = getVerilogFileDependencies((IFile)resource);
                        List<String> resourcesLocation = getVerilogFileDependencies((IFile)resource, getToolDefine(configuration));
//                        resourcesLocation.add(resource.getLocation().toOSString());
//                        resourcesLocation.add(resource.getLocation().toOSString());
                        return resourcesLocation;
                        return resourcesLocation;
                }       
                }       
@@ -258,13 +269,13 @@ public class VDTLaunchUtil {
        return null;
        return null;
    } // getResources()
    } // getResources()
    
    
    private static List<String> getVerilogFileDependencies(IFile file) throws CoreException {
    private static List<String> getVerilogFileDependencies(IFile file, String toolDefine) throws CoreException {
   	
   	
//        StackTraceElement frame = new Exception().getStackTrace()[0];
//        StackTraceElement frame = new Exception().getStackTrace()[0];
//    	System.out.println("*** Broken core/tools/generators in "+frame.getFileName()+":"+frame.getLineNumber());
//    	System.out.println("*** Broken core/tools/generators in "+frame.getFileName()+":"+frame.getLineNumber());
//        return null;
//        return null;
        
        
        IFile[] dependencies = VerilogUtils.getDependencies(file);
        IFile[] dependencies = VerilogUtils.getDependencies(file, toolDefine);
        List<String> dependenciesLocation = new ArrayList<String>();
        List<String> dependenciesLocation = new ArrayList<String>();
        
        
        if(dependencies != null) {
        if(dependencies != null) {
@@ -273,7 +284,7 @@ public class VDTLaunchUtil {
//                  System.out.println("  "+dependencies[i].getName());
//                  System.out.println("  "+dependencies[i].getName());
            }    
            }    
        }
        }
        dependencies = VerilogUtils.getIncludedDependencies(file);
        dependencies = VerilogUtils.getIncludedDependencies(file, toolDefine);
        if(dependencies != null) {
        if(dependencies != null) {
            for (int i=0; i < dependencies.length; i++) {
            for (int i=0; i < dependencies.length; i++) {
                    dependenciesLocation.add(dependencies[i].getLocation().toOSString());
                    dependenciesLocation.add(dependencies[i].getLocation().toOSString());
+9 −2
Original line number Original line Diff line number Diff line
@@ -147,6 +147,9 @@ public class XMLConfig extends Config {
    static final String CONTEXT_TOOL_ABSTRACT =       "abstract"; // true for the prototype tools used only for inheritance by others
    static final String CONTEXT_TOOL_ABSTRACT =       "abstract"; // true for the prototype tools used only for inheritance by others
    static final String CONTEXT_TOOL_PRIORITY =       "priority"; // lower the value, first to run among otherwise equivalent report tools (taht do not change state)
    static final String CONTEXT_TOOL_PRIORITY =       "priority"; // lower the value, first to run among otherwise equivalent report tools (taht do not change state)


    static final String CONTEXT_TOOL_TOP_FILE =       "top-file"; // Top file for this tool
    static final String CONTEXT_TOOL_DEFINE =         "define";   // Tool-specific define used to resolve dependencies



    static final String CONTEXT_LINEBLOCK_TAG =           "line";
    static final String CONTEXT_LINEBLOCK_TAG =           "line";
    static final String CONTEXT_LINEBLOCK_NAME_ATTR =     "name";
    static final String CONTEXT_LINEBLOCK_NAME_ATTR =     "name";
@@ -664,6 +667,8 @@ public class XMLConfig extends Config {
                
                
                String priorityString = getAttributeValue(contextNode, CONTEXT_TOOL_PRIORITY);
                String priorityString = getAttributeValue(contextNode, CONTEXT_TOOL_PRIORITY);


                String topFile =        getAttributeValue(contextNode, CONTEXT_TOOL_TOP_FILE);
                String toolDefine =     getAttributeValue(contextNode, CONTEXT_TOOL_DEFINE);


                double priority=Double.NaN;;
                double priority=Double.NaN;;
                if (priorityString!=null){
                if (priorityString!=null){
@@ -735,6 +740,8 @@ public class XMLConfig extends Config {
                                   autoSaveString,
                                   autoSaveString,
                                   isAbstract,
                                   isAbstract,
                                   priority,
                                   priority,
                                   topFile,
                                   toolDefine,
                                   null,
                                   null,
                                   null,
                                   null,
                                   null);
                                   null);
+13 −3
Original line number Original line Diff line number Diff line
@@ -67,13 +67,13 @@ public abstract class Context {
    protected List<CommandLinesBlock> commandLinesBlocks;
    protected List<CommandLinesBlock> commandLinesBlocks;
    protected List<ParamGroup> visibleParamGroups = new ArrayList<ParamGroup>();
    protected List<ParamGroup> visibleParamGroups = new ArrayList<ParamGroup>();
    protected Config config;
    protected Config config;

    protected boolean needsReparse;
    private StringConditionParser conditionParser = new StringConditionParser(this); 
    private StringConditionParser conditionParser = new StringConditionParser(this); 
    private List<String> createdControlFiles = new ArrayList<String>();    
    private List<String> createdControlFiles = new ArrayList<String>();    
    private boolean initialized = false; 
    private boolean initialized = false; 
    private String workingDirectory;
    private String workingDirectory;
    private String version;
    private String version;
    private Context context=null;
//    private Context context=null;
    private int currentHash; // calculated during buildparam from non-parser command blocks and command files.
    private int currentHash; // calculated during buildparam from non-parser command blocks and command files.
    protected Context(String name,
    protected Context(String name,
                      String controlInterfaceName,
                      String controlInterfaceName,
@@ -92,6 +92,16 @@ public abstract class Context {
        this.inputDialogLabel = inputDialogLabel;
        this.inputDialogLabel = inputDialogLabel;
        this.paramGroups = paramGroups;        
        this.paramGroups = paramGroups;        
        this.paramContainer = new ParameterContainer(params);
        this.paramContainer = new ParameterContainer(params);
        this.needsReparse = false;
    }
    
    // Tree needed to be reparsed for closure rebuild (slow)
    public boolean needsTreeReparse(){
    	return needsReparse;
    }
    public void setTreeReparse(boolean needsReparse){
//    	System.out.println("Tool.setTreeReparse("+needsReparse+") - "+getName());
    	this.needsReparse = needsReparse;
    }
    }
    
    
    /**
    /**
Loading