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

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

Issue 2709613004: upload clang pdbs to chrome's symbol server (Closed)
Patch Set: . 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.exe
scottmg 2017/03/09 17:53:23 Since you're cab compressing the binary too, make
Nico 2017/03/09 17:56:03 Done.
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 # PDB:
125 # gs://chromium-browser-symsrv/clang-cl.exe.pdb/AABBCCDD/clang-cl.dll.pd_
126 # AABBCCDD here is computed from the output of
127 # dumpbin /all mybinary.exe | find "Format: RSDS"
128 # but tools/symsrc/pdb_fingerprint_from_img.py can compute it already, so
129 # again just use that.
130 sys.path.insert(0, os.path.join(CHROMIUM_DIR, 'tools', 'symsrc'))
131 import img_fingerprint, pdb_fingerprint_from_img
132
133 binaries = [ 'bin/clang-cl.exe', 'bin/lld-link.exe' ]
134 for binary_path in binaries:
135 binary_path = os.path.join(LLVM_RELEASE_DIR, binary_path)
136 binary_id = img_fingerprint.GetImgFingerprint(binary_path)
137 (pdb_id, pdb_path) = pdb_fingerprint_from_img.GetPDBInfoFromImg(binary_path)
138
139 # The build process builds clang.exe and then copies it to clang-cl.exe
140 # (both are the same binary and they behave differently on what their
141 # filename is). Hence, the pdb is at clang.pdb, not at clang-cl.pdb.
142 # Likewise, lld-link.exe's PDB file is called lld.pdb.
143
144 # Compress and upload.
145 for f, f_id in ((binary_path, binary_id), (pdb_path, pdb_id)):
146 subprocess.check_call(
147 ['makecab', '/D', 'CompressionType=LZX', '/D', 'CompressionMemory=21',
148 f, '/L', os.path.dirname(f)])
149 f_cab = f[:-1] + '_'
150
151 dest = '%s/%s/%s' % (os.path.basename(f), f_id, os.path.basename(f_cab))
152 print 'Uploading %s to Google Cloud Storage...' % dest
153 gsutil_args = ['cp', '-n', '-a', 'public-read', f_cab,
154 'gs://chromium-browser-symsrv/' + dest]
scottmg 2017/03/09 17:53:23 indent
Nico 2017/03/09 17:56:03 Done.
155 exit_code = RunGsutil(gsutil_args)
156 if exit_code != 0:
157 print "gsutil failed, exit_code: %s" % exit_code
158 sys.exit(exit_code)
159
160
113 def main(): 161 def main():
114 parser = argparse.ArgumentParser(description='build and package clang') 162 parser = argparse.ArgumentParser(description='build and package clang')
115 parser.add_argument('--upload', action='store_true', 163 parser.add_argument('--upload', action='store_true',
116 help='Upload the target archive to Google Cloud Storage.') 164 help='Upload the target archive to Google Cloud Storage.')
117 args = parser.parse_args() 165 args = parser.parse_args()
118 166
119 # Check that the script is not going to upload a toolchain built from HEAD. 167 # 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 168 use_head_revision = 'LLVM_FORCE_HEAD_REVISION' in os.environ
121 if args.upload and use_head_revision: 169 if args.upload and use_head_revision:
122 print ("--upload and LLVM_FORCE_HEAD_REVISION could not be used " 170 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 343 objdumpdir = 'llvmobjdump-' + stamp
296 shutil.rmtree(objdumpdir, ignore_errors=True) 344 shutil.rmtree(objdumpdir, ignore_errors=True)
297 os.makedirs(os.path.join(objdumpdir, 'bin')) 345 os.makedirs(os.path.join(objdumpdir, 'bin'))
298 shutil.copy(os.path.join(LLVM_RELEASE_DIR, 'bin', 'llvm-objdump' + exe_ext), 346 shutil.copy(os.path.join(LLVM_RELEASE_DIR, 'bin', 'llvm-objdump' + exe_ext),
299 os.path.join(objdumpdir, 'bin')) 347 os.path.join(objdumpdir, 'bin'))
300 with tarfile.open(objdumpdir + '.tgz', 'w:gz') as tar: 348 with tarfile.open(objdumpdir + '.tgz', 'w:gz') as tar:
301 tar.add(os.path.join(objdumpdir, 'bin'), arcname='bin', 349 tar.add(os.path.join(objdumpdir, 'bin'), arcname='bin',
302 filter=PrintTarProgress) 350 filter=PrintTarProgress)
303 MaybeUpload(args, objdumpdir, platform) 351 MaybeUpload(args, objdumpdir, platform)
304 352
353 if sys.platform == 'win32' and args.upload:
354 UploadPDBToSymbolServer()
355
305 # FIXME: Warn if the file already exists on the server. 356 # FIXME: Warn if the file already exists on the server.
306 357
307 358
308 if __name__ == '__main__': 359 if __name__ == '__main__':
309 sys.exit(main()) 360 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