import os
import subprocess
import sys
if len(sys.argv) != 5:
print("dump_app_syms.py <dump_syms_exe> <strip_binary>")
print(" <binary_with_symbols> <symbols_output>")
sys.exit(1)
dumpsyms = sys.argv[1]
strip_binary = sys.argv[2]
infile = sys.argv[3]
outfile = sys.argv[4]
if not os.path.isfile(outfile) or \
os.stat(outfile).st_mtime < os.stat(infile).st_mtime:
try:
with open(outfile, 'w') as outfileobj:
subprocess.check_call([dumpsyms, '-m', '-d', infile], stdout=outfileobj)
except:
if os.path.isfile(outfile):
os.remove(outfile)
raise
if strip_binary != '0':
subprocess.check_call(['strip', infile])