| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # | 2 # |
| 3 # Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 """Invokes Android's aidl | 7 """Invokes Android's aidl |
| 8 """ | 8 """ |
| 9 | 9 |
| 10 import optparse | 10 import optparse |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 help='Directories to add as import search paths.') | 25 help='Directories to add as import search paths.') |
| 26 option_parser.add_option('--srcjar', help='Path for srcjar output.') | 26 option_parser.add_option('--srcjar', help='Path for srcjar output.') |
| 27 options, args = option_parser.parse_args(argv[1:]) | 27 options, args = option_parser.parse_args(argv[1:]) |
| 28 | 28 |
| 29 with build_utils.TempDir() as temp_dir: | 29 with build_utils.TempDir() as temp_dir: |
| 30 for f in args: | 30 for f in args: |
| 31 classname = os.path.splitext(os.path.basename(f))[0] | 31 classname = os.path.splitext(os.path.basename(f))[0] |
| 32 output = os.path.join(temp_dir, classname + '.java') | 32 output = os.path.join(temp_dir, classname + '.java') |
| 33 aidl_cmd = [options.aidl_path] | 33 aidl_cmd = [options.aidl_path] |
| 34 aidl_cmd += [ | 34 aidl_cmd += [ |
| 35 '-p' + s for s in build_utils.ParseGypList(options.imports) | 35 '-p' + s for s in build_utils.ParseGnList(options.imports) |
| 36 ] | 36 ] |
| 37 if options.includes is not None: | 37 if options.includes is not None: |
| 38 aidl_cmd += [ | 38 aidl_cmd += [ |
| 39 '-I' + s for s in build_utils.ParseGypList(options.includes) | 39 '-I' + s for s in build_utils.ParseGnList(options.includes) |
| 40 ] | 40 ] |
| 41 aidl_cmd += [ | 41 aidl_cmd += [ |
| 42 f, | 42 f, |
| 43 output | 43 output |
| 44 ] | 44 ] |
| 45 build_utils.CheckOutput(aidl_cmd) | 45 build_utils.CheckOutput(aidl_cmd) |
| 46 | 46 |
| 47 with zipfile.ZipFile(options.srcjar, 'w') as srcjar: | 47 with zipfile.ZipFile(options.srcjar, 'w') as srcjar: |
| 48 for path in build_utils.FindInDirectory(temp_dir, '*.java'): | 48 for path in build_utils.FindInDirectory(temp_dir, '*.java'): |
| 49 with open(path) as fileobj: | 49 with open(path) as fileobj: |
| 50 data = fileobj.read() | 50 data = fileobj.read() |
| 51 pkg_name = re.search(r'^\s*package\s+(.*?)\s*;', data, re.M).group(1) | 51 pkg_name = re.search(r'^\s*package\s+(.*?)\s*;', data, re.M).group(1) |
| 52 arcname = '%s/%s' % (pkg_name.replace('.', '/'), os.path.basename(path)) | 52 arcname = '%s/%s' % (pkg_name.replace('.', '/'), os.path.basename(path)) |
| 53 srcjar.writestr(arcname, data) | 53 srcjar.writestr(arcname, data) |
| 54 | 54 |
| 55 if options.depfile: | 55 if options.depfile: |
| 56 build_utils.WriteDepfile( | 56 build_utils.WriteDepfile( |
| 57 options.depfile, | 57 options.depfile, |
| 58 build_utils.GetPythonDependencies()) | 58 build_utils.GetPythonDependencies()) |
| 59 | 59 |
| 60 | 60 |
| 61 if __name__ == '__main__': | 61 if __name__ == '__main__': |
| 62 sys.exit(main(sys.argv)) | 62 sys.exit(main(sys.argv)) |
| OLD | NEW |