Chromium Code Reviews| 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 |
| 11 import os | 11 import os |
| 12 import re | |
| 12 import sys | 13 import sys |
| 14 import zipfile | |
| 13 | 15 |
| 14 from util import build_utils | 16 from util import build_utils |
| 15 | 17 |
| 16 | 18 |
| 17 def main(argv): | 19 def main(argv): |
| 18 option_parser = optparse.OptionParser() | 20 option_parser = optparse.OptionParser() |
| 19 build_utils.AddDepfileOption(option_parser) | 21 build_utils.AddDepfileOption(option_parser) |
| 20 option_parser.add_option('--aidl-path', help='Path to the aidl binary.') | 22 option_parser.add_option('--aidl-path', help='Path to the aidl binary.') |
| 21 option_parser.add_option('--imports', help='Files to import.') | 23 option_parser.add_option('--imports', help='Files to import.') |
| 22 option_parser.add_option('--includes', | 24 option_parser.add_option('--includes', |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 35 if options.includes is not None: | 37 if options.includes is not None: |
| 36 aidl_cmd += [ | 38 aidl_cmd += [ |
| 37 '-I' + s for s in build_utils.ParseGypList(options.includes) | 39 '-I' + s for s in build_utils.ParseGypList(options.includes) |
| 38 ] | 40 ] |
| 39 aidl_cmd += [ | 41 aidl_cmd += [ |
| 40 f, | 42 f, |
| 41 output | 43 output |
| 42 ] | 44 ] |
| 43 build_utils.CheckOutput(aidl_cmd) | 45 build_utils.CheckOutput(aidl_cmd) |
| 44 | 46 |
| 45 build_utils.ZipDir(options.srcjar, temp_dir) | 47 with zipfile.ZipFile(options.srcjar, 'w') as srcjar: |
|
Yaron
2015/09/29 17:24:05
As an alternative, how hard would it be to create
agrieve
2015/09/29 17:36:56
The .java files are deleted after the script runs,
Yaron
2015/09/29 17:48:00
Right, thanks for clarifying the gyp vs gn thing.
| |
| 48 for path in build_utils.FindInDirectory(temp_dir, '*.java'): | |
| 49 with open(path) as fileobj: | |
| 50 data = fileobj.read() | |
| 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)) | |
| 53 srcjar.writestr(arcname, data) | |
| 46 | 54 |
| 47 if options.depfile: | 55 if options.depfile: |
| 48 build_utils.WriteDepfile( | 56 build_utils.WriteDepfile( |
| 49 options.depfile, | 57 options.depfile, |
| 50 build_utils.GetPythonDependencies()) | 58 build_utils.GetPythonDependencies()) |
| 51 | 59 |
| 52 | 60 |
| 53 if __name__ == '__main__': | 61 if __name__ == '__main__': |
| 54 sys.exit(main(sys.argv)) | 62 sys.exit(main(sys.argv)) |
| OLD | NEW |