From eb55e5c38f1c374897a60f17627a153480e608bd Mon Sep 17 00:00:00 2001 From: Przemyslaw Szczepaniak Date: Tue, 26 Sep 2017 13:42:44 +0100 Subject: 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 --- annotations/generate_annotated_java_files.py | 30 ++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 annotations/generate_annotated_java_files.py (limited to 'annotations/generate_annotated_java_files.py') 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) -- cgit v1.2.3