Home | History | Annotate | Download | only in bindings
      1 #!/usr/bin/env python
      2 # Copyright 2016 The Chromium 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 import sys
      7 
      8 # This utility converts mojom dependencies into their corresponding typemap
      9 # paths and formats them to be consumed by generate_type_mappings.py.
     10 
     11 
     12 def FormatTypemap(typemap_filename):
     13   # A simple typemap is valid Python with a minor alteration.
     14   with open(typemap_filename) as f:
     15     typemap_content = f.read().replace('=\n', '=')
     16   typemap = {}
     17   exec typemap_content in typemap
     18 
     19   for header in typemap.get('public_headers', []):
     20     yield 'public_headers=%s' % header
     21   for header in typemap.get('traits_headers', []):
     22     yield 'traits_headers=%s' % header
     23   for header in typemap.get('type_mappings', []):
     24     yield 'type_mappings=%s' % header
     25 
     26 
     27 def main():
     28   typemaps = sys.argv[1:]
     29   print ' '.join('--start-typemap %s' % ' '.join(FormatTypemap(typemap))
     30                  for typemap in typemaps)
     31 
     32 
     33 if __name__ == '__main__':
     34   sys.exit(main())
     35