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
|
|
|
|
from lib.gn import gn
|
|
|
|
from lib.util import execute, rm_rf
|
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))
|
|
|
|
RELEASE_PATH = os.path.join('out', 'Release')
|
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)
|
|
|
|
product_name = gn(build_path).args().get_string('electron_product_name')
|
|
|
|
project_name = gn(build_path).args().get_string('electron_project_name')
|
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-26 18:56:05 +00:00
|
|
|
for binary in binaries:
|
|
|
|
generate_posix_symbols(binary, source_root, build_path,
|
|
|
|
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)
|
|
|
|
generate_posix_symbols(binary, source_root, build_path,
|
|
|
|
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),
|
|
|
|
]
|
|
|
|
execute([sys.executable, generate_breakpad_symbols] + args)
|
2015-04-08 14:12:47 +00:00
|
|
|
|
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),
|
|
|
|
]
|
|
|
|
if is_verbose_mode():
|
|
|
|
args += ['-v']
|
|
|
|
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',
|
|
|
|
help='Prints the output of the subprocesses')
|
|
|
|
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())
|