Commit f464f5d1 authored by Andrey Filippov's avatar Andrey Filippov
Browse files

Minor changes while better integrating cocotb

parent 6f968447
Loading
Loading
Loading
Loading
+120 −0
Original line number Diff line number Diff line
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (C) 2013, Elphel.inc.
# configuration of the DDR-related registers
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#  
#  Additional permission under GNU GPL version 3 section 7:
#  If you modify this Program, or any covered work, by linking or combining it
#  with Eclipse or Eclipse plugins (or a modified version of those libraries),
#  containing parts covered by the terms of EPL/CPL, the licensors of this
#  Program grant you additional permission to convey the resulting work.
#  {Corresponding Source for a non-source form of such a combination shall
#  include the source code for the parts of Eclipse or Eclipse plugins used
#  as well as that of the covered work.}
 
__author__ = "Andrey Filippov"
__copyright__ = "Copyright 2016, Elphel, Inc."
__license__ = "GPL"
__version__ = "3.0+"
__maintainer__ = "Andrey Filippov"
__email__ = "andrey@elphel.com"
__status__ = "Development"
"""
Mimics cocotb/Python problems to those of Icarus, passing icarus through
<Filepath>:<line>: [warning|error|info]: <description>
"""


import sys
import re
RAISED_EXCEPTION="raised exception:"
COMMA_LINE=", line"
state = None # None - pass, cocotb - collecting Cocotb problem, python- just raw python problem
lines = []
def report_python(lines):
    err_msg=lines[0]
    for i in range((len(lines)-1)//2):
        fline=lines[2*i+1]
        fileStart= fline.find('"')+1
        fileEnd=   fline.find('"',fileStart)
        fpath = fline[fileStart:fileEnd]
        flineNumStart=fline.find(COMMA_LINE,fileEnd)+len(COMMA_LINE)
        flineNumEnd=  fline.find(',',flineNumStart)
        flineNum = fline[flineNumStart:flineNumEnd].strip()
        infunction = fline[flineNumEnd+1:].strip()
        lineTxt = lines[2*i+2]
        sys.stdout.write('%s:%s: error: %s, %s "%s"\n'%(fpath, flineNum, err_msg, infunction, lineTxt))

for line in iter(sys.stdin.readline,''):
    sline = line.strip()
    if state == "cocotb":
        if (len(lines)%2 == 0) or sline.startswith('File "'):
            lines.append(sline)
        else:
            report_python(lines)
            state = None
            sys.stdout.write(line)    
    elif state == "python":
        if (len(lines)%2 == 0) or sline.startswith('File "'):
            lines.append(sline)
        else:
            lines[0] = sline # instead of "Traceback (most recent call last):"
            report_python(lines)
            state = None
    else:
        if sline.startswith("Traceback (most"):
            #print("***Got Traceback***")
            state = "python"
            lines =[sline]
            continue
        elif (line.find("ERROR")>=0) and (line.find(RAISED_EXCEPTION)>0):
            #print("***Got Cocotb error***")
            index=line.find(RAISED_EXCEPTION)+len(RAISED_EXCEPTION)
            sline=  line[index:].strip()
            state = "cocotb"
            lines =[sline]
            sys.stdout.write(line)
            
            
            
            continue
        else:
            sys.stdout.write(line)    
            
    
        
"""        
'
    if isProblem(pline):
        if line.startswith("   ") :
            pline = pline[:len(pline)-1]+line[2:]
        else:
            pline=addTool(pline,tool)
#            sys.stdout.write("*"+str(debugSize())+pline)
#            sys.stdout.write(pline)
            if REMOVE_DUPS:
                lineHash=hash(pline)
                if not lineHash in dupLines:
                    dupLines.add(lineHash)
                    sys.stdout.write(pline)
#                    sys.stdout.write(": "+str(lineHash)+" : " +count(dupLines))
            else:
                sys.stdout.write(pline)    
            
            
            pline = line
    else:
        pline = line
"""
 No newline at end of file
+4 −0
Original line number Diff line number Diff line
@@ -314,9 +314,13 @@ public class RunningBuilds {
					if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING)) System.out.print("Killed open console");
					return true;
				} else {
					if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING)){
						System.out.print("removeConsole(): hasBad="+hasBad+", hasGood="+hasGood+", goodSet"+goodSet);
					}
					if      (hasBad)  tool.setState(TOOL_STATE.FAILURE);
					else if (hasGood) tool.setState(TOOL_STATE.SUCCESS);
					else if (goodSet) tool.setState(TOOL_STATE.FAILURE);
					else              tool.setState(TOOL_STATE.SUCCESS); // No bad, and good is not specified
				}
			}
		}
+4 −2
Original line number Diff line number Diff line
@@ -49,10 +49,12 @@ public class ParamNodeReader extends AbstractConditionNodeReader {
            try {
            	Parameter param = readParam(node, condition);
            	String id=param.getID();
            	// It should now handle duplicate parameters (used for conditionals) AF 2016/07/04
            	/*
            	if (paramIdList.contains(id)){
            		System.out.println("Warning: duplicate parameter ('" + id + "') in context '" + context + "' defined in "+param.getSourceXML());
//                    throw new ConfigException("Duplicate parameter ('" + id + "') in context '" + context + "' defined in "+param.getSourceXML());
            	}
            	*/
                paramIdList.add(id);
                paramList.add(param);
            } catch(ConfigException e) {
+2 −1
Original line number Diff line number Diff line
@@ -155,7 +155,8 @@ public abstract class AbstractGenerator {
    protected String fault(String message) {
    	if (menuMode)
    		return "";
        MessageUI.error("Generator '" + getName() + "' fault: " + message);
//        MessageUI.error("Generator '" + getName() + "' fault: " + message);
        System.out.println("Error: Generator '" + getName() + "' fault: " + message);
        return null;
    }
    
+9 −3
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ import com.elphel.vdt.veditor.preference.PreferenceStrings;
import com.elphel.vdt.core.options.OptionsCore;
import com.elphel.vdt.core.tools.contexts.Context;
import com.elphel.vdt.core.tools.contexts.PackageContext;
import com.elphel.vdt.core.tools.params.Parameter;
import com.elphel.vdt.core.tools.params.ToolException;
import com.elphel.vdt.core.tools.params.ToolSequence;
import com.elphel.vdt.ui.MessageUI;
@@ -88,7 +89,7 @@ public class ContextOptionsDialog extends Dialog {
    protected void okPressed() {
    	/* Currently multiple same-named parameters in the same context have warnings.
    	 * What happens is that after parameters are changed in the dialog, the new value is
    	 * applied only to the first entry, then the saecond (unmodified) entry is processed
    	 * applied only to the first entry, then the second (unmodified) entry is processed
    	 * and overwrites the modified value (effectively disabling modification. Another
    	 * option would be to partially restore name+index in the preference store - just
    	 * instead of the index of all parameters, use index among those with the same ID.
@@ -98,6 +99,11 @@ public class ContextOptionsDialog extends Dialog {
    	 * tool settings */
    	
    	optionsBlock.performApply();
    	//Debug:
//    	for (Parameter par:context.getParams()){
//    		System.out.println("okPressed() "+context.getName()+" ->"+par.getID());
//    	}
    	
        OptionsCore.doStoreContextOptions(context, store);
        context.setWorkingDirectory(location);
        try {
Loading