| OLD | NEW |
| (Empty) |
| 1 #!/usr/bin/python | |
| 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
| 3 # Use of this source code is governed by a BSD-style license that can be | |
| 4 # found in the LICENSE file. | |
| 5 | |
| 6 import optparse | |
| 7 import os | |
| 8 import re | |
| 9 import shutil | |
| 10 import subprocess | |
| 11 import sys | |
| 12 | |
| 13 | |
| 14 # Where things are in relation to this script. | |
| 15 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) | |
| 16 SRC_DIR = os.path.dirname(SCRIPT_DIR) | |
| 17 NACL_DIR = os.path.join(SRC_DIR, 'native_client') | |
| 18 | |
| 19 | |
| 20 def StripIRT(platform, src, dst): | |
| 21 """Build the IRT for several platforms. | |
| 22 | |
| 23 Arguments: | |
| 24 platform: is the name of the platform to build for. | |
| 25 src: path to the input NEXE. | |
| 26 dst: path to the output NEXE. | |
| 27 """ | |
| 28 uplatform = platform.replace('-', '_') | |
| 29 # NaCl Trusted code is in thumb2 mode in CrOS, but as yet, | |
| 30 # untrusted code is still in classic ARM mode | |
| 31 # arm-thumb2 is for the future when untrusted code is in thumb2 as well | |
| 32 platform2 = {'arm': 'pnacl', | |
| 33 'arm-thumb2' : 'pnacl', | |
| 34 'x86-32': 'i686', | |
| 35 'x86-64': 'x86_64'}.get(platform, uplatform) | |
| 36 cplatform = { | |
| 37 'win32': 'win', | |
| 38 'cygwin': 'win', | |
| 39 'darwin': 'mac', | |
| 40 }.get(sys.platform, 'linux') | |
| 41 if platform in ['arm', 'arm-thumb2']: | |
| 42 cmd = [ | |
| 43 '../native_client/toolchain/pnacl_linux_x86_64_newlib/bin/' + | |
| 44 platform2 + '-strip', | |
| 45 '--strip-debug', src, '-o', dst | |
| 46 ] | |
| 47 else: | |
| 48 cmd = [ | |
| 49 '../native_client/toolchain/' + cplatform + '_x86_newlib/bin/' + | |
| 50 platform2 + '-nacl-strip', | |
| 51 '--strip-debug', src, '-o', dst | |
| 52 ] | |
| 53 print 'Running: ' + ' '.join(cmd) | |
| 54 p = subprocess.Popen(cmd, cwd=SCRIPT_DIR) | |
| 55 p.wait() | |
| 56 if p.returncode != 0: | |
| 57 sys.exit(4) | |
| 58 | |
| 59 | |
| 60 def Main(argv): | |
| 61 parser = optparse.OptionParser() | |
| 62 parser.add_option('--platform', dest='platforms', | |
| 63 help='select a platform to strip') | |
| 64 parser.add_option('--src', dest='src', | |
| 65 help='source IRT file') | |
| 66 parser.add_option('--dst', dest='dst', | |
| 67 help='destination IRT file') | |
| 68 (options, args) = parser.parse_args(argv[1:]) | |
| 69 if args or not options.platforms: | |
| 70 parser.print_help() | |
| 71 sys.exit(1) | |
| 72 | |
| 73 StripIRT(options.platforms, options.src, options.dst) | |
| 74 | |
| 75 | |
| 76 if __name__ == '__main__': | |
| 77 Main(sys.argv) | |
| OLD | NEW |