Support breakpad (#2340)

This commit is contained in:
sun20121818 2020-05-25 18:33:37 +08:00 committed by GitHub
parent bd7ae28770
commit 99d9b5c7c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 84 additions and 22 deletions

View File

@ -26,33 +26,74 @@ def get_command_output(cmd, **kw):
return subprocess.check_output(cmd, shell=shell, **kw)
def main():
parser = optparse.OptionParser()
parser.add_option('--output', help='the path of the symbol file.')
args, _ = parser.parse_args()
def generate_seafile_breakpad_symbol(project_dir, program_name, symbols_output):
"""
:param project_dir : [string]
:param program_name : [string]
:param symbols_output: [string]
:return: None
seafile_src_dir = dirname(abspath(dirname(__file__)))
os.chdir(seafile_src_dir)
program = 'seaf-daemon.exe' if os.name == 'nt' else 'seaf-daemon'
seaf_daemon = join('daemon', '.libs', program)
generate_seafile_breakpad_symbol
"""
os.chdir(project_dir)
seaf_daemon = join('daemon', '.libs', program_name)
if not exists(seaf_daemon):
seaf_daemon = join('daemon', program)
seaf_daemon = join('daemon', program_name)
if not exists(seaf_daemon):
raise RuntimeError('seaf-daemon executable not found!')
symbols = get_command_output('dump_syms {}'.format(seaf_daemon))
if args.output:
symbol_file = args.output
if symbols_output:
symbol_file = symbols_output
else:
symbol_id = symbols.splitlines()[0].split()[3]
symbol_dir = join('symbols', program, symbol_id)
symbol_dir = join('symbols', program_name, symbol_id)
if not exists(symbol_dir):
os.makedirs(symbol_dir)
symbol_file = join(symbol_dir, '{}.sym'.format(program))
symbol_file = join(symbol_dir, '{}.sym'.format(program_name))
print('symbols written to {}'.format(symbol_file))
with open(symbol_file, 'w') as fp:
fp.write(symbols)
def generate_seafile_gui_breakpad_symbol(project_dir, program_name, symbol_output):
"""
:param project_dir: [string]
:param program_name: [string]
:param symbol_output: [string]
:return: None
generate seafile gui breakpad symbol
"""
os.chdir(project_dir)
seafile_gui_path = os.path.join(project_dir, program_name)
if not exists(seafile_gui_path):
raise RuntimeError('seafile gui executable not found !')
symbols = get_command_output('dump_syms {}'.format(seafile_gui_path))
with open(symbol_output, 'w') as fp:
fp.write(symbols)
def main():
parser = optparse.OptionParser()
parser.add_option('--projectSrc', help='the project source file directory')
parser.add_option('--name', help='the program name need to generated breakpad symbol')
parser.add_option('--output', help='the path of the symbol file.')
args, _ = parser.parse_args()
src_dir = args.projectSrc
program_name = args.name
symbols_output = args.output
if program_name == 'seaf-daemon.exe' or program_name == 'seaf-daemon':
# generate seafile breakpad symbols
generate_seafile_breakpad_symbol(src_dir, program_name, symbols_output)
else:
# generate seafile-gui breakpad symbols
generate_seafile_gui_breakpad_symbol(src_dir, program_name, symbols_output)
if __name__ == '__main__':
main()

View File

@ -891,19 +891,40 @@ def edit_fragment_wxs():
with open(file_path, 'w') as fp:
fp.write(content)
def generate_breakpad_symbols():
seafiledir = Seafile().projdir
script = os.path.join(seafiledir, 'scripts/breakpad.py')
symbol_file = 'seaf-daemon.exe.sym-%s' % conf[CONF_VERSION]
output = os.path.join(seafiledir, symbol_file)
# generate the breakpad symbols
if run('python %s --output %s' % (script, output)) != 0:
def generate_breakpad_symbols():
"""
Generate seafile and seafile-gui breakpad symbols
:return: None
"""
seafile_src = Seafile().projdir
seafile_gui_src = SeafileClient().projdir
generate_breakpad_symbols_script = os.path.join(seafile_src, 'scripts/breakpad.py')
# generate seafile the breakpad symbols
seafile_name = 'seaf-daemon.exe'
seafile_symbol_name = 'seaf-daemon.exe.sym-%s' % conf[CONF_VERSION]
seafile_symbol_output = os.path.join(seafile_src, seafile_symbol_name)
if run('python %s --projectSrc %s --name %s --output %s'
% (generate_breakpad_symbols_script, seafile_src, seafile_name, seafile_symbol_output)) != 0:
error('Error when generating breakpad symbols')
# generate seafile gui breakpad symbols
seafile_gui_name = 'seafile-applet.exe'
seafile_gui_symbol_name = 'seafile-applet.exe.sym-%s' % conf[CONF_VERSION]
seafile_gui_symbol_output = os.path.join(seafile_gui_src, seafile_gui_symbol_name)
if run('python %s --projectSrc %s --name %s --output %s'
% (generate_breakpad_symbols_script, seafile_gui_src, seafile_gui_name, seafile_gui_symbol_output)) != 0:
error('Error when generating seafile gui client breakpad symbol')
# move symbols to output directory
dst_symbol_file = os.path.join(conf[CONF_OUTPUTDIR], symbol_file)
must_copy(output, dst_symbol_file)
dst_seafile_symbol_file = os.path.join(conf[CONF_OUTPUTDIR], seafile_symbol_name)
dst_seafile_gui_symbol_file = os.path.join(conf[CONF_OUTPUTDIR], seafile_gui_symbol_name)
must_copy(seafile_symbol_output, dst_seafile_symbol_file)
must_copy(seafile_gui_symbol_output, dst_seafile_gui_symbol_file)
def build_msi():
prepare_msi()