| OLD | NEW | 
|---|
|  | (Empty) | 
| 1 #!/usr/bin/python |  | 
| 2 # Copyright (c) 2014 The Native Client 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 # This is a thin wrapper for native LLC. This is not meant to be used by |  | 
| 7 # the user, only by the build system. |  | 
| 8 |  | 
| 9 import subprocess |  | 
| 10 |  | 
| 11 from driver_env import env |  | 
| 12 import driver_tools |  | 
| 13 |  | 
| 14 EXTRA_ENV = { |  | 
| 15   'ARGS'   : '', |  | 
| 16   'INPUT'  : '', |  | 
| 17   'OUTPUT' : '', |  | 
| 18   # Binary output may go to stdout (when -o was not specified) |  | 
| 19   'HAVE_OUTPUT' : '0', |  | 
| 20 } |  | 
| 21 |  | 
| 22 PATTERNS  = [ |  | 
| 23   (('-o','(.*)'),      "env.set('OUTPUT', pathtools.normalize($0))\n" + |  | 
| 24                        "env.set('HAVE_OUTPUT', '1')"), |  | 
| 25   ( '(-.*)',           "env.append('ARGS', $0)"), |  | 
| 26   ( '(.*)',            "env.set('INPUT', $0)"), |  | 
| 27 ] |  | 
| 28 |  | 
| 29 def main(argv): |  | 
| 30   env.update(EXTRA_ENV) |  | 
| 31   driver_tools.ParseArgs(argv, PATTERNS) |  | 
| 32 |  | 
| 33   driver_tools.CheckPathLength(env.getone('INPUT')) |  | 
| 34   driver_tools.CheckPathLength(env.getone('OUTPUT')) |  | 
| 35 |  | 
| 36   driver_tools.Run( |  | 
| 37       '"${LLVM_PNACL_LLC}" ${ARGS} ' + |  | 
| 38       '${HAVE_OUTPUT ? -o ${OUTPUT}} ' + |  | 
| 39       '${INPUT}') |  | 
| 40 |  | 
| 41   # only reached in case of no errors |  | 
| 42   return 0 |  | 
| 43 |  | 
| 44 def get_help(unused_argv): |  | 
| 45   # Set errexit=False -- Do not exit early to allow testing. |  | 
| 46   # For some reason most the llvm tools return non-zero with --help, |  | 
| 47   # while all of the gnu tools return 0 with --help. |  | 
| 48   # On windows, the exit code is also inconsistent =( |  | 
| 49   code, stdout, stderr = driver_tools.Run('${LLVM_PNACL_LLC} -help', |  | 
| 50                                           redirect_stdout=subprocess.PIPE, |  | 
| 51                                           redirect_stderr=subprocess.STDOUT, |  | 
| 52                                           errexit=False) |  | 
| 53 |  | 
| 54   help = """ |  | 
| 55 LLVM static compiler |  | 
| 56 |  | 
| 57 To translate PNaCl bitcode, use pnacl-translate instead. |  | 
| 58 |  | 
| 59 """ + stdout |  | 
| 60 |  | 
| 61   return help |  | 
| OLD | NEW | 
|---|