⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dependlist.py

📁 linux下的一款播放器
💻 PY
📖 第 1 页 / 共 2 页
字号:
# # ***** BEGIN LICENSE BLOCK *****# Source last modified: $Id: dependlist.py,v 1.24 2004/10/19 19:38:11 hubbe Exp $# # Portions Copyright (c) 1995-2004 RealNetworks, Inc. All Rights Reserved.# # The contents of this file, and the files included with this file,# are subject to the current version of the RealNetworks Public# Source License (the "RPSL") available at# http://www.helixcommunity.org/content/rpsl unless you have licensed# the file under the current version of the RealNetworks Community# Source License (the "RCSL") available at# http://www.helixcommunity.org/content/rcsl, in which case the RCSL# will apply. You may also obtain the license terms directly from# RealNetworks.  You may not use this file except in compliance with# the RPSL or, if you have a valid RCSL with RealNetworks applicable# to this file, the RCSL.  Please see the applicable RPSL or RCSL for# the rights, obligations and limitations governing use of the# contents of the file.# # Alternatively, the contents of this file may be used under the# terms of the GNU General Public License Version 2 or later (the# "GPL") in which case the provisions of the GPL are applicable# instead of those above. If you wish to allow use of your version of# this file only under the terms of the GPL, and not to allow others# to use your version of this file under the terms of either the RPSL# or RCSL, indicate your decision by deleting the provisions above# and replace them with the notice and other provisions required by# the GPL. If you do not delete the provisions above, a recipient may# use your version of this file under the terms of any one of the# RPSL, the RCSL or the GPL.# # This file is part of the Helix DNA Technology. RealNetworks is the# developer of the Original Code and owns the copyrights in the# portions it created.# # This file, and the files included with this file, is distributed# and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY# KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS# ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET# ENJOYMENT OR NON-INFRINGEMENT.# # Technology Compatibility Kit Test Suite(s) Location:#    http://www.helixcommunity.org/content/tck# # Contributor(s):# # ***** END LICENSE BLOCK *****# """Functions and clases for computing module dependency lists given aBIFData class."""import osimport sysimport stringimport typesimport errimport sysinfoimport bldregimport sdkclass ModuleDependancyStack:    """Given a list of module_id's, compute a stack of levels where    level n+1 depends on the modules in level n."""    def __init__(self, bif_data, module_id_list, filter_func = None):        self.bif_data = bif_data        self.doing={}        self.done={}        self.ordered_list=[]        self.filter_func=filter_func        ## resolve the module_ids with the bif_data        for module_id in module_id_list:            self.recursive_resolv_dependencies(module_id,"-")        ## Cleanup        self.done={}    def circular_dependancy_error(self, mod):        l = [ mod ]        tmp = self.doing[mod]        while mod != tmp:            l.append(tmp)            tmp = self.doing[tmp]        l.append(mod)                    e = err.Error()        import bif        e.Set("A circular module dependancy was detected in the bif "\              "file while computing the dependancy list for the target "\              "involving the following modules: %s" %              string.join(l,"->"))        raise err.error, e    def dependancy_error(self, module_id, depmodule_id):        e = err.Error()        e.Set("While computing the dependancy list for your target, "\              "module id=\"%s\" has a dependancy on module=\"%s\" which "\              "was not found in the bif file." % (module_id, depmodule_id))        raise err.error, e    def recursive_resolv_dependencies(self, module_id, last = ""):        if self.doing.has_key(module_id):            self.circular_dependancy_error(module_id)                        if self.done.has_key(module_id):            return        self.done[module_id]=1        ## lookup dependancy module; fail if it doesn't exist        try:            module = self.bif_data.module_hash[module_id]        except KeyError:            self.dependancy_error(last, module_id)        # Why compute dependencies for modules which will not be built?        #if not module.no_build_flag:        ## Check {exclude,include}{platform,profile}        if self.filter_func and not self.filter_func(module):            return        for depmod_id in module.dependancy_id_list:            self.doing[module_id]=depmod_id            self.recursive_resolv_dependencies(depmod_id, module_id)                    if len(module.dependancy_id_list):            del self.doing[module_id]                self.ordered_list.append(module)    def get_ordered_module_list(self):        return self.ordered_listclass DependList:    """Once loaded up with a BIFData class and a target list, this class    can be used to return the dependency list for the target in a number of    ways, and in a number of formats."""    def __init__(self, bif_data, target_list):        self.bif_data = bif_data        if type(target_list) == types.StringType:            self.target_list = [target_list]        elif type(target_list) == types.ListType:            self.target_list = target_list        self.defines = {}        ## This could potentially be a very very heavy calculation        ## Luckily, the normal case only takes one or two iterations        while 1:            num_defines=-1            while len(self.defines) > num_defines:                num_defines = len(self.defines)                tmp=self.target_list[:]                ## Include "always" modules                for (modid, module) in self.bif_data.module_hash.items():                    if module.attributes.get("always",None):                        tmp.append(modid)                                        self.module_list = self.compute_dependancy_list(tmp,                                                                self.chk_platform)                #                 # Propagate the static_build attribute to dependant modules                # This could be done once and for all above really...                # No error checking should be needed since all dependancies                # Have already been resolved once above. -Hubbe                #                ## This is actual dual mark-and-sweep procedure,                ## once for static propagation, and once for dynamic                ## propagation                statics = []            # A list containing all static modules                statics_done = {}       # And a hash for fast lookups                for module in self.module_list:                    if  module.build_static_flag:                        statics_done[module] = 1                        statics.append(module)                # Magic trick, we append stuff to 'statics' from inside the loop                # This way no recursion is needed. -Hubbe                for module in statics:                    for depid in module.dependancy_id_list:                        depmod = self.bif_data.module_hash[depid]                        if not statics_done.has_key(depmod) \                               and not depmod.build_dynamic_only_flag:                            statics.append(depmod)                            statics_done[depmod] = 1                dynamics = []         # A list containing all dynamic modules                dynamics_done = {}    # And a hash for fast lookups                ## All targets are built dynamically by default                for modid in self.target_list:                    module=self.bif_data.module_hash[modid]                    if not module.build_static_only_flag:                        dynamics_done[module] = 1                        dynamics.append(module)                ## All dynamic_only modules are built dynamically                for module in self.module_list:                    if module.build_dynamic_only_flag:                        dynamics_done[module] = 1                        dynamics.append(module)                # Magic trick, we append stuff to 'dynamics' from inside the loop                # This way no recursion is needed. -Hubbe                for module in dynamics:                    for depid in module.dependancy_id_list:                        depmod = self.bif_data.module_hash[depid]                        if not dynamics_done.has_key(depmod) \                               and not depmod.build_static_only_flag:                            dynamics.append(depmod)                            dynamics_done[depmod] = 1                for module in self.module_list:                    if statics_done.get(module):                        if dynamics_done.get(module):                            module.set_build_static()                        else:                            module.set_build_static_only()                ## Read all defines in these modules                ## If new defines are found since last iteration, start from top                ## This could be really really really slow if we're unlucky.                self.defines = {}                for module in self.module_list:                    for d in module.defines.keys():                        self.defines[d]=module.defines[d]                # Find any source_dependancies which are not already                # in the list of modules and mark them as nobuild and                # add them to the list of modules.                modules_done = {}                for module in self.module_list:                    modules_done[module]=1                    module.source_dep_only=0                    module.checkin_dep_only=0                ## Source dependencies do *not* add defines                ## Same for checkout dependencies                for module in self.module_list:                    if module.checkin_dep_only:                        continue                                        for sourcedep in module.source_dependancy_id_list:                        sdep_module = self.bif_data.module_hash[sourcedep]                        if not modules_done.has_key(sdep_module):                            sdep_module.source_dep_only = 1                            self.module_list.append(sdep_module)                            modules_done[sdep_module]=1                    if module.source_dep_only:                        continue                                        for cidep in module.checkin_dependancy_id_list:                        cidep_module = self.bif_data.module_hash[cidep]                        if not modules_done.has_key(cidep_module):                            cidep_module.checkin_dep_only = 1                            cidep_module.source_dep_only = 1                            self.module_list.append(cidep_module)                            modules_done[cidep_module]=1                                    ## Check for missing SDKs, if additional            ## dependencies were added, iterate again            if not self.check_sdks_pass1():                break            #print "SDK DEP ADDED, GO FISH!!! (%d)" % len(self.module_list)        ## Now that we have figured out all dependencies        ## we can do the required modifications        bldreg.set_value("build","defines",self.defines)        for module in self.module_list:            if module.source_dep_only:                module.no_build_flag=1        self.check_sdks_pass2()    def check_sdk_platform(self, sdk):        return sdk.check_platform(sysinfo.platform)    def sdk_iterator(self, modules, fun, *args):        """Call 'func' for every undefined SDK in 'modules'"""        #print "sdk_iterator: %s" % repr(fun)        for module in modules:            if not self.chk_platform(module):                continue            if module.checkin_dep_only:                continue            for s in module.sdks:                if not self.check_sdk_platform(s):                    continue                if sdk.GetPath(s.name):                    continue                #print "FOO %s %s\n" % (repr(fun),repr(args))                ret=apply( fun, (module, s) + args)                if ret:                    return ret        return 0    def mark_sdk_iter(self, module, s, sdktmp):        """Create a hash which maps sdk names to their definition,        the hash will contain zeroes for SDKs which are required but        not yet defined"""                if sdktmp.has_key(s.name) and sdktmp[s.name]:            return        sdktmp[s.name]=0        if not s.path:            return        if not os.path.exists(s.path):            if module.type not in  [module.MODULE_CVS,                                    module.MODULE_DISTRIBUTION]:                return            if module.name != s.path[:len(module.name)]:                return        if s.ifexists and not os.path.exists(s.ifexists):            return        sdktmp[s.name]=s.path        #print "SDK %s = %s" % (s.name, s.path)    def find_sdk_module_iter(self, module, s, sdk_name, name_only = 0):        """Iterator which finds a module which defined a previously        undefined SDK"""        if name_only and module.type != module.MODULE_NAME_ONLY:            return 0                tmp={}        self.mark_sdk_iter(module, s, tmp)                if tmp.has_key(sdk_name) and tmp[sdk_name]:            return module.id            def add_sdk_dependencies_iter(self, module, s, sdktmp):        """Go through all undefined SDKS and try to define them"""

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -