diff options
author | Przemyslaw Szczepaniak <pszczepaniak@google.com> | 2017-09-26 13:42:44 +0100 |
---|---|---|
committer | Przemyslaw Szczepaniak <pszczepaniak@google.com> | 2017-10-26 12:42:23 +0100 |
commit | eb55e5c38f1c374897a60f17627a153480e608bd (patch) | |
tree | 41e140d4026e05b6472e693579315ceb86889d36 /annotations/generate_annotated_java_files.py | |
parent | db279ae6db5345a0b5455516f14d0316b739f520 (diff) |
Add makefile targets for ojluni jaif-annotated source files.
Second attempt, this time with fixed list of targets in blueprints
and with less broken python code.
Test: make docs
Bug: 64930165
Change-Id: I9571a7841cbcc2790891352e0efc69327484736b
Diffstat (limited to 'annotations/generate_annotated_java_files.py')
-rwxr-xr-x | annotations/generate_annotated_java_files.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/annotations/generate_annotated_java_files.py b/annotations/generate_annotated_java_files.py new file mode 100755 index 0000000000..de8b131da6 --- /dev/null +++ b/annotations/generate_annotated_java_files.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python + +"""Generate annotated_java_files.bp from a jaif file.""" +import os + +PACKAGE_STRING = 'package ' +CLASS_STRING = 'class ' +SRC_PREFIX = 'ojluni/src/main/java/' + +BP_TEMPLATE = '''filegroup { + name: "annotated_ojluni_files", + export_to_make_var: "annotated_ojluni_files", + srcs: [ +%s + ], +}''' + +srcs_list = [] +current_package = None +with open(os.sys.argv[1], 'r') as jaif_file: + for line in jaif_file: + if line.startswith(PACKAGE_STRING): + current_package = line[len(PACKAGE_STRING): line.find(':')] + if line.startswith(CLASS_STRING) and current_package is not None: + current_class = line[len(CLASS_STRING): line.find(':')] + srcs_list.append(SRC_PREFIX + current_package.replace('.', '/') + '/' + current_class + '.java') + +print '// Do not edit; generated using libcore/annotations/generate_annotated_java_files.py' +print BP_TEMPLATE % ('\n'.join([' "' + src_entry + '",' for src_entry in sorted(srcs_list)]),) +os.sys.exit(0) |