2022-04-12 04:21:55 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#!/usr/bin/env python3
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-29 02:10:42 +12:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-10-12 22:02:52 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import argparse
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-27 15:38:06 +10:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								import glob
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								import os
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								import sys
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								from lib.config import PLATFORM, get_target_arch
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								from lib.util import scoped_cwd, get_electron_version, make_zip, \
							 | 
						
					
						
							
								
									
										
										
										
											2021-04-26 13:00:50 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                     get_electron_branding, get_out_dir, execute
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-27 15:38:06 +10:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								ELECTRON_VERSION = get_electron_version()
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-28 16:48:09 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								PROJECT_NAME = get_electron_branding()['project_name']
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-27 15:38:06 +10:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								OUT_DIR = get_out_dir()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								def main():
							 | 
						
					
						
							
								
									
										
										
										
											2018-10-10 11:04:55 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  print('Zipping Symbols')
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-27 15:38:06 +10:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-10-12 22:02:52 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  args = parse_args()
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-27 15:38:06 +10:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  dist_name = 'symbols.zip'
							 | 
						
					
						
							
								
									
										
										
										
											2018-10-12 22:02:52 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  zip_file = os.path.join(args.build_dir, dist_name)
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-27 15:38:06 +10:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  licenses = ['LICENSE', 'LICENSES.chromium.html', 'version']
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-10-12 22:02:52 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  with scoped_cwd(args.build_dir):
							 | 
						
					
						
							
								
									
										
										
										
											2018-11-14 12:47:01 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    dirs = ['breakpad_symbols']
							 | 
						
					
						
							
								
									
										
										
										
											2018-10-10 11:04:55 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    print('Making symbol zip: ' + zip_file)
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-27 15:38:06 +10:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    make_zip(zip_file, licenses, dirs)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  if PLATFORM == 'darwin':
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    dsym_name = 'dsym.zip'
							 | 
						
					
						
							
								
									
										
										
										
											2018-10-12 22:02:52 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    with scoped_cwd(args.build_dir):
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-27 15:38:06 +10:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      dsyms = glob.glob('*.dSYM')
							 | 
						
					
						
							
								
									
										
										
										
											2022-03-07 15:47:58 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      snapshot_dsyms = ['v8_context_snapshot_generator.dSYM']
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      for dsym in snapshot_dsyms:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        if (dsym in dsyms):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          dsyms.remove(dsym)
							 | 
						
					
						
							
								
									
										
										
										
											2018-10-12 22:02:52 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      dsym_zip_file = os.path.join(args.build_dir, dsym_name)
							 | 
						
					
						
							
								
									
										
										
										
											2018-10-10 11:04:55 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      print('Making dsym zip: ' + dsym_zip_file)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      make_zip(dsym_zip_file, licenses, dsyms)
							 | 
						
					
						
							
								
									
										
										
										
											2022-03-07 15:47:58 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      dsym_snapshot_name = 'dsym-snapshot.zip'
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      dsym_snapshot_zip_file = os.path.join(args.build_dir, dsym_snapshot_name)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      print('Making dsym snapshot zip: ' + dsym_snapshot_zip_file)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      make_zip(dsym_snapshot_zip_file, licenses, snapshot_dsyms)
							 | 
						
					
						
							
								
									
										
										
										
											2021-04-26 11:04:44 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      if len(dsyms) > 0 and 'DELETE_DSYMS_AFTER_ZIP' in os.environ:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        execute(['rm', '-rf'] + dsyms)
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-27 15:38:06 +10:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  elif PLATFORM == 'win32':
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    pdb_name = 'pdb.zip'
							 | 
						
					
						
							
								
									
										
										
										
											2018-10-12 22:02:52 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    with scoped_cwd(args.build_dir):
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-27 15:38:06 +10:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      pdbs = glob.glob('*.pdb')
							 | 
						
					
						
							
								
									
										
										
										
											2018-10-12 22:02:52 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      pdb_zip_file = os.path.join(args.build_dir, pdb_name)
							 | 
						
					
						
							
								
									
										
										
										
											2018-10-10 11:04:55 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      print('Making pdb zip: ' + pdb_zip_file)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      make_zip(pdb_zip_file, pdbs + licenses, [])
							 | 
						
					
						
							
								
									
										
										
										
											2019-11-20 17:21:44 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  elif PLATFORM == 'linux':
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    debug_name = 'debug.zip'
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    with scoped_cwd(args.build_dir):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      dirs = ['debug']
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      debug_zip_file = os.path.join(args.build_dir, debug_name)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      print('Making debug zip: ' + debug_zip_file)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      make_zip(debug_zip_file, licenses, dirs)
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-27 15:38:06 +10:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-10-12 22:02:52 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								def parse_args():
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  parser = argparse.ArgumentParser(description='Zip symbols')
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  parser.add_argument('-b', '--build-dir',
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                      help='Path to an Electron build folder.',
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                      default=OUT_DIR,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                      required=False)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  return parser.parse_args()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-27 15:38:06 +10:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								if __name__ == '__main__':
							 | 
						
					
						
							
								
									
										
										
										
											2018-10-12 22:02:52 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  sys.exit(main())
							 |