import argparse
import os
import subprocess
import sys
def do_strip(strip, output, unstripped_file, mini_debug, clang_base_dir):
if strip:
result = subprocess.call(
[strip, '-o', output, unstripped_file])
if mini_debug and not unstripped_file.endswith(".exe") and not unstripped_file.endswith(".dll"):
unstripped_libfile = os.path.abspath(unstripped_file)
script_path = os.path.join(
os.path.dirname(__file__), 'mini_debug_info.py')
ohos_root_path = os.path.join(os.path.dirname(__file__), '../..')
result = subprocess.call(
['python3', script_path, '--unstripped-path', unstripped_libfile, '--stripped-path', output,
'--root-path', ohos_root_path, '--clang-base-dir', clang_base_dir])
return result
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--strip',
help='The strip binary to run',
metavar='FILE')
parser.add_argument('--unstripped-file',
help='Binary file produced by linking command',
metavar='FILE')
parser.add_argument('--output',
required=True,
help='Final output binary file',
metavar='FILE')
parser.add_argument('command', nargs='+',
help='Linking command')
parser.add_argument('--mini-debug',
action='store_true',
default=False,
help='Add .gnu_debugdata section for stripped sofile')
parser.add_argument('--clang-base-dir', help='')
args = parser.parse_args()
return do_strip(args.strip, args.output, args.unstripped_file, args.mini_debug, args.clang_base_dir)
if __name__ == "__main__":
sys.exit(main())