📄 macuber.py
字号:
# # ***** BEGIN LICENSE BLOCK *****# Source last modified: $Id: macuber.py,v 1.2 2004/07/07 22:00:04 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 *****# import ascriptimport osimport outmsgimport stringimport globdef generate_uberxml(build_list, module_id_build_dict, uberxml_output_name, uber_dir): tag1 = '#TARGET#' tag2 = '#TARGETORDER#' tag3 = '#GROUP#' tag4 = '#MAKE_ALL_SUBTARGETS#' dependencies_section_empty = '<SUBTARGETLIST></SUBTARGETLIST>' uber_template = GetUberTemplate() old_dir = os.getcwd() # make a list of the module names we're building; we'll exclude # any dependencies that are not in the list modules_built_id_list = [ x.id for x in build_list ] # scoop up the uber text from each directory, add the depend success_list = [] failure_list = [] module_targetname_dict = {} # by module.id's, the names of the targets built by this module all_module_targetnames_list = [] for module in build_list: # outmsg.send("module id: %s" % ( module.id )) # outmsg.send("modules_dependancy_id_list: %s" % ( string.join(module.dependancy_id_list, ','))) # outmsg.send("module_build_list: %s" % ( string.join( [x for x in module_id_build_dict[module.id]] , ','))) # move to the module's project_xml directory module_dir = os.path.join(old_dir, module.name) project_xml_dir = os.path.join(module_dir, "project_xml") if not os.path.isdir(project_xml_dir): outmsg.send("No project_xml directory found for module %s" % (module.name)) failure_list = failure_list + [module.name] continue os.chdir(project_xml_dir) # find all uber files we need to incorporate uber_file_names = glob.glob("*_uber.xml") if (len(uber_file_names) < 1): outmsg.send("No uber xml found for module %s" % (module.name)) failure_list = failure_list + [module.name] for uber_file_name in uber_file_names: # outmsg.send("Extracting uber-project XML from %s for module %s" % (uber_file_name, module.name)) # switch to the module directory and read in the module's uber XML data try: uber_file = open(uber_file_name, 'r') uber_text = uber_file.read() uber_file.close() except: outmsg.send("==> Cannot read from %s for module %s" % (uber_file_name, module.name)) continue success_list = success_list + [module.name] try: (uber_target_name, uber_text_1, uber_text_2, uber_text_3, uber_output_path) = string.split(uber_text, "<<>>") except: outmsg.send("==> Cannot parse %s from module %s for <<>> sections" % (uber_file_name, module.name)) continue uber_target_name = string.strip(uber_target_name) # store the target name or names for this module for later use if not module_targetname_dict.has_key(module.id): module_targetname_dict[module.id] = [] module_targetname_dict[module.id] = module_targetname_dict[module.id] + [uber_target_name] # also add this as a subtarget for the Make All target all_module_targetnames_list.append(uber_target_name) # now we look for the <SUBTARGETLIST></SUBTARGETLIST> in the target section of the # module's XML, and replace it with a list of all actual dependencies # make a list containing a targetname section for each dependency (only for # dependencies built, to avoid things like include) # unfortunately, module.dependancy_id_list only has the modules listed in the bif, # which could include name_only targets that are not really built # our subtarget list is the subtarget names for the build list for this modules, # but only the ones actually built and not this one subtarget_list = [] for subtarget_module in module_id_build_dict[module.id]: if (subtarget_module in modules_built_id_list) and (subtarget_module != module.id): if module_targetname_dict.has_key(subtarget_module): subtarget_list = subtarget_list + module_targetname_dict[subtarget_module] else: subtarget_list = subtarget_list + [subtarget_module] outmsg.send("Subtarget_module name not found: %s" % (subtarget_module)) # outmsg.send(" actual subtarget_list: %s" % ( string.join(subtarget_list, ','))) dependencies_section_xml = MakeDependenciesSubtargetListXML(subtarget_list) # make a subtarget list containing our dependencies list, and replace the empty one # in the template with ours uber_text_1 = string.replace(uber_text_1, dependencies_section_empty, dependencies_section_xml, 1) # if an empty subtarget list is left in the template, remove it uber_text_1 = string.replace(uber_text_1, dependencies_section_empty, "", 1) # finally, follow the target, targetorder, and group placeholders in the top level # template with the data for this module template1 = string.replace(uber_template, tag1, tag1 + '\n' + uber_text_1, 1) template2 = string.replace(template1, tag2, tag2 + '\n' + uber_text_2, 1)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -