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

Side by Side Diff: run.py

Issue 12667019: [MIPS] Support for building tests for MIPS (Closed) Base URL: http://git.chromium.org/native_client/src/native_client.git@master
Patch Set: updates to sandboxed_mips.S. Created 7 years, 9 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
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright (c) 2012 The Native Client Authors. All rights reserved. 2 # Copyright (c) 2012 The Native Client Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import os 6 import os
7 import platform 7 import platform
8 import subprocess 8 import subprocess
9 import sys 9 import sys
10 10
(...skipping 24 matching lines...) Expand all
35 --irt=none Don't use IRT 35 --irt=none Don't use IRT
36 --irt=<path> Path to IRT nexe 36 --irt=<path> Path to IRT nexe
37 Default: Uses whichever IRT already exists. Otherwise, builds irt_core. 37 Default: Uses whichever IRT already exists. Otherwise, builds irt_core.
38 38
39 -n | --dry-run Just print commands, don't execute them 39 -n | --dry-run Just print commands, don't execute them
40 -h | --help Display this information 40 -h | --help Display this information
41 -q | --quiet Don't print anything (nexe output can be redirected 41 -q | --quiet Don't print anything (nexe output can be redirected
42 with NACL_EXE_STDOUT/STDERR env vars) 42 with NACL_EXE_STDOUT/STDERR env vars)
43 --more Display sel_ldr usage 43 --more Display sel_ldr usage
44 44
45 -arch <arch> | -m32 | -m64 | -marm 45 -arch <arch> | -m32 | -m64 | -marm | -mmips32
46 Specify architecture for PNaCl translation 46 Specify architecture for PNaCl translation
47 (arch is one of: x86-32, x86-64 or arm) 47 (arch is one of: x86-32, x86-64, arm or mips32)
48 ''' 48 '''
49 print info % name 49 print info % name
50 print '-' * 80 50 print '-' * 80
51 sys.exit(0) 51 sys.exit(0)
52 52
53 def SetupEnvironment(): 53 def SetupEnvironment():
54 # linux, win, or mac 54 # linux, win, or mac
55 env.scons_os = GetSconsOS() 55 env.scons_os = GetSconsOS()
56 56
57 # native_client/ directory 57 # native_client/ directory
58 env.nacl_root = FindBaseDir() 58 env.nacl_root = FindBaseDir()
59 59
60 # Path to Native NaCl toolchain (glibc) 60 # Path to Native NaCl toolchain (glibc)
61 env.nnacl_root = os.path.join(env.nacl_root, 61 env.nnacl_root = os.path.join(env.nacl_root,
62 'toolchain', 62 'toolchain',
63 env.scons_os + '_x86') 63 env.scons_os + '_x86')
64 64
65 # Path to PNaCl toolchain 65 # Path to PNaCl toolchain
66 pnacl_label = 'pnacl_%s_%s' % (GetSconsOS(), GetBuildArch().replace('-','_')) 66 pnacl_label = 'pnacl_%s_%s' % (GetSconsOS(), GetBuildArch().replace('-','_'))
67 env.pnacl_base = os.path.join(env.nacl_root, 'toolchain', pnacl_label) 67 env.pnacl_base = os.path.join(env.nacl_root, 'toolchain', pnacl_label)
68 env.pnacl_root_newlib = os.path.join(env.pnacl_base, 'newlib') 68 env.pnacl_root_newlib = os.path.join(env.pnacl_base, 'newlib')
69 env.pnacl_root_glibc = os.path.join(env.pnacl_base, 'glibc') 69 env.pnacl_root_glibc = os.path.join(env.pnacl_base, 'glibc')
70 70
71 # QEMU 71 # QEMU
72 env.arm_root = os.path.join(env.nacl_root, 72 env.arm_root = os.path.join(env.nacl_root,
73 'toolchain', 'linux_arm-trusted') 73 'toolchain', 'linux_arm-trusted')
74 env.qemu = os.path.join(env.arm_root, 'run_under_qemu_arm') 74 env.qemu_arm = os.path.join(env.arm_root, 'run_under_qemu_arm')
75
76 env.mips32_root = os.path.join(env.nacl_root,
77 'toolchain', 'linux_mips-trusted')
78 env.qemu_mips32 = os.path.join(env.mips32_root, 'run_under_qemu_mips32')
75 79
76 # Path to 'readelf' 80 # Path to 'readelf'
77 env.readelf = FindReadElf() 81 env.readelf = FindReadElf()
78 82
79 # Path to 'scons' 83 # Path to 'scons'
80 env.scons = os.path.join(env.nacl_root, 'scons') 84 env.scons = os.path.join(env.nacl_root, 'scons')
81 85
82 # Library path for runnable-ld.so 86 # Library path for runnable-ld.so
83 env.library_path = [] 87 env.library_path = []
84 88
85 # Suppress -S -a 89 # Suppress -S -a
86 env.paranoid = False 90 env.paranoid = False
87 91
88 # Only print commands, don't run them 92 # Only print commands, don't run them
89 env.dry_run = False 93 env.dry_run = False
90 94
91 # Force a specific sel_ldr 95 # Force a specific sel_ldr
92 env.force_sel_ldr = None 96 env.force_sel_ldr = None
93 97
94 # Force a specific IRT 98 # Force a specific IRT
95 env.force_irt = None 99 env.force_irt = None
96 100
97 # Don't print anything 101 # Don't print anything
98 env.quiet = False 102 env.quiet = False
99 103
100 # Arch (x86-32, x86-64, arm) 104 # Arch (x86-32, x86-64, arm, mips32)
101 env.arch = None 105 env.arch = None
102 106
103 # Trace in QEMU 107 # Trace in QEMU
104 env.trace = False 108 env.trace = False
105 109
106 # Debug the nexe using the debug stub 110 # Debug the nexe using the debug stub
107 env.debug = False 111 env.debug = False
108 112
109 def PrintBanner(output): 113 def PrintBanner(output):
110 if not env.quiet: 114 if not env.quiet:
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 sel_ldr_args += [os.path.abspath(nexe)] + nexe_params 218 sel_ldr_args += [os.path.abspath(nexe)] + nexe_params
215 219
216 # Run sel_ldr! 220 # Run sel_ldr!
217 RunSelLdr(sel_ldr_args) 221 RunSelLdr(sel_ldr_args)
218 return 0 222 return 0
219 223
220 224
221 def RunSelLdr(args): 225 def RunSelLdr(args):
222 prefix = [] 226 prefix = []
223 if GetBuildArch().find('arm') == -1 and env.arch == 'arm': 227 if GetBuildArch().find('arm') == -1 and env.arch == 'arm':
224 prefix = [ env.qemu, '-cpu', 'cortex-a8'] 228 prefix = [ env.qemu_arm, '-cpu', 'cortex-a8']
225 if env.trace: 229 if env.trace:
226 prefix += ['-d', 'in_asm,op,exec,cpu'] 230 prefix += ['-d', 'in_asm,op,exec,cpu']
227 args = ['-Q'] + args 231 args = ['-Q'] + args
232
233 if GetBuildArch().find('mips32') == -1 and env.arch == 'mips32':
234 prefix = [env.qemu_mips32]
235 if env.trace:
236 prefix += ['-d', 'in_asm,op,exec,cpu']
237 args = ['-Q'] + args
228 238
229 # Use the bootstrap loader on linux. 239 # Use the bootstrap loader on linux.
230 if env.scons_os == 'linux': 240 if env.scons_os == 'linux':
231 bootstrap = os.path.join(os.path.dirname(env.sel_ldr), 241 bootstrap = os.path.join(os.path.dirname(env.sel_ldr),
232 'nacl_helper_bootstrap') 242 'nacl_helper_bootstrap')
233 loader = [bootstrap, env.sel_ldr] 243 loader = [bootstrap, env.sel_ldr]
234 template_digits = 'X' * 16 244 template_digits = 'X' * 16
235 args = ['--r_debug=0x' + template_digits, 245 args = ['--r_debug=0x' + template_digits,
236 '--reserved_at_zero=0x' + template_digits] + args 246 '--reserved_at_zero=0x' + template_digits] + args
237 else: 247 else:
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 Fatal('Missing argument to -L') 434 Fatal('Missing argument to -L')
425 else: 435 else:
426 path = arg[len('-L'):] 436 path = arg[len('-L'):]
427 env.library_path.append(path) 437 env.library_path.append(path)
428 elif arg == '-m32': 438 elif arg == '-m32':
429 env.arch = 'x86-32' 439 env.arch = 'x86-32'
430 elif arg == '-m64': 440 elif arg == '-m64':
431 env.arch = 'x86-64' 441 env.arch = 'x86-64'
432 elif arg == '-marm': 442 elif arg == '-marm':
433 env.arch = 'arm' 443 env.arch = 'arm'
444 elif arg == '-mmips32':
445 env.arch = 'mips32'
434 elif arg == '-arch': 446 elif arg == '-arch':
435 if i+1 < len(argv): 447 if i+1 < len(argv):
436 env.arch = FixArch(argv[i+1]) 448 env.arch = FixArch(argv[i+1])
437 skip_one = True 449 skip_one = True
438 elif arg == '--paranoid': 450 elif arg == '--paranoid':
439 env.paranoid = True 451 env.paranoid = True
440 elif arg.startswith('--loader='): 452 elif arg.startswith('--loader='):
441 env.force_sel_ldr = arg[len('--loader='):] 453 env.force_sel_ldr = arg[len('--loader='):]
442 elif arg.startswith('--irt='): 454 elif arg.startswith('--irt='):
443 env.force_irt = arg[len('--irt='):] 455 env.force_irt = arg[len('--irt='):]
(...skipping 20 matching lines...) Expand all
464 476
465 nexe_params = argv[i+1:] 477 nexe_params = argv[i+1:]
466 478
467 return sel_ldr_options, nexe, nexe_params 479 return sel_ldr_options, nexe, nexe_params
468 480
469 481
470 def FixArch(arch): 482 def FixArch(arch):
471 x86_32 = 'x86-32 x86_32 x8632 i386 i686 ia32'.split() 483 x86_32 = 'x86-32 x86_32 x8632 i386 i686 ia32'.split()
472 x86_64 = 'amd64 x86_64 x86-64 x8664'.split() 484 x86_64 = 'amd64 x86_64 x86-64 x8664'.split()
473 arm = 'arm armv7'.split() 485 arm = 'arm armv7'.split()
486 mips32 = 'mips mips32'.split()
474 487
475 if arch in x86_32: 488 if arch in x86_32:
476 return 'x86-32' 489 return 'x86-32'
477 490
478 if arch in x86_64: 491 if arch in x86_64:
479 return 'x86-64' 492 return 'x86-64'
480 493
481 if arch in arm: 494 if arch in arm:
482 return 'arm' 495 return 'arm'
483 496
497 if arch in mips32:
498 return 'mips32'
499
484 Fatal('Unrecognized arch "%s"!', arch) 500 Fatal('Unrecognized arch "%s"!', arch)
485 501
486 502
487 def Fatal(msg, *args): 503 def Fatal(msg, *args):
488 if len(args) > 0: 504 if len(args) > 0:
489 msg = msg % args 505 msg = msg % args
490 print msg 506 print msg
491 sys.exit(1) 507 sys.exit(1)
492 508
493 def Usage2(): 509 def Usage2():
494 # Try to find any sel_ldr that already exists 510 # Try to find any sel_ldr that already exists
495 for arch in ['x86-32','x86-64','arm']: 511 for arch in ['x86-32','x86-64','arm','mips32']:
496 SetupArch(arch, allow_build = False) 512 SetupArch(arch, allow_build = False)
497 if env.sel_ldr: 513 if env.sel_ldr:
498 break 514 break
499 515
500 if not env.sel_ldr: 516 if not env.sel_ldr:
501 # If nothing exists, build it. 517 # If nothing exists, build it.
502 SetupArch('x86-32') 518 SetupArch('x86-32')
503 519
504 RunSelLdr(['-h']) 520 RunSelLdr(['-h'])
505 521
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 563
548 if not machine_line: 564 if not machine_line:
549 Fatal('Script error: readelf output did not make sense!') 565 Fatal('Script error: readelf output did not make sense!')
550 566
551 if 'Intel 80386' in machine_line: 567 if 'Intel 80386' in machine_line:
552 arch = 'x86-32' 568 arch = 'x86-32'
553 elif 'X86-64' in machine_line: 569 elif 'X86-64' in machine_line:
554 arch = 'x86-64' 570 arch = 'x86-64'
555 elif 'ARM' in machine_line: 571 elif 'ARM' in machine_line:
556 arch = 'arm' 572 arch = 'arm'
573 elif 'MIPS' in machine_line:
574 arch = 'mips32'
557 else: 575 else:
558 Fatal('%s: Unknown machine type', f) 576 Fatal('%s: Unknown machine type', f)
559 577
560 return (arch, is_dynamic, is_glibc_static) 578 return (arch, is_dynamic, is_glibc_static)
561 579
562 580
563 def GetSconsOS(): 581 def GetSconsOS():
564 name = platform.system().lower() 582 name = platform.system().lower()
565 if name == 'linux': 583 if name == 'linux':
566 return 'linux' 584 return 'linux'
(...skipping 19 matching lines...) Expand all
586 # We've hit the file system root 604 # We've hit the file system root
587 break 605 break
588 606
589 if os.path.basename(curdir) != 'native_client': 607 if os.path.basename(curdir) != 'native_client':
590 Fatal('Unable to find native_client directory!') 608 Fatal('Unable to find native_client directory!')
591 return curdir 609 return curdir
592 610
593 611
594 if __name__ == '__main__': 612 if __name__ == '__main__':
595 sys.exit(main(sys.argv)) 613 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « no previous file | tests/callingconv/nacl.scons » ('j') | tests/syscall_return_sandboxing/sandboxed_mips.S » ('J')

Powered by Google App Engine
This is Rietveld 408576698