Exemplo n.º 1
0
 def change(self):
     """change component SIDL_SYMBOL options
     """
     project,graph = Globals().getProjectAndGraph(self.projectName)
     
     # delete uses or provides port
     if self.options.deletePortName:
         allmyports = [x.getName() for x in self._b_provides + self._b_uses]
         for p in self.options.deletePortName:
             if p not in allmyports:
                 err('There is not port named ' + p + ' in this component.')
     
         for pname in self.options.deletePortName:
             for theport in self._b_uses + self._b_provides:
                 if pname == theport.getName():
                     # TODO: Make sure this port is not in the implements or provides list under more than one name 
                     # before deleting the type
                     ptype = theport.getType()
                     if [x.getType()==ptype for x in self._b_uses + self._b_provides].count(True) + self._b_implements.keys().count(ptype) <= 0:
                         # remove edge
                         self.removeInEdge(ptype, kind = 'port', graph=graph)
                         if location == '%external%':
                             # Remove external file name in project defaults file
                             if not self._findExternal(ptype): project.removeDefaultValue(ptype,'External')
                             print >>DEBUGSTREAM, 'Removed external port or interface: ' + ptype
                             if ptype in self._b_externalSidlFiles.keys(): del self._b_externalSidlFiles[ptype]   
                     try: 
                         if theport in self._b_uses: self._b_uses.remove(theport)
                         elif theport in self._b_provides: self._b_provides.remove(theport)
                     except: err('Could not remove port %s, port not used or provided in component %s' % (pname, self.symbol))     
         
     # Let class handle everything it can (it also calls the builder update method)
     Sidlclass.change(self)
     return 0
Exemplo n.º 2
0
    def remove(self, vertexList):
        ''' Removes build-relevant information associated with vertices in vertexList.
        Returns 0 upon success, 1 otherwise.
        '''
        import glob
        project, pgraph = Globals().getProjectAndGraph(self.project.getName())
        projectDir = project.getDir()
        for vertex in vertexList:
            print >>DEBUGSTREAM, 'removing build system artifacts for ' + vertex.symbol
            if vertex.kind in ['interface','port', 'enum']:
                mydir = os.path.join(projectDir,self.locationManager.getPortLoc()[0])
                libs = glob.glob(os.path.join(mydir, 'lib', 'lib' + vertex.symbol + 'Port-*.la'))
                libs += glob.glob(os.path.join(mydir, 'lib', '*', 'lib' + vertex.symbol + 'Port-*.*'))
                for lib in libs:
                    try: fileManager.rmdir(lib,trash=False,nobackup=True)
                    except: pass
            elif vertex.kind in ['class','component']:
                mydir = os.path.join(projectDir,self.locationManager.getComponentLoc()[0])
                libs = glob.glob(os.path.join(mydir, 'lib', 'lib' + vertex.symbol + '.*'))
                for lib in libs:
                    try: fileManager.rm(lib,trash=False,nobackup=True)
                    except: pass
            else: return 0

            if os.path.exists(os.path.join(mydir,vertex.symbol)):
                try: fileManager.rmdir(os.path.join(mydir,vertex.symbol),trash=True)
                except: pass
        return 0
Exemplo n.º 3
0
    def update(self, buildFilesOnly=False, quiet=False, genSIDL=False):
        '''Given a new project graph, update build information. 
        @param buildFilesOnly: Only update files containing component and port info.
        '''

        status = 0
        if self.changedList or buildFilesOnly:

            if not quiet: 
                if self.changedList:
                    items = ''
                    for i in self.changedList: items += i.symbol + ', '
                    if items.endswith(', '): items = items[:-2]
                    print "Updating makefiles (for " +items + ")..."
                else: print "Updating makefiles..."
            if self.timing == 'enabled': 
                import time
                t1 = time.time()
                
                
            # Check whether project was moved since the last time it was configured.
            moved,oldpath,newpath = self.locationManager.projectMoved()
            if moved:
                print >>DEBUGSTREAM, "This project appears to have moved from " \
                    + str(oldpath) + " to " + str(newpath) +". Updating paths..."
                # Remove make.vars.common to force users to rerun configure
                if os.path.exists(os.path.join(newpath,'buildutils','make.vars.common')):
                    os.unlink(os.path.join(newpath,'buildutils','make.vars.common'))
                # update all babel generated files (basically sed oldpath to newpath)
                os.path.walk(newpath,self._fixPathsInMakefiles,arg={'oldpath':oldpath,'newpath':newpath})
    
            
            # First, detect cycles
            pgraph = Globals().getGraph(self.project.getName())
            cycles = pgraph.find_cycles()
            
            # Create Makefile.am file, order vertex list clients-first
           
            makefile_am = self._generateMakefileAm()
            makefile_am_path = os.path.join(self.project.getDir(),'Makefile.am')
            print 'Makefile.am:\n',makefile_am
            try:
                BFileManager().writeStringToFile(makefile_am_path,makefile_am)
            except IOError,e:
                err('Could not write to file ' + makefile_am_path + ': ' + str(e))
            
            # Copy user files and create makefile if they don't already exist
            if self.changedList:
                for vertex in self.changedList:
                    if vertex.kind == 'component' or vertex.kind == 'class':
                        # Genereate BOCCA/Dir-projName files if not there
                        myDir = os.path.join(self.project.getDir(),
                                             self.locationManager.getComponentLoc()[0],
                                             vertex.symbol)
                        if not os.path.exists(os.path.join(myDir,'BOCCA','Dir-' + self.project.getName())):
                            addProjectMetadirs(self.project.getName(),
                                               topDir=myDir,rootDir=self.project.getDir())
Exemplo n.º 4
0
    def prettystr(self):
        project, graph = Globals().getProjectAndGraph()
        s =  self.kind + ' ' + self.symbol + ' ' + self.version + ' (' + self._b_language + ')'
        
        if len(self._b_provides) > 0:
            s+=  '\n\tprovides ports:\n'
            for i in self._b_provides: 
                s +=  '\t  ' + i.prettystr() + '\n'
        
        if len(self._b_uses) > 0:
            s+=  '\n\tuses ports:\n'
            for i in self._b_uses: 
                s +=  '\t  ' + i.prettystr() + '\n'
                        
        if len(self._b_implements) > 0:
            s+=  '\n\timplements interfaces:\n'
            for i in self._b_implements.keys(): 
                s +=  '\t  ' + i 
                if self._b_implements[i] != '%local%': s += ', location = ' + project.getDefaultValue(i,'External')
                else: s += ', local'
                s += ' ' + '\n'

        if len(self._b_extends) > 0:
            s += '\n\textends class: ' + self._b_extends.keys()[0]                 
            if self._b_extends.values()[0] != '%local%': s += ', location = ' + project.getDefaultValue(self._b_extends.keys()[0],'External')
            else: s += ', local'
            s += ' ' + '\n'

        otherdeps = self.getAttr('requires')
        if otherdeps:
            s += '\n\tdepends on these symbols:\n\t  ' + ', '.join(otherdeps)  + '\n'    

        mysidldir, sidlfiles = project.getLocationManager().getSIDLLoc(self)
        s += '\n\tSIDL definition: ' + os.path.join(mysidldir,sidlfiles[0])
        
        myimpldir, impls = project.getLocationManager().getImplLoc(self)
        if not impls[0] or impls[0] == 'None': 
            s += '\n\timplementation:\t' + str(os.path.join(myimpldir, impls[1])) + '\n'
        else:
            files =[]
            for i in impls: files.append(os.path.join(myimpldir,i))
            s +=  '\n\timplementation:\n\t\t' + '\n\t\t'.join(files) + '\n'
            
        # Temporary for testing
        #s += "Extends hierarchy: " + str([v.symbol for v in self.walk(edgefilter=['extends'])]) + '\n'
        #s += "Implements hierarchy: " + str([v.symbol for v in self.walk(edgefilter=['implements'])]) + '\n'
 
        return s
Exemplo n.º 5
0
 def updateProjectInfo(self):
     from cct._util import Globals
     project = Globals().getProject(projectName=self.projectName)
     if project is not None: self.projectDir = project.getDir()
     pass
Exemplo n.º 6
0
    def getWriter (self, language, dialect, babelVersion='', kind = 'component'):
        ccaVars = Globals().getCCAVars()
        if len(ccaVars) == 0:
            err('[BoccaWriterFactory] could not load CCA settings from defaults file')
        if babelVersion is '': 
            # The CCASPEC_BABEL_VERSION has a timestamp instead of a version for nightly
            # tarballs, so call babel to determine version
            cmd = ccaVars['CCASPEC_BABEL_BABEL'] + ' --version'
            try:
                f = os.popen(cmd)
                lines = f.readlines()
                for l in lines:
                    cl = l.strip()
                    if cl.startswith('Babel version'): babelVersion = l.split()[-1]
            except:
                err('[BoccaWriterFactory] Could not determine Babel version')
                
        print >> DEBUGSTREAM, '[BoccaWriterFactory] Babel version is ' + str(babelVersion)
        
        # Handle nightly Babel tarballs, which don't have a regular version number
        if babelVersion.count('.') == 0:
            if 'CCASPEC_BABEL_SNAPSHOT' in ccaVars.keys():
                if ccaVars['CCASPEC_BABEL_SNAPSHOT'] == '1':
                    babelVersion = ccaVars['CCASPEC_BABEL_BRANCH']
        
        if babelVersion.count('.') == 0:
            # Sometimes the version number is in that variable, whether it's a snapshot or not
            if 'CCASPEC_BABEL_BRANCH' in ccaVars.keys():
                babelVersion = ccaVars['CCASPEC_BABEL_BRANCH']

        if babelVersion.count('.') == 0:
            err('[BoccaWriterFactory] Invalid Babel version encountered')

        for key in self.writers.keys():
            (lang, versionList, dial) = key.split(':')
            versionList = versionList.split('|')
            if (lang != language):
                continue
            if (dial != dialect):
                continue
            (major, minor, patch) = babelVersion.upper().split('.')
            matchingVer = ''
            for v in versionList:
                v_elements = v.upper().split('.')
                v_major = v_elements[0]
                v_minor='X'
                v_patch='X'
                if (len(v_elements) > 3):
                    err('Invalid supported Babel version number ' + 
                        v + ' in class ' + str(self.writers[key][0]), 2)
                if(len(v_elements) == 2):
                    v_minor = v_elements[1]
                elif (len(v_elements) == 3):
                    v_minor = v_elements[1]
                    v_patch = v_elements[2]
                match = False
                if (v_major == 'X'):
                    match = True
                    matchingVer = v
                    break
                if (v_major != major):
                    continue
                if (v_minor == 'X'):
                    match = True
                    matchingVer = v
                    break
                if (v_minor != minor):
                    continue
                if (v_patch == 'X'):
                    match = True
                    matchingVer = v
                    break
                if (v_patch != patch):
                    continue
            if (not match):
                print >> DEBUGSTREAM, 'Babel version', babelVersion , 'NOT matched by writer versions', versionList
                continue
            print >> DEBUGSTREAM, 'Babel version', babelVersion , 'is matched by writer version', matchingVer
            (classRef, classInstance) = self.writers[key]
            if (classInstance == None):
                classInstance = classRef(kind)
                self.writers[key] = (classRef, classInstance)
            classInstance.setBabelVersion(babelVersion)
            return classInstance
        err('No writer supports ' + language + ' for Babel version ' + babelVersion + ' and dialect ' + dialect, 1)