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