| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2011 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 # IMPORTANT NOTE: If you make local mods to this file, you must run: | 6 # IMPORTANT NOTE: If you make local mods to this file, you must run: |
| 7 # % tools/llvm/utman.sh driver | 7 # % pnacl/build.sh driver |
| 8 # in order for them to take effect in the scons build. This command | 8 # in order for them to take effect in the scons build. This command |
| 9 # updates the copy in the toolchain/ tree. | 9 # updates the copy in the toolchain/ tree. |
| 10 # | 10 # |
| 11 | 11 |
| 12 # Show the PNaCl metadata of a bitcode file | 12 # Show the PNaCl metadata of a bitcode file. |
| 13 | 13 |
| 14 from driver_tools import * | 14 from driver_tools import * |
| 15 from driver_env import env | 15 from driver_env import env |
| 16 from driver_log import Log, DriverExit | 16 from driver_log import Log, DriverExit |
| 17 | 17 |
| 18 EXTRA_ENV = { | 18 EXTRA_ENV = { |
| 19 'INPUTS' : '', | 19 'INPUTS' : '', |
| 20 } | 20 } |
| 21 env.update(EXTRA_ENV) | 21 env.update(EXTRA_ENV) |
| 22 | 22 |
| 23 META_PATTERNS = [ | 23 META_PATTERNS = [ |
| 24 ( '(.*)', "env.append('INPUTS', pathtools.normalize($0))"), | 24 ( '(.*)', "env.append('INPUTS', pathtools.normalize($0))"), |
| 25 ] | 25 ] |
| 26 | 26 |
| 27 def Usage(): | 27 def Usage(): |
| 28 print "Usage: pnacl-meta [files...]" | 28 print "Usage: pnacl-meta [files...]" |
| 29 print "Show the PNaCl-specific metadata of a bitcode file" | 29 print "Show the PNaCl-specific metadata of a bitcode file" |
| 30 | 30 |
| 31 def OutputAll(input_file, metadata): |
| 32 print pathtools.touser(input_file) + ":" |
| 33 for k, v in metadata.iteritems(): |
| 34 if isinstance(v, list): |
| 35 v = '[ ' + ', '.join(v) + ' ]' |
| 36 print ' %-12s: %s' % (k, v) |
| 37 else: |
| 38 print ' %-12s: %s' % (k, v) |
| 39 |
| 31 def main(argv): | 40 def main(argv): |
| 32 ParseArgs(argv, META_PATTERNS) | 41 ParseArgs(argv, META_PATTERNS) |
| 33 | |
| 34 inputs = env.get('INPUTS') | 42 inputs = env.get('INPUTS') |
| 35 | 43 |
| 36 if not inputs: | 44 if not inputs: |
| 37 Usage() | 45 Usage() |
| 38 DriverExit(0) | 46 DriverExit(0) |
| 39 | 47 |
| 40 for f in inputs: | 48 for f in inputs: |
| 41 if not IsBitcode(f): | 49 if not IsBitcode(f): |
| 42 Log.Fatal("%s: File is not bitcode", pathtools.touser(f)) | 50 Log.Fatal("%s: File is not bitcode", pathtools.touser(f)) |
| 43 metadata = GetBitcodeMetadata(f) | 51 metadata = GetBitcodeMetadata(f) |
| 44 print pathtools.touser(f) + ":" | 52 OutputAll(f, metadata) |
| 45 for k, v in metadata.iteritems(): | |
| 46 if isinstance(v, list): | |
| 47 v = "[ " + ', '.join(v) + " ]" | |
| 48 print " %-12s: %s" % (k, v) | |
| 49 | 53 |
| 50 return 0 | 54 return 0 |
| 51 | 55 |
| 52 if __name__ == "__main__": | 56 if __name__ == "__main__": |
| 53 DriverMain(main) | 57 DriverMain(main) |
| OLD | NEW |