Home | History | Annotate | Download | only in gyp
      1 #!/usr/bin/env python
      2 #
      3 # Copyright 2014 The Chromium Authors. All rights reserved.
      4 # Use of this source code is governed by a BSD-style license that can be
      5 # found in the LICENSE file.
      6 
      7 """Invokes Android's aidl
      8 """
      9 
     10 import optparse
     11 import os
     12 import sys
     13 
     14 from util import build_utils
     15 
     16 
     17 def main(argv):
     18   option_parser = optparse.OptionParser()
     19   build_utils.AddDepfileOption(option_parser)
     20   option_parser.add_option('--aidl-path', help='Path to the aidl binary.')
     21   option_parser.add_option('--imports', help='Files to import.')
     22   option_parser.add_option('--includes',
     23                            help='Directories to add as import search paths.')
     24   option_parser.add_option('--srcjar', help='Path for srcjar output.')
     25   options, args = option_parser.parse_args(argv[1:])
     26 
     27   with build_utils.TempDir() as temp_dir:
     28     for f in args:
     29       classname = os.path.splitext(os.path.basename(f))[0]
     30       output = os.path.join(temp_dir, classname + '.java')
     31       aidl_cmd = [options.aidl_path]
     32       aidl_cmd += [
     33         '-p' + s for s in build_utils.ParseGypList(options.imports)
     34       ]
     35       if options.includes is not None:
     36         aidl_cmd += [
     37           '-I' + s for s in build_utils.ParseGypList(options.includes)
     38         ]
     39       aidl_cmd += [
     40         f,
     41         output
     42       ]
     43       build_utils.CheckOutput(aidl_cmd)
     44 
     45     build_utils.ZipDir(options.srcjar, temp_dir)
     46 
     47   if options.depfile:
     48     build_utils.WriteDepfile(
     49         options.depfile,
     50         build_utils.GetPythonDependencies())
     51 
     52 
     53 if __name__ == '__main__':
     54   sys.exit(main(sys.argv))
     55