| 
									
										
										
										
											2015-04-08 22:12:47 +08:00
										 |  |  | #!/usr/bin/env python | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-26 14:56:05 -04:00
										 |  |  | import argparse | 
					
						
							| 
									
										
										
										
											2015-04-08 22:12:47 +08:00
										 |  |  | import os | 
					
						
							|  |  |  | import sys | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-26 14:56:05 -04:00
										 |  |  | from lib.config import PLATFORM, enable_verbose_mode, is_verbose_mode | 
					
						
							| 
									
										
										
										
											2018-09-28 13:24:00 -04:00
										 |  |  | from lib.util import get_electron_branding, execute, rm_rf, get_out_dir, \ | 
					
						
							| 
									
										
										
										
											2018-10-08 22:19:40 +02:00
										 |  |  |                      SRC_DIR | 
					
						
							| 
									
										
										
										
											2015-04-08 22:12:47 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-26 14:56:05 -04:00
										 |  |  | ELECTRON_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) | 
					
						
							|  |  |  | SOURCE_ROOT = os.path.abspath(os.path.dirname(ELECTRON_ROOT)) | 
					
						
							| 
									
										
										
										
											2018-09-27 15:49:02 +10:00
										 |  |  | RELEASE_PATH = get_out_dir() | 
					
						
							| 
									
										
										
										
											2015-04-08 22:12:47 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-26 14:56:05 -04:00
										 |  |  | def main(): | 
					
						
							|  |  |  |   args = parse_args() | 
					
						
							|  |  |  |   if args.verbose: | 
					
						
							|  |  |  |     enable_verbose_mode() | 
					
						
							|  |  |  |   rm_rf(args.destination) | 
					
						
							|  |  |  |   source_root = os.path.abspath(args.source_root) | 
					
						
							|  |  |  |   build_path = os.path.join(source_root, args.build_dir) | 
					
						
							| 
									
										
										
										
											2018-09-27 13:53:08 -05:00
										 |  |  |   (project_name, product_name) = get_names_from_branding() | 
					
						
							| 
									
										
										
										
											2015-04-08 22:12:47 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-11 17:30:52 +08:00
										 |  |  |   if PLATFORM in ['darwin', 'linux']: | 
					
						
							| 
									
										
										
										
											2018-09-26 14:56:05 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-11 17:30:52 +08:00
										 |  |  |     if PLATFORM == 'darwin': | 
					
						
							| 
									
										
										
										
											2018-05-20 18:01:17 -07:00
										 |  |  |       #macOS has an additional helper app; provide the path to that binary also | 
					
						
							| 
									
										
										
										
											2018-09-26 14:56:05 -04:00
										 |  |  |       main_app = os.path.join(build_path, '{0}.app'.format(product_name), | 
					
						
							| 
									
										
										
										
											2018-05-20 18:01:17 -07:00
										 |  |  |                             'Contents', 'MacOS', product_name) | 
					
						
							|  |  |  |       helper_name = product_name + " Helper" | 
					
						
							| 
									
										
										
										
											2018-09-26 14:56:05 -04:00
										 |  |  |       helper_app = os.path.join(build_path, '{0}.app'.format(helper_name), | 
					
						
							| 
									
										
										
										
											2018-05-20 18:01:17 -07:00
										 |  |  |                             'Contents', 'MacOS', product_name + " Helper") | 
					
						
							|  |  |  |       binaries = [main_app, helper_app] | 
					
						
							| 
									
										
										
										
											2018-09-28 13:24:00 -04:00
										 |  |  |       for binary in binaries: | 
					
						
							|  |  |  |         generate_posix_symbols(binary, source_root, build_path, | 
					
						
							| 
									
										
										
										
											2018-09-26 14:56:05 -04:00
										 |  |  |                                         args.destination) | 
					
						
							| 
									
										
										
										
											2015-04-08 22:12:47 +08:00
										 |  |  |     else: | 
					
						
							| 
									
										
										
										
											2018-09-26 14:56:05 -04:00
										 |  |  |       binary = os.path.join(build_path, project_name) | 
					
						
							| 
									
										
										
										
											2018-09-28 13:24:00 -04:00
										 |  |  |       generate_posix_symbols(binary, source_root, build_path, | 
					
						
							| 
									
										
										
										
											2018-09-26 14:56:05 -04:00
										 |  |  |                                       args.destination) | 
					
						
							| 
									
										
										
										
											2018-05-20 18:01:17 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-08 22:12:47 +08:00
										 |  |  |   else: | 
					
						
							| 
									
										
										
										
											2018-09-26 14:56:05 -04:00
										 |  |  |     generate_breakpad_symbols = os.path.join(ELECTRON_ROOT, 'tools', 'win', | 
					
						
							| 
									
										
										
										
											2015-04-08 22:12:47 +08:00
										 |  |  |                                              'generate_breakpad_symbols.py') | 
					
						
							|  |  |  |     args = [ | 
					
						
							| 
									
										
										
										
											2018-09-26 14:56:05 -04:00
										 |  |  |       '--symbols-dir={0}'.format(args.destination), | 
					
						
							| 
									
										
										
										
											2015-04-08 22:12:47 +08:00
										 |  |  |       '--jobs=16', | 
					
						
							| 
									
										
										
										
											2018-09-26 14:56:05 -04:00
										 |  |  |       os.path.relpath(build_path), | 
					
						
							| 
									
										
										
										
											2018-09-28 13:24:00 -04:00
										 |  |  |     ] | 
					
						
							| 
									
										
										
										
											2018-09-28 15:37:11 -04:00
										 |  |  |     if is_verbose_mode(): | 
					
						
							|  |  |  |       args += ['-v'] | 
					
						
							| 
									
										
										
										
											2018-09-28 13:24:00 -04:00
										 |  |  |     #Make sure msdia140.dll is in the path (needed for dump_syms.exe) | 
					
						
							|  |  |  |     env = os.environ.copy() | 
					
						
							| 
									
										
										
										
											2018-10-08 22:19:40 +02:00
										 |  |  |     msdia140_dll_path =  os.path.join(SRC_DIR, 'third_party', 'llvm-build', | 
					
						
							| 
									
										
										
										
											2018-09-28 13:24:00 -04:00
										 |  |  |                                       'Release+Asserts', 'bin') | 
					
						
							|  |  |  |     env['PATH'] = os.path.pathsep.join( | 
					
						
							|  |  |  |         [env.get('PATH', '')] + [msdia140_dll_path]) | 
					
						
							|  |  |  |     execute([sys.executable, generate_breakpad_symbols] + args, env) | 
					
						
							| 
									
										
										
										
											2015-04-08 22:12:47 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-27 13:53:08 -05:00
										 |  |  | def get_names_from_branding(): | 
					
						
							|  |  |  |   variables = get_electron_branding() | 
					
						
							|  |  |  |   return (variables['project_name'], variables['product_name']) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-26 14:56:05 -04:00
										 |  |  | def generate_posix_symbols(binary, source_root, build_dir, destination): | 
					
						
							|  |  |  |   generate_breakpad_symbols = os.path.join(source_root, 'components', 'crash', | 
					
						
							|  |  |  |                                           'content', 'tools', | 
					
						
							|  |  |  |                                           'generate_breakpad_symbols.py') | 
					
						
							|  |  |  |   args = [ | 
					
						
							|  |  |  |     '--build-dir={0}'.format(build_dir), | 
					
						
							|  |  |  |     '--symbols-dir={0}'.format(destination), | 
					
						
							|  |  |  |     '--jobs=16', | 
					
						
							|  |  |  |     '--binary={0}'.format(binary), | 
					
						
							|  |  |  |   ] | 
					
						
							| 
									
										
										
										
											2018-09-28 13:24:00 -04:00
										 |  |  |   if is_verbose_mode(): | 
					
						
							| 
									
										
										
										
											2018-11-14 12:47:01 -08:00
										 |  |  |     args += ['--verbose'] | 
					
						
							| 
									
										
										
										
											2018-09-28 13:24:00 -04:00
										 |  |  |   execute([sys.executable, generate_breakpad_symbols] + args) | 
					
						
							| 
									
										
										
										
											2015-04-08 22:12:47 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-26 14:56:05 -04:00
										 |  |  | def parse_args(): | 
					
						
							|  |  |  |   parser = argparse.ArgumentParser(description='Create breakpad symbols') | 
					
						
							|  |  |  |   parser.add_argument('-b', '--build-dir', | 
					
						
							| 
									
										
										
										
											2018-10-12 22:02:52 -04:00
										 |  |  |                       help='Path to an Electron build folder.', | 
					
						
							| 
									
										
										
										
											2018-09-26 14:56:05 -04:00
										 |  |  |                       default=RELEASE_PATH, | 
					
						
							|  |  |  |                       required=False) | 
					
						
							|  |  |  |   parser.add_argument('-d', '--destination', | 
					
						
							|  |  |  |                       help='Path to save symbols to.', | 
					
						
							|  |  |  |                       default=None, | 
					
						
							|  |  |  |                       required=True) | 
					
						
							|  |  |  |   parser.add_argument('-s', '--source-root', | 
					
						
							|  |  |  |                       help='Path to the src folder.', | 
					
						
							|  |  |  |                       default=SOURCE_ROOT, | 
					
						
							|  |  |  |                       required=False) | 
					
						
							|  |  |  |   parser.add_argument('-v', '--verbose', | 
					
						
							|  |  |  |                       action='store_true', | 
					
						
							| 
									
										
										
										
											2018-09-28 13:24:00 -04:00
										 |  |  |                       help='Prints the output of the subprocesses') | 
					
						
							| 
									
										
										
										
											2018-09-26 14:56:05 -04:00
										 |  |  |   return parser.parse_args() | 
					
						
							| 
									
										
										
										
											2015-04-08 22:12:47 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | if __name__ == '__main__': | 
					
						
							| 
									
										
										
										
											2018-09-26 14:56:05 -04:00
										 |  |  |   sys.exit(main()) |