Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Side by Side Diff: tools/nacl-run.py

Issue 631703002: Use the pnacl-clang toolchain for (P)NaCL builds (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/gyp/v8.gyp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # 2 #
3 # Copyright 2013 the V8 project authors. All rights reserved. 3 # Copyright 2013 the V8 project authors. All rights reserved.
4 # Redistribution and use in source and binary forms, with or without 4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are 5 # modification, are permitted provided that the following conditions are
6 # met: 6 # met:
7 # 7 #
8 # * Redistributions of source code must retain the above copyright 8 # * Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer. 9 # notice, this list of conditions and the following disclaimer.
10 # * Redistributions in binary form must reproduce the above 10 # * Redistributions in binary form must reproduce the above
(...skipping 14 matching lines...) Expand all
25 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 29
30 # This script executes the passed command line using the Native Client 30 # This script executes the passed command line using the Native Client
31 # 'sel_ldr' container. It is derived from android-run.py. 31 # 'sel_ldr' container. It is derived from android-run.py.
32 32
33 import os 33 import os
34 from os.path import join, dirname, abspath 34 from os.path import join, dirname, abspath
35 import re
35 import subprocess 36 import subprocess
36 import sys 37 import sys
37 import tempfile 38 import tempfile
38 39
39 def Check(output, errors): 40 def Check(output, errors):
40 failed = any([s.startswith('/system/bin/sh:') or s.startswith('ANDROID') 41 failed = any([s.startswith('/system/bin/sh:') or s.startswith('ANDROID')
41 for s in output.split('\n')]) 42 for s in output.split('\n')])
42 return 1 if failed else 0 43 return 1 if failed else 0
43 44
44 def Execute(cmdline): 45 def Execute(cmdline):
(...skipping 30 matching lines...) Expand all
75 os.close(fd) 76 os.close(fd)
76 tmp_file = open(fname, "w") 77 tmp_file = open(fname, "w")
77 tmp_file.write(data) 78 tmp_file.write(data)
78 tmp_file.close() 79 tmp_file.close()
79 return fname 80 return fname
80 81
81 def GetNaClArchFromNexe(nexe): 82 def GetNaClArchFromNexe(nexe):
82 try: 83 try:
83 p = subprocess.Popen(['file', nexe], stdout=subprocess.PIPE) 84 p = subprocess.Popen(['file', nexe], stdout=subprocess.PIPE)
84 out, err = p.communicate() 85 out, err = p.communicate()
85 lines = out.split('\n') 86 lines = [re.sub("\s+", " " , line) for line in out.split('\n')]
86 if lines[0].find(": ELF 32-bit LSB executable, Intel 80386") > 0: 87 if lines[0].find(": ELF 32-bit LSB executable, Intel 80386") > 0:
87 return "x86_32" 88 return "x86_32"
88 if lines[0].find(": ELF 64-bit LSB executable, x86-64") > 0: 89 if lines[0].find(": ELF 64-bit LSB executable, x86-64") > 0:
89 return "x86_64" 90 return "x86_64"
90 except: 91 except:
91 print 'file ' + sys.argv[1] + ' failed' 92 print 'file ' + sys.argv[1] + ' failed'
92 return None 93 return None
93 94
94 def GetNaClResources(nexe): 95 def GetNaClResources(nexe):
95 nacl_sdk_dir = os.environ["NACL_SDK_ROOT"] 96 nacl_sdk_dir = os.environ["NACL_SDK_ROOT"]
(...skipping 13 matching lines...) Expand all
109 libdir = "lib64" 110 libdir = "lib64"
110 elif nacl_arch is "x86_32": 111 elif nacl_arch is "x86_32":
111 toolchain = platform + "_x86_glibc" 112 toolchain = platform + "_x86_glibc"
112 sel_ldr = "sel_ldr_x86_32" 113 sel_ldr = "sel_ldr_x86_32"
113 irt = "irt_core_x86_32.nexe" 114 irt = "irt_core_x86_32.nexe"
114 libdir = "lib32" 115 libdir = "lib32"
115 elif nacl_arch is "arm": 116 elif nacl_arch is "arm":
116 print("NaCl V8 ARM support is not ready yet.") 117 print("NaCl V8 ARM support is not ready yet.")
117 sys.exit(1) 118 sys.exit(1)
118 else: 119 else:
119 print("Invalid nexe %s" % nexe) 120 print("Invalid nexe %s with NaCl arch %s" % (nexe, nacl_arch))
120 sys.exit(1) 121 sys.exit(1)
121 122
122 nacl_sel_ldr = os.path.join(nacl_sdk_dir, "tools", sel_ldr) 123 nacl_sel_ldr = os.path.join(nacl_sdk_dir, "tools", sel_ldr)
123 nacl_irt = os.path.join(nacl_sdk_dir, "tools", irt) 124 nacl_irt = os.path.join(nacl_sdk_dir, "tools", irt)
124 nacl_ld_so = os.path.join(nacl_sdk_dir, "toolchain", toolchain,
125 "x86_64-nacl", libdir, "runnable-ld.so")
126 nacl_lib_path = os.path.join(nacl_sdk_dir, "toolchain", toolchain,
127 "x86_64-nacl", libdir)
128 125
129 return (nacl_sdk_dir, nacl_sel_ldr, nacl_irt, nacl_ld_so, nacl_lib_path) 126 return (nacl_sdk_dir, nacl_sel_ldr, nacl_irt)
130 127
131 def Main(): 128 def Main():
132 if (len(sys.argv) == 1): 129 if (len(sys.argv) == 1):
133 print("Usage: %s <command-to-run-on-device>" % sys.argv[0]) 130 print("Usage: %s <command-to-run-on-device>" % sys.argv[0])
134 return 1 131 return 1
135 132
136 args = [Escape(arg) for arg in sys.argv[1:]] 133 args = [Escape(arg) for arg in sys.argv[1:]]
137 134
138 (nacl_sdk_dir, nacl_sel_ldr, nacl_irt, nacl_ld_so, 135 (nacl_sdk_dir, nacl_sel_ldr, nacl_irt) = GetNaClResources(sys.argv[1])
139 nacl_lib_path) = GetNaClResources(sys.argv[1])
140 136
141 # sel_ldr Options: 137 # sel_ldr Options:
142 # -c -c: disable validation (for performance) 138 # -c -c: disable validation (for performance)
143 # -a: allow file access 139 # -a: allow file access
144 # -B <irt>: load the IRT 140 # -B <irt>: load the IRT
145 command = ' '.join([nacl_sel_ldr, '-c', '-c', '-a', '-B', nacl_irt, '--', 141 command = ' '.join([nacl_sel_ldr, '-c', '-c', '-a', '-B', nacl_irt, '--'] +
146 nacl_ld_so, '--library-path', nacl_lib_path] + args) 142 args)
147 error_code = Execute(command) 143 error_code = Execute(command)
148 return error_code 144 return error_code
149 145
150 if __name__ == '__main__': 146 if __name__ == '__main__':
151 sys.exit(Main()) 147 sys.exit(Main())
OLDNEW
« no previous file with comments | « tools/gyp/v8.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698