| OLD | NEW |
| (Empty) |
| 1 #!/usr/bin/python | |
| 2 | |
| 3 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
| 4 # Use of this source code is governed by a BSD-style license that can be | |
| 5 # found in the LICENSE file. | |
| 6 | |
| 7 import glob | |
| 8 import optparse | |
| 9 import os | |
| 10 import shutil | |
| 11 import sys | |
| 12 import utils | |
| 13 | |
| 14 HOST_OS = utils.guessOS() | |
| 15 | |
| 16 if HOST_OS == 'mac': | |
| 17 CONTENTSHELL_FILES = ['Content Shell.app', 'ffmpegsumo.so', 'osmesa.so', | |
| 18 'lib'] | |
| 19 CHROMEDRIVER_FILES = ['chromedriver'] | |
| 20 elif HOST_OS == 'linux': | |
| 21 CONTENTSHELL_FILES = ['content_shell', 'content_shell.pak', 'fonts.conf', | |
| 22 'libblink_test_plugin.so', 'libffmpegsumo.so', | |
| 23 'libosmesa.so', 'lib', 'icudtl.dat', 'AHEM____.TTF', | |
| 24 'GardinerModBug.ttf', 'GardinerModCat.ttf', | |
| 25 'natives_blob.bin'] | |
| 26 CHROMEDRIVER_FILES = ['chromedriver'] | |
| 27 elif HOST_OS == 'win': | |
| 28 # TODO: provide proper list. | |
| 29 CONTENTSHELL_FILES = ['content_shell.exe', 'AHEM____.ttf', 'icudtl.dat', ] | |
| 30 CHROMEDRIVER_FILES = ['chromedriver.exe'] | |
| 31 else: | |
| 32 raise Exception('Unsupported platform') | |
| 33 | |
| 34 # Append a file with size of the snapshot. | |
| 35 CONTENTSHELL_FILES.append('snapshot-size.txt') | |
| 36 | |
| 37 | |
| 38 def GenerateDartiumFileList(mode, srcpath): | |
| 39 def blacklisted(name): | |
| 40 # We include everything if this is a debug build. | |
| 41 if mode.lower() == 'debug': | |
| 42 return True | |
| 43 else: | |
| 44 # We don't include .debug/.pdb files if this is a release build. | |
| 45 if name.endswith('.debug') or name.endswith('.pdb'): | |
| 46 return False | |
| 47 return True | |
| 48 | |
| 49 configFile = os.path.join(srcpath, 'chrome', 'tools', 'build', HOST_OS, | |
| 50 'FILES.cfg') | |
| 51 configNamespace = {} | |
| 52 execfile(configFile, configNamespace) | |
| 53 fileList = [file['filename'] for file in configNamespace['FILES']] | |
| 54 | |
| 55 # The debug version of dartium on our bots build with | |
| 56 # 'component=shared_library', so we need to include all libraries | |
| 57 # (i.e. 'lib/*.so) as we do on the CONTENTSHELL_FILES list above. | |
| 58 if HOST_OS == 'linux' and mode.lower() == 'debug': | |
| 59 fileList.append('lib') | |
| 60 | |
| 61 # Filter out files we've blacklisted and don't want to include. | |
| 62 fileList = filter(blacklisted, fileList) | |
| 63 return fileList | |
| 64 | |
| 65 | |
| 66 def GenerateContentShellFileList(srcpath): | |
| 67 return CONTENTSHELL_FILES | |
| 68 | |
| 69 | |
| 70 def GenerateChromeDriverFileList(srcpath): | |
| 71 return CHROMEDRIVER_FILES | |
| 72 | |
| 73 | |
| 74 def ZipDir(zipFile, directory): | |
| 75 if HOST_OS == 'win': | |
| 76 cmd = os.path.normpath(os.path.join( | |
| 77 os.path.dirname(__file__), | |
| 78 '../../../third_party/lzma_sdk/Executable/7za.exe')) | |
| 79 options = ['a', '-r', '-tzip'] | |
| 80 else: | |
| 81 cmd = 'zip' | |
| 82 options = ['-yr'] | |
| 83 utils.runCommand([cmd] + options + [zipFile, directory]) | |
| 84 | |
| 85 | |
| 86 def GenerateZipFile(zipFile, stageDir, fileList): | |
| 87 # Stage files. | |
| 88 for fileName in fileList: | |
| 89 fileName = fileName.rstrip(os.linesep) | |
| 90 targetName = os.path.join(stageDir, fileName) | |
| 91 try: | |
| 92 targetDir = os.path.dirname(targetName) | |
| 93 if not os.path.exists(targetDir): | |
| 94 os.makedirs(targetDir) | |
| 95 if os.path.isdir(fileName): | |
| 96 # TODO: This is a hack to handle duplicates on the fileList of the | |
| 97 # form: [ 'lib/foo.so', 'lib' ] | |
| 98 if os.path.exists(targetName) and os.path.isdir(targetName): | |
| 99 shutil.rmtree(targetName) | |
| 100 shutil.copytree(fileName, targetName) | |
| 101 elif os.path.exists(fileName): | |
| 102 shutil.copy2(fileName, targetName) | |
| 103 except: | |
| 104 import traceback | |
| 105 print 'Troubles processing %s [cwd=%s]: %s' % (fileName, os.getcwd(), trac
eback.format_exc()) | |
| 106 | |
| 107 ZipDir(zipFile, stageDir) | |
| 108 | |
| 109 | |
| 110 def StageAndZip(fileList, target): | |
| 111 if not target: | |
| 112 return None | |
| 113 | |
| 114 stageDir = target | |
| 115 zipFile = stageDir + '.zip' | |
| 116 | |
| 117 # Cleanup old files. | |
| 118 if os.path.exists(stageDir): | |
| 119 shutil.rmtree(stageDir) | |
| 120 os.mkdir(stageDir) | |
| 121 revision = target.split('-')[-1] | |
| 122 oldFiles = glob.glob(target.replace(revision, '*.zip')) | |
| 123 for oldFile in oldFiles: | |
| 124 os.remove(oldFile) | |
| 125 | |
| 126 GenerateZipFile(zipFile, stageDir, fileList) | |
| 127 print 'last change: %s' % (zipFile) | |
| 128 | |
| 129 # Clean up. Buildbot disk space is limited. | |
| 130 shutil.rmtree(stageDir) | |
| 131 | |
| 132 return zipFile | |
| 133 | |
| 134 | |
| 135 def Archive(srcpath, mode, dartium_target, contentshell_target, | |
| 136 chromedriver_target): | |
| 137 # We currently build using ninja on mac debug. | |
| 138 if HOST_OS == 'mac': | |
| 139 releaseDir = os.path.join(srcpath, 'out', mode) | |
| 140 # Also package dynamic libraries. | |
| 141 extra_files = [file for file in os.listdir(releaseDir) if file.endswith('.dy
lib')] | |
| 142 elif HOST_OS == 'linux': | |
| 143 releaseDir = os.path.join(srcpath, 'out', mode) | |
| 144 extra_files = [] | |
| 145 elif HOST_OS == 'win': | |
| 146 releaseDir = os.path.join(srcpath, 'out', mode) | |
| 147 # issue(16760) - we _need_ to fix our parsing of the FILES.cfg | |
| 148 extra_files = [file for file in os.listdir(releaseDir) if file.endswith('man
ifest')] | |
| 149 else: | |
| 150 raise Exception('Unsupported platform') | |
| 151 os.chdir(releaseDir) | |
| 152 | |
| 153 dartium_zip = StageAndZip( | |
| 154 GenerateDartiumFileList(mode, srcpath) + extra_files, dartium_target) | |
| 155 contentshell_zip = StageAndZip(GenerateContentShellFileList(srcpath) + extra_f
iles, | |
| 156 contentshell_target) | |
| 157 chromedriver_zip = StageAndZip(GenerateChromeDriverFileList(srcpath) + extra_f
iles, | |
| 158 chromedriver_target) | |
| 159 return (dartium_zip, contentshell_zip, chromedriver_zip) | |
| 160 | |
| 161 | |
| 162 def main(): | |
| 163 pathname = os.path.dirname(sys.argv[0]) | |
| 164 fullpath = os.path.abspath(pathname) | |
| 165 srcpath = os.path.join(fullpath, '..', '..', '..') | |
| 166 | |
| 167 parser = optparse.OptionParser() | |
| 168 parser.add_option('--dartium', dest='dartium', | |
| 169 action='store', type='string', | |
| 170 help='dartium archive name') | |
| 171 parser.add_option('--contentshell', dest='contentshell', | |
| 172 action='store', type='string', | |
| 173 help='content shell archive name') | |
| 174 parser.add_option('--chromedriver', dest='chromedriver', | |
| 175 action='store', type='string', | |
| 176 help='chromedriver archive name') | |
| 177 parser.add_option('--mode', dest='mode', | |
| 178 default='Release', | |
| 179 action='store', type='string', | |
| 180 help='(Release|Debug)') | |
| 181 (options, args) = parser.parse_args() | |
| 182 Archive(srcpath, options.mode, options.dartium, options.contentshell, | |
| 183 options.chromedriver) | |
| 184 return 0 | |
| 185 | |
| 186 | |
| 187 if __name__ == '__main__': | |
| 188 sys.exit(main()) | |
| OLD | NEW |