Ejemplo n.º 1
0
def main():
    args = parse_args()
    allFiles = fileCollection.getAllSourceFiles(args.src[0])
    
    graph = headInGraph();
    allFileSize = []
    for file in allFiles:
        allFileSize.append(os.path.getsize(file))
        statbuf = os.stat(file)
        if(".h" not in file):
            graph.addNode(os.path.basename(file).replace(".", "_"), fileNode.cppColor, "internal", statbuf.st_mtime, max(1, 50 * (os.path.getsize(file) /float(max(allFileSize)) ) ) )
        else:
            graph.addNode(os.path.basename(file).replace(".", "_"), fileNode.headerColor, "internal", statbuf.st_mtime,  max(1, 50 * (os.path.getsize(file) /float(max(allFileSize)) ) ) )
    pattern = re.compile("^[\w]*#include.*\".*\.h")
    for file in allFiles:
        for i, line in enumerate(open(file)):
            for match in re.finditer(pattern, line):
                if(".h" in file): 
                    graph.addPair(os.path.basename(file).replace(".", "_"), os.path.basename(re.findall('"([^"]*)"', line)[0]).replace(".", "_"), fileNode.headToHeadColor)
                else:
                    graph.addPair(os.path.basename(file).replace(".", "_"), os.path.basename(re.findall('"([^"]*)"', line)[0]).replace(".", "_"), fileNode.cppToHeaderColor)
    graph.setNodeColorAll(fileNode.unModColor)
    graph.setEdgeColorAll(fileNode.unModEdgeColor)
    outFileTest = open(args.outMod[0], "w")
    graph.modChildren(graph.nodePositions_[args.header[0]], fileNode.modColor, fileNode.modEdgeColor)
    graph.nodes_[graph.nodePositions_[args.header[0]]].color_ = "#ff0000"
    graph.printGraphViz(outFileTest, args.header[0], False)
Ejemplo n.º 2
0
def main():
    args = parse_args()
    allFiles = fileCollection.getAllSourceFiles(args.src[0])
    objectFiles = fileCollection.getObjectFiles(args.obj[0])
    srcFileDict = {}
    graph = headInGraph();
    objectFilesTrimedDic = {}
    for obj in objectFiles:
        srcName = obj.find(args.src[0])
        objectFilesTrimedDic[obj[srcName:]] = obj
        srcFileDict[os.path.basename(obj).replace(".o", "_cpp")] = obj
    
    for file in allFiles:
        statbuf = os.stat(file)
        if(".h" not in file):
            graph.addNode(os.path.basename(file).replace(".", "_"), fileNode.cppColor, "internal", statbuf.st_mtime, os.path.getsize(file))
            lastPeriod = file.rfind(".c")
            objNameFile = file[:lastPeriod] + ".o"
            if objNameFile in objectFilesTrimedDic.keys():
                statbuf = os.stat(objectFilesTrimedDic[objNameFile])
                graph.addObjecTime(os.path.basename(file).replace(".", "_"), statbuf.st_mtime)
        else:
            graph.addNode(os.path.basename(file).replace(".", "_"), fileNode.headerColor, "internal", statbuf.st_mtime, os.path.getsize(file))
        
    pattern = re.compile("^[\w]*#include.*\".*\.h")
    for file in allFiles:
        for i, line in enumerate(open(file)):
            for match in re.finditer(pattern, line):
                if(".h" in file): 
                    graph.addPair(os.path.basename(file).replace(".", "_"), os.path.basename(re.findall('"([^"]*)"', line)[0]).replace(".", "_"), fileNode.headToHeadColor)
                else:
                    graph.addPair(os.path.basename(file).replace(".", "_"), os.path.basename(re.findall('"([^"]*)"', line)[0]).replace(".", "_"), fileNode.cppToHeaderColor)
    graph.reset()
    needToRecompile = [];
    for nPos in range(len(graph.nodes_)):
        if not (graph.nodes_[nPos].value_.endswith("_c") or graph.nodes_[nPos].value_.endswith("_cpp")):
            for child in graph.getChildrenList(nPos):
                if not (graph.nodes_[child].value_.endswith("_h") or graph.nodes_[child].value_.endswith("_hpp") or child == nPos):
                    if graph.nodes_[nPos].modTime_ > graph.nodes_[child].objectModTime_:
                        needToRecompile.append(graph.nodes_[child].value_)
                    else:
                        graph.nodes_[child].visited_ = False
                else:
                    graph.nodes_[child].visited_ = False
        
    #print needToRecompile;
    #print srcFileDict.keys()
    out = ""
    for need in needToRecompile:
        if(need in srcFileDict.keys()):
            out += " " + srcFileDict[need]
    print out
Ejemplo n.º 3
0
def main():
    args = parse_args()
    allFiles = fileCollection.getAllSourceFiles(args.src[0])
    objectFiles = fileCollection.getObjectFiles(args.obj[0])
    srcFileDict = {}
    graph = headInGraph();
    objectFilesTrimedDic = {}
    for obj in objectFiles:
        srcName = obj.find(args.src[0])
        objectFilesTrimedDic[obj[srcName:]] = obj
        srcFileDict[os.path.basename(obj).replace(".o", "_cpp")] = obj
    
    for file in allFiles:
       
        statbuf = os.stat(file)
        if(".h" not in file):
            graph.addNode(os.path.basename(file).replace(".", "_"), fileNode.cppColor, "internal", statbuf.st_mtime,os.path.getsize(file))
            lastPeriod = file.rfind(".c")
            objNameFile = file[:lastPeriod] + ".o"
            if objNameFile in objectFilesTrimedDic.keys():
                statbuf = os.stat(objectFilesTrimedDic[objNameFile])
                graph.addObjecTime(os.path.basename(file).replace(".", "_"), statbuf.st_mtime)
        else:
            graph.addNode(os.path.basename(file).replace(".", "_"), fileNode.headerColor, "internal", statbuf.st_mtime, os.path.getsize(file))
        
    pattern = re.compile("^[\w]*#include.*\".*\.h")
    for file in allFiles:
        for i, line in enumerate(open(file)):
            for match in re.finditer(pattern, line):
                if(".h" in file): 
                    graph.addPair(os.path.basename(file).replace(".", "_"), os.path.basename(re.findall('"([^"]*)"', line)[0]).replace(".", "_"), fileNode.headToHeadColor)
                else:
                    graph.addPair(os.path.basename(file).replace(".", "_"), os.path.basename(re.findall('"([^"]*)"', line)[0]).replace(".", "_"), fileNode.cppToHeaderColor)
    graph.reset()
    needToRecompile = [];
    for nPos in range(len(graph.nodes_)):
        if not (graph.nodes_[nPos].value_.endswith("_c") or graph.nodes_[nPos].value_.endswith("_cpp")):
            for child in graph.getChildrenList(nPos):
                if not (graph.nodes_[child].value_.endswith("_h") or graph.nodes_[child].value_.endswith("_hpp") or child == nPos):
                    if graph.nodes_[nPos].modTime_ > graph.nodes_[child].objectModTime_:
                        needToRecompile.append(graph.nodes_[child].value_)
                    else:
                        graph.nodes_[child].visited_ = False
                else:
                    graph.nodes_[child].visited_ = False
        
    for need in needToRecompile:
        if(need in srcFileDict.keys()):
            os.remove(srcFileDict[need]);
Ejemplo n.º 4
0
def main():
    args = parse_args()
    allFiles = fileCollection.getAllSourceFiles(args.src[0])
    
    graph = headInGraph();
    sizes = []
    for file in allFiles:
        sizes.append(os.path.getsize(file))
   # for s in sizes:
        #print max(1, int(float(s)/max(sizes) * 100))
        
    for file in allFiles:
        #print os.path.getsize(file)
        statbuf = os.stat(file)
        #print int(float(os.path.getsize(file))/max(sizes) * 100)
        if(".h" not in file):
            graph.addNode(os.path.basename(file).replace(".", "_"), fileNode.cppColor, "internal", statbuf.st_mtime, max(1, int(float(os.path.getsize(file))/max(sizes) * 50) ))
        else:
            graph.addNode(os.path.basename(file).replace(".", "_"), fileNode.headerColor, "internal", statbuf.st_mtime, max(1, int(float(os.path.getsize(file))/max(sizes) * 50)) )
    pattern = re.compile("^[\w]*#include.*\".*\.h")
    patternSystem = re.compile("^[\w]*#include.*\<.*\>")
    for file in allFiles:
        for i, line in enumerate(open(file)):
            for match in re.finditer(pattern, line):
                if(".h" in file): 
                    graph.addPair(os.path.basename(file).replace(".", "_"), os.path.basename(re.findall('"([^"]*)"', line)[0]).replace(".", "_"), fileNode.headToHeadColor)
                else:
                    graph.addPair(os.path.basename(file).replace(".", "_"), os.path.basename(re.findall('"([^"]*)"', line)[0]).replace(".", "_"), fileNode.cppToHeaderColor)
            if args.addSystem:
                for match in re.finditer(patternSystem, line):
                    modifiedHeaderName = ((line[(line.find("<") + 1):line.find(">")]).replace(".", "_")).replace("/", "__");
                    if modifiedHeaderName not in list(graph.nodePositions_.keys()):
                        graph.addNode(modifiedHeaderName, fileNode.externalHeaderColor, "external", 0, 1)
                    if(".h" in file): 
                        graph.addPair(os.path.basename(file).replace(".", "_"), modifiedHeaderName, fileNode.headToHeadColor)
                    else:
                        graph.addPair(os.path.basename(file).replace(".", "_"), modifiedHeaderName, fileNode.cppToHeaderColor)
    
    outMainFile = open(args.outMain[0], "w");
    graph.printGraphViz(outMainFile, "all", args.addSystem)