| OLD | NEW |
| 1 import os | 1 import os |
| 2 import subprocess | 2 import subprocess |
| 3 import sys | 3 import sys |
| 4 | 4 |
| 5 def shellcmd(command, echo=True): | 5 def shellcmd(command, echo=True): |
| 6 if not isinstance(command, str): | 6 if not isinstance(command, str): |
| 7 command = ' '.join(command) | 7 command = ' '.join(command) |
| 8 | 8 |
| 9 if echo: print '[cmd]', command | 9 if echo: print '[cmd]', command |
| 10 | 10 |
| 11 stdout_result = subprocess.check_output(command, shell=True) | 11 stdout_result = subprocess.check_output(command, shell=True) |
| 12 if echo: sys.stdout.write(stdout_result) | 12 if echo: sys.stdout.write(stdout_result) |
| 13 return stdout_result | 13 return stdout_result |
| 14 | 14 |
| 15 def FindBaseNaCl(): | 15 def FindBaseNaCl(): |
| 16 """Find the base native_client/ directory.""" | 16 """Find the base native_client/ directory.""" |
| 17 nacl = 'native_client' | 17 nacl = 'native_client' |
| 18 path_list = os.getcwd().split(os.sep) | 18 path_list = os.getcwd().split(os.sep) |
| 19 """Use the executable path if cwd does not contain 'native_client' """ |
| 20 path_list = path_list if nacl in path_list else sys.argv[0].split(os.sep) |
| 19 if nacl not in path_list: | 21 if nacl not in path_list: |
| 20 return None | 22 print "Script must be executed from within 'native_client' directory" |
| 23 exit(1) |
| 21 last_index = len(path_list) - path_list[::-1].index(nacl) | 24 last_index = len(path_list) - path_list[::-1].index(nacl) |
| 22 return os.sep.join(path_list[:last_index]) | 25 return os.sep.join(path_list[:last_index]) |
| 23 | 26 |
| 24 def get_sfi_string(args, sb_ret, nonsfi_ret, native_ret): | 27 def get_sfi_string(args, sb_ret, nonsfi_ret, native_ret): |
| 25 """Return a value depending on args.sandbox and args.nonsfi.""" | 28 """Return a value depending on args.sandbox and args.nonsfi.""" |
| 26 if args.sandbox: | 29 if args.sandbox: |
| 27 assert(not args.nonsfi) | 30 assert(not args.nonsfi) |
| 28 return sb_ret | 31 return sb_ret |
| 29 if args.nonsfi: | 32 if args.nonsfi: |
| 30 return nonsfi_ret | 33 return nonsfi_ret |
| 31 return native_ret | 34 return native_ret |
| OLD | NEW |