|
OLD | NEW |
---|---|
(Empty) | |
1 #!/usr/bin/python | |
Ryan Sleevi
2011/11/12 02:52:51
In my msys checkout, this has historically caused
noelallen1
2011/11/12 03:00:54
We allow cygwin for Windows in NaCl land. But yea
Ryan Sleevi
2011/11/12 03:07:14
Right, I know the Google Open-Source Python guide
| |
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 platforms: list of platform names to build for. | |
25 out_dir: directory to output the IRT to. | |
26 """ | |
27 uplatform = platform.replace('-', '_') | |
Ryan Sleevi
2011/11/12 02:52:51
This variable seems is never used.
Did you mean t
noelallen1
2011/11/12 03:00:54
Lol, looks like a bug in the original I pulled thi
| |
28 # NaCl Trusted code is in thumb2 mode in CrOS, but as yet, | |
29 # untrusted code is still in classic ARM mode | |
30 # arm-thumb2 is for the future when untrusted code is in thumb2 as well | |
31 platform2 = {'arm': 'pnacl', | |
32 'arm-thumb2' : 'pnacl', | |
33 'x86-32': 'i686', | |
34 'x86-64': 'x86_64'}.get(platform, platform) | |
35 cplatform = { | |
36 'win32': 'win', | |
37 'cygwin': 'win', | |
38 'darwin': 'mac', | |
39 }.get(sys.platform, 'linux') | |
Ryan Sleevi
2011/11/12 02:52:51
I suspect it's not an issue, but any concern for t
noelallen1
2011/11/12 03:00:54
We don't support it yet so...
| |
40 if platform in ['arm', 'arm-thumb2']: | |
41 cmd = [ | |
42 '../native_client/toolchain/pnacl_linux_x86_64_newlib/bin/' + | |
43 platform2 + '-strip', | |
44 '--strip-debug', src, '-o', dst | |
45 ] | |
46 else: | |
47 cmd = [ | |
48 '../native_client/toolchain/' + cplatform + '_x86_newlib/bin/' + | |
49 platform2 + '-nacl-strip', | |
50 '--strip-debug', src, '-o', dst | |
51 ] | |
52 print 'Running: ' + ' '.join(cmd) | |
53 p = subprocess.Popen(cmd, cwd=SCRIPT_DIR) | |
54 p.wait() | |
55 if p.returncode != 0: | |
56 sys.exit(4) | |
57 | |
58 | |
59 def Main(argv): | |
60 parser = optparse.OptionParser() | |
61 parser.add_option('--platform', dest='platforms', | |
62 help='select a platform to strip') | |
63 parser.add_option('--src', dest='src', | |
64 help='source IRT file') | |
65 parser.add_option('--dst', dest='dst', | |
66 help='destination IRT file') | |
67 (options, args) = parser.parse_args(argv[1:]) | |
68 if args or not options.platforms: | |
69 parser.print_help() | |
70 sys.exit(1) | |
71 | |
72 StripIRT(options.platforms, options.src, options.dst) | |
73 | |
74 | |
75 if __name__ == '__main__': | |
76 Main(sys.argv) | |
OLD | NEW |