Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Side by Side Diff: tools/clang/scripts/package.py

Issue 2709613004: upload clang pdbs to chrome's symbol server (Closed)
Patch Set: comments Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | tools/clang/scripts/update.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2015 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2015 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """This script will check out llvm and clang, and then package the results up 6 """This script will check out llvm and clang, and then package the results up
7 to a tgz file.""" 7 to a tgz file."""
8 8
9 import argparse 9 import argparse
10 import fnmatch 10 import fnmatch
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 # so -n option to gsutil is used. It will warn, if the upload was aborted. 97 # so -n option to gsutil is used. It will warn, if the upload was aborted.
98 gsutil_args = ['cp', '-n', '-a', 'public-read', 98 gsutil_args = ['cp', '-n', '-a', 'public-read',
99 '%s.tgz' % archive_name, 99 '%s.tgz' % archive_name,
100 'gs://chromium-browser-clang-staging/%s/%s.tgz' % 100 'gs://chromium-browser-clang-staging/%s/%s.tgz' %
101 (platform, archive_name)] 101 (platform, archive_name)]
102 if args.upload: 102 if args.upload:
103 print 'Uploading %s to Google Cloud Storage...' % archive_name 103 print 'Uploading %s to Google Cloud Storage...' % archive_name
104 exit_code = RunGsutil(gsutil_args) 104 exit_code = RunGsutil(gsutil_args)
105 if exit_code != 0: 105 if exit_code != 0:
106 print "gsutil failed, exit_code: %s" % exit_code 106 print "gsutil failed, exit_code: %s" % exit_code
107 os.exit(exit_code) 107 sys.exit(exit_code)
108 else: 108 else:
109 print 'To upload, run:' 109 print 'To upload, run:'
110 print ('gsutil %s' % ' '.join(gsutil_args)) 110 print ('gsutil %s' % ' '.join(gsutil_args))
111 111
112 112
113 def UploadPDBToSymbolServer():
114 assert sys.platform == 'win32'
115 # Upload PDB and binary to the symbol server on Windows. Put them into the
116 # chromium-browser-symsrv bucket, since chrome devs have that in their
117 # _NT_SYMBOL_PATH already. Executable and PDB must be at paths following a
118 # certain pattern for the Microsoft debuggers to be able to load them.
119 # Executable:
120 # chromium-browser-symsrv/clang-cl.exe/ABCDEFAB01234/clang-cl.ex_
121 # ABCDEFAB is the executable's timestamp in %08X format, 01234 is the
122 # executable's image size in %x format. tools/symsrc/img_fingerprint.py
123 # can compute this ABCDEFAB01234 string for us, so use that.
124 # The .ex_ instead of .exe at the end means that the file is compressed.
125 # PDB:
126 # gs://chromium-browser-symsrv/clang-cl.exe.pdb/AABBCCDD/clang-cl.dll.pd_
127 # AABBCCDD here is computed from the output of
128 # dumpbin /all mybinary.exe | find "Format: RSDS"
129 # but tools/symsrc/pdb_fingerprint_from_img.py can compute it already, so
130 # again just use that.
131 sys.path.insert(0, os.path.join(CHROMIUM_DIR, 'tools', 'symsrc'))
132 import img_fingerprint, pdb_fingerprint_from_img
133
134 binaries = [ 'bin/clang-cl.exe', 'bin/lld-link.exe' ]
135 for binary_path in binaries:
136 binary_path = os.path.join(LLVM_RELEASE_DIR, binary_path)
137 binary_id = img_fingerprint.GetImgFingerprint(binary_path)
138 (pdb_id, pdb_path) = pdb_fingerprint_from_img.GetPDBInfoFromImg(binary_path)
139
140 # The build process builds clang.exe and then copies it to clang-cl.exe
141 # (both are the same binary and they behave differently on what their
142 # filename is). Hence, the pdb is at clang.pdb, not at clang-cl.pdb.
143 # Likewise, lld-link.exe's PDB file is called lld.pdb.
144
145 # Compress and upload.
146 for f, f_id in ((binary_path, binary_id), (pdb_path, pdb_id)):
147 subprocess.check_call(
148 ['makecab', '/D', 'CompressionType=LZX', '/D', 'CompressionMemory=21',
149 f, '/L', os.path.dirname(f)])
150 f_cab = f[:-1] + '_'
151
152 dest = '%s/%s/%s' % (os.path.basename(f), f_id, os.path.basename(f_cab))
153 print 'Uploading %s to Google Cloud Storage...' % dest
154 gsutil_args = ['cp', '-n', '-a', 'public-read', f_cab,
155 'gs://chromium-browser-symsrv/' + dest]
156 exit_code = RunGsutil(gsutil_args)
157 if exit_code != 0:
158 print "gsutil failed, exit_code: %s" % exit_code
159 sys.exit(exit_code)
160
161
113 def main(): 162 def main():
114 parser = argparse.ArgumentParser(description='build and package clang') 163 parser = argparse.ArgumentParser(description='build and package clang')
115 parser.add_argument('--upload', action='store_true', 164 parser.add_argument('--upload', action='store_true',
116 help='Upload the target archive to Google Cloud Storage.') 165 help='Upload the target archive to Google Cloud Storage.')
117 args = parser.parse_args() 166 args = parser.parse_args()
118 167
119 # Check that the script is not going to upload a toolchain built from HEAD. 168 # Check that the script is not going to upload a toolchain built from HEAD.
120 use_head_revision = 'LLVM_FORCE_HEAD_REVISION' in os.environ 169 use_head_revision = 'LLVM_FORCE_HEAD_REVISION' in os.environ
121 if args.upload and use_head_revision: 170 if args.upload and use_head_revision:
122 print ("--upload and LLVM_FORCE_HEAD_REVISION could not be used " 171 print ("--upload and LLVM_FORCE_HEAD_REVISION could not be used "
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 objdumpdir = 'llvmobjdump-' + stamp 344 objdumpdir = 'llvmobjdump-' + stamp
296 shutil.rmtree(objdumpdir, ignore_errors=True) 345 shutil.rmtree(objdumpdir, ignore_errors=True)
297 os.makedirs(os.path.join(objdumpdir, 'bin')) 346 os.makedirs(os.path.join(objdumpdir, 'bin'))
298 shutil.copy(os.path.join(LLVM_RELEASE_DIR, 'bin', 'llvm-objdump' + exe_ext), 347 shutil.copy(os.path.join(LLVM_RELEASE_DIR, 'bin', 'llvm-objdump' + exe_ext),
299 os.path.join(objdumpdir, 'bin')) 348 os.path.join(objdumpdir, 'bin'))
300 with tarfile.open(objdumpdir + '.tgz', 'w:gz') as tar: 349 with tarfile.open(objdumpdir + '.tgz', 'w:gz') as tar:
301 tar.add(os.path.join(objdumpdir, 'bin'), arcname='bin', 350 tar.add(os.path.join(objdumpdir, 'bin'), arcname='bin',
302 filter=PrintTarProgress) 351 filter=PrintTarProgress)
303 MaybeUpload(args, objdumpdir, platform) 352 MaybeUpload(args, objdumpdir, platform)
304 353
354 if sys.platform == 'win32' and args.upload:
355 UploadPDBToSymbolServer()
356
305 # FIXME: Warn if the file already exists on the server. 357 # FIXME: Warn if the file already exists on the server.
306 358
307 359
308 if __name__ == '__main__': 360 if __name__ == '__main__':
309 sys.exit(main()) 361 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | tools/clang/scripts/update.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698