📄 rztbld.py
字号:
# # ***** BEGIN LICENSE BLOCK *****# Source last modified: $Id: rztbld.py,v 1.9 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 *****# """Consumer installer helper functions. This is not part of the DSG Umakesystem, but was put here so long ago it couldn't be moved."""import osimport stringimport structimport ascriptimport sysinfotemp_dir_name = 'temp'product_distcode = ''product_executable = ''mac_path_translation_table = string.maketrans('\\', ':')unix_path_translation_table = string.maketrans('\\', '/')g_rzt_apple_script = Noneg_compression_type = ''g_product_name = ''g_rebasedirs = ' *.dll 'pnpkg_path=Nonedistcode_files = []def Initialize(platform, project): if project.module_dir == '' or project.module_dir == ':': project.module_dir = project.target_name if sysinfo.host_type == 'mac': project.src_root_path = os.environ['SOURCE_ROOT'] if (project.build_choices.count('release') > 0): debug_release = 'release' else: debug_release = 'debug' project.target_dir = os.path.join(project.src_root_path, debug_release) if sysinfo.host_type == 'mac': global g_rzt_apple_script g_rzt_apple_script = ascript.CreateAppleScript() ASMakefile_VerifyPath(g_rzt_apple_script) g_rzt_apple_script.Append('on all()') g_rzt_apple_script.Append( 'verifypath("%s")' % (project.target_dir)) # Copy pncrt*.dll which is needed for pnpkg.exe on win32 if sysinfo.host_type == 'win32': if project.IsDefined("HELIX_CONFIG_RN_CRT"): project.writeln('\t' + platform.mkdir.execute(project.target_dir)) pncrt_path = os.path.join(os.pardir, 'pncrt') if (project.build_choices.count('release') > 0): pncrt_path = os.path.join(pncrt_path, 'pncrt.dll') else: pncrt_path = os.path.join(pncrt_path, 'pncrtd.dll') project.writeln('\t' + platform.copy.cmd + ' ' + pncrt_path + ' ' + project.target_dir) pnpkg_path = os.path.join(os.pardir, 'pnpkg', project.output_dir) project.writeln('\t' + platform.copy.cmd + ' ' + pnpkg_path + ' ' + project.target_dir)def ASMakefile_VerifyPath(script): script.Append( '-- VerifyPath creates the path up to the specified folder if it doesnt already exist', '-- example usage: VerifyPath("Hard Disk:A:B") where B is the target folder that should exist', 'on VerifyPath(thePath)', ' -- first save the old text item delimiter and use ":" as the text item delimiter', ' set savedTextItemDelimiters to AppleScript\'s text item delimiters', ' set AppleScript\'s text item delimiters to ":"', ' ', ' set numPathItems to (count of text items of thePath)', ' if numPathItems > 1 then', ' set previousPartialPath to text item 1 of thePath -- previous path starts as the disk name', ' repeat with n from 2 to numPathItems', ' -- make a partial path through the nth item', ' set partialPath to (text items 1 through n of thePath) as string', ' tell application "Finder"', ' if not (exists (folder partialPath)) then', ' if n is 2 then', ' make new folder at disk previousPartialPath with properties {name:(text item n of thePath)}', ' else', ' make new folder at folder previousPartialPath with properties {name:(text item n of thePath)}', ' end if', ' end if', ' end tell', ' set previousPartialPath to partialPath', ' end repeat', 'end if', ' -- restore the text item delimiter', ' set AppleScript\'s text item delimiters to savedTextItemDelimiters', 'end VerifyPath' )def CreateProductHeader(header_name, product_name, main_component): global g_product_name g_product_name = product_name file = open(header_name + '.hdr', 'w') file.write('PRODUCT ' + product_name + '|' + main_component[0] + '\n') file.close()def AddHeader(platform, project, header_name, component, add_options): specfile_path = os.path.join(project.src_root_path, component[2]) verfile_path = os.path.join(project.src_root_path, component[1]) if platform.type == 'unix': verfile_path = string.translate(verfile_path, unix_path_translation_table) specfile_path = string.translate(specfile_path, unix_path_translation_table) if (platform.type == 'unix'): index = string.rfind(specfile_path, '/') else: index = string.rfind(specfile_path, '\\') specfile_name = specfile_path[index+1:] if sysinfo.host_type == 'mac': verfile_path = string.translate(verfile_path, mac_path_translation_table) specfile_path = string.translate(specfile_path, mac_path_translation_table) out_file = open(header_name + '.hdr', add_options) in_file = open(verfile_path, 'r') try: lines = in_file.readlines() except: raise VersionError, 'Error opening ' + verfile_path for line in lines: if string.find(line, '#define TARVER_STRING_VERSION') == 0: index = string.find(line, '"') line = line[ index + 1 : ] index = string.find(line, '"') line = line[ : index ] out_file.write('COMPONENT ' + component[0] + '|' + line + '|' + specfile_name + '\n') out_file.close() in_file.close() if project.target_name != project.module_dir: specfile_name = specfile_name + '_' + project.target_name out_file = open(specfile_name, 'w') in_file = open(specfile_path, 'r') try: lines = in_file.readlines() except: raise VersionError, 'Error opening ' + specfile_path for line in lines: ## Exclude other platform's commands include_line = 1 if (string.find(line, '#') == 0): include_line = 0 ## determine whether this line should be included for the current platform line = line[ 1 : ] index = string.find(line, '#') platforms_string = line[ 0 : index ] platforms_string = string.split(platforms_string) for platform_name in platforms_string: if platform_name == platform.name or platform_name == platform.type: include_line = 1 break ## strip the platform info from line line = line[ index + 1 : ] line = string.lstrip(line) if (include_line == 1): output_line = '' ## Insert platform specific dll names index = string.find(line, 'dll_name(') while index != -1: output_line = output_line + line[ : index ] line = line[ index + 9 : ] index = string.find(line, ')') platform.versioning.version = '' output_line = output_line + platform.versioning.create_dll_name(line[ : index ], line[ : index ]) platform.versioning.version = '' line = line[ index + 1 : ] index = string.find(line, 'dll_name(') output_line = output_line + line out_file.write(output_line) out_file.close() in_file.close()codewarrior_gone = Nonedef Cleanup(platform, project): ## CLEANUP TEMP if sysinfo.host_type == 'win32' or platform.name == 'win16': project.writeln('\trm -f -r ' + temp_dir_name) ## Remove installer executable installer_exe = os.path.join(project.src_root_path, "setshell") installer_exe = os.path.join(installer_exe, project.output_dir + 's') installer_exe = os.path.join(installer_exe, "setup.exe") project.writeln('\trm -f ' + installer_exe) elif platform.type == 'unix': project.writeln('\trm -f -r ' + temp_dir_name) elif sysinfo.host_type == 'mac': temp_dir = os.path.join(project.src_root_path, project.module_dir) temp_dir = os.path.join(temp_dir, temp_dir_name) global g_rzt_apple_script ## We need to exit CodeWarrior, or we may not be able ## To successfully empty the trash. global codewarrior_gone if not codewarrior_gone: g_rzt_apple_script.Append( 'tell application %s to quit' % os.environ["BUILD_SW"]) codewarrior_gone=1 g_rzt_apple_script.Append( 'tell application "Finder"', ' with timeout of 900 seconds', ' if folder "%s" exists then' % (temp_dir), ' delete folder "%s"' % (temp_dir), ' set result to ""', ' end if', ' end timeout', 'end tell' )def AddComponent(platform, project, component, dirs, files, dlls): temp_dir = os.path.join(project.src_root_path, project.module_dir) copydir = temp_dir temp_dir = os.path.join(temp_dir, temp_dir_name) ## Create directories for files to copy if sysinfo.host_type == 'mac': global g_rzt_apple_script g_rzt_apple_script.Append( 'verifypath("%s")' % (temp_dir)) else: project.writeln('\t' + platform.mkdir.execute(temp_dir_name)) for dir in dirs: if sysinfo.host_type == 'mac': global g_rzt_apple_script g_rzt_apple_script.Append( 'verifypath("%s")' % (os.path.join(temp_dir, dir))) else: project.writeln('\t' + platform.mkdir.execute(os.path.join(temp_dir_name, dir))) AddRebaseDirectory(dir) str_copycommand = '\t' + platform.copy.cmd + ' ' if (platform.name == 'win16'):
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -