📄 module.py
字号:
# # ***** BEGIN LICENSE BLOCK *****# Source last modified: $Id: module.py,v 1.21 2004/11/06 01:53:29 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 *****# """Implements the Module class, storing data for module entries in *.biffiles. A module has a id, name, and directory; these can all be the sameor all different depending on the module, so it is important to understandthem here.module id:A absolutely unique identifier defined within the BIF file to referencethis module for its dependancies.module name:The CVS name of the module, used to checkout and update the module.module directory_list:The list of directorioes the module will checkout to; this can be differentthan the module name if we are using module aliasing, or it can be a wholelist of things if multiple top-level directories are stored in a distributionarchive."""import sysimport stringimport errimport osimport sysinfoclass SDK: def __init__(self, name, path, error_message = "", system_id = None, ifexists = None): self.name=name self.path=path self.error_message=error_message self.system_id=system_id self.ifexists=ifexists def check_platform(self, sysid=None): ## Check the for=... if not self.system_id: return 1 if not sysid: if fnmatch.fnmatch(sysinfo.id, self.system_id): return 1 for l in sysinfo.family_list: if fnmatch.fnmatch(l, s.system_id): return 1 else: if fnmatch.fnmatch(sysid, self.system_id): return 1 for l in sysinfo.PLATFORM_HASH.get(sysid).family_list: if fnmatch.fnmatch(l, s.system_id): return 1 return 0 def write(self): ret = ' <sdk name="%s"' % self.name if self.system_id: ret=ret+' for="%s"' % self.system_id if self.ifexists: ret=ret+' ifexists="%s"' % self.ifexists if self.path: ret=ret+' path="%s"' % self.path if self.error_message: ret=ret+">" for m in string.split(self.error_message,"\n"): ret=ret+"\n %s" % m ret=ret+" </sdk>" else: ret=ret+"/>" return retclass Module: """Data associated with one module entry defined in the *.bif files.""" ## types of modules MODULE_CVS = "cvs" MODULE_NAME_ONLY = "name_only" MODULE_DISTRIBUTION = "distribution" MODULE_INSTALLER = "installer" MODULE_PROFILE = "profile" module_type_list = [ MODULE_CVS, MODULE_NAME_ONLY, MODULE_DISTRIBUTION, MODULE_INSTALLER, MODULE_PROFILE ] def __init__(self, id, name = None, filename = None, line_number = None): # unique ID of module self.id = string.strip(id) # name of module if name: self.name = string.strip(name) else: self.name = self.id self.filename = filename self.line_number = line_number self.bif_version = 100 self.default_profile = None self.default_options = None ## REQUIRED SANITY CHECKS self.__name_check() ## default module type is CVS self.type = self.MODULE_CVS ## group this module belongs to self.group = '' ## english description of module self.description = '' ## list containing the id of dependancy modules ## listed in the information file self.dependancy_id_list = [] ## list containing the id of source dependancy modules ## listed in the information file self.source_dependancy_id_list = [] ## list containing the id of checkin dependancy modules ## listed in the information file self.checkin_dependancy_id_list = [] ## list containing the names of platform types to ## exclusively build this module under self.platform_include_list = [] ## list containing the names of platform types to ## NOT build this module under self.platform_exclude_list = [] ## list containing the names of profile types to ## exclusively build this module under self.profile_include_list = [] ## list containing the names of profile types to ## NOT build this module under self.profile_exclude_list = [] ## list containing the names of defines to ## exclusively build this module under self.define_include_list = [] ## list containing the names of defines to ## NOT build this module under self.define_exclude_list = [] ## Umake prefix files self.umake_includefiles = [] ## flags self.define_include_list_flag = 0 self.define_exclude_list_flag = 0 self.platform_include_list_flag = 0 self.platform_exclude_list_flag = 0 self.profile_include_list_flag = 0 self.profile_exclude_list_flag = 0 self.build_static_flag = 0 self.build_static_only_flag = 0 self.build_dynamic_only_flag = 0 self.build_number_flag = 0 self.version_file_flag = 0 self.update_platform_header_flag= 0 self.no_build_flag = 0 self.cvs_tag_flag = 0 self.cvs_date_flag = 0 self.installer_flag = 0 ## attributes self.attributes = {} ## cvs tag specified for this module self.cvs_tag = '' self.cvs_tag_type = 'branch' self.cvs_root = '' self.cvs_date = '' self.cvs_path = None ## halt priority, default to green self.halt_priority = "green" ## Checkout error message self.error_message='' ## Required SDKs self.sdks = [] ## Defines self.defines = {} ## This means this module is only needed when checking in code ## with -tdistribute self.checkin_dep_only=0 def __name_check(self): """Check the module.name value for invalid charactors.""" for sep in [ '\\', ':', ' ', '#']: if sep in self.name or sep in self.id: e = err.Error() e.Set("The module id=\"%s\" with name=\"%s\" in the bif "\ "file has the illegal charactor=\"%s\" in it." % ( self.id, self.name, sep)) raise err.error, e def set_type(self, type): """Set the module type. This is usually: cvs(default), or distribution.""" if type not in self.module_type_list: e = err.Error() e.Set("The module id=\"%s\" in the bif file is set to a "\ "unknown type=\"%s\"." % (self.id, type)) raise err.error, e self.type = type def location(self): if self.filename and self.line_number != None: return "%s:%d" % (self.filename, self.line_number) return "-" def desc(self): return "%s(%s)" % (self.id, self.location()) def set_group(self, group): """Set the company group field the module belongs to.""" self.group = group def set_description(self, attribute_string): """Set the text description of the module.""" self.description = string.strip(attribute_string) def set_halt_priority(self, priority): if priority not in ["red", "yellow", "green"]: e = err.Error() e.Set("The module id=\"%s\" with name=\"%s\" in the bif "\ "file has a incorrect halt_priority setting=\"%s\"." % ( self.id, self.name, priority)) raise err.error, e self.halt_priority = priority def set_dependancy_id_list(self, attribute_string): """Given a space-seperated string of dependent module ids, split it up and add each to the dependancy_id_list.""" attribute_string = string.strip(attribute_string) for item in string.split(attribute_string): if item != '': self.dependancy_id_list.append(string.strip(item)) def set_source_dependancy_id_list(self, attribute_string): """Given a space-seperated string of dependent module ids, split it up and add each to the dependancy_id_list.""" attribute_string = string.strip(attribute_string) for item in string.split(attribute_string): if item != '': self.source_dependancy_id_list.append(string.strip(item)) def set_checkin_dependancy_id_list(self, attribute_string): """Given a space-seperated string of dependent module ids, split it up and add each to the dependancy_id_list.""" attribute_string = string.strip(attribute_string) for item in string.split(attribute_string): if item != '': self.checkin_dependancy_id_list.append(string.strip(item)) def set_platform_include_list(self, attribute_string): """Given a space-seperated sting of platforms for this module to be included on, split it up and add each to the platform_include_list, and set the platform_include_list_flag to true.""" self.platform_include_list_flag = 1 attribute_string = string.strip(attribute_string) for item in string.split(attribute_string): if item != '': self.platform_include_list.append(string.strip(item)) def set_platform_exclude_list(self, attribute_string): """Same as set_platform_include_list, but for the platform_exclude_list.""" self.platform_exclude_list_flag = 1 attribute_string = string.strip(attribute_string) for item in string.split(attribute_string): if item != '': self.platform_exclude_list.append(string.strip(item)) def set_profile_include_list(self, attribute_string): """Given a space-seperated sting of profiles for this module to be included on, split it up and add each to the profile_include_list, and set the profile_include_list_flag to true.""" self.profile_include_list_flag = 1 attribute_string = string.strip(attribute_string) for item in string.split(attribute_string): if item != '': self.profile_include_list.append(string.strip(item)) def set_profile_exclude_list(self, attribute_string): """Same as set_profile_include_list, but for the profile_exclude_list.""" self.profile_exclude_list_flag = 1 attribute_string = string.strip(attribute_string) for item in string.split(attribute_string): if item != '': self.profile_exclude_list.append(string.strip(item)) def set_define_include_list(self, attribute_string): """Given a space-seperated sting of defines for this module to be included on, split it up and add each to the define_include_list, and set the define_include_list_flag to true.""" self.define_include_list_flag = 1 attribute_string = string.strip(attribute_string) for item in string.split(attribute_string): if item != '': self.define_include_list.append(string.strip(item)) def set_define_exclude_list(self, attribute_string): """Same as set_define_include_list, but for the define_exclude_list.""" self.define_exclude_list_flag = 1 attribute_string = string.strip(attribute_string) for item in string.split(attribute_string):
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -