Example #1
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())