From fb7218e7ced6dae1654ffc723835bda6e3696ac7 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Fri, 27 Oct 2017 17:50:42 +0000 Subject: Revert "Revert "Add makefile targets for ojluni jaif-annotated source files."" This reverts commit 554d65461915e1f9d2197a13d4ef39fa9964c809. This reapplies I9571a7841cbcc2790891352e0efc69327484736b with additional fixes for absolute OUT_DIR. Bug: 64930165 Bug: 68375156 Test: m checkbuild Test: m docs Change-Id: Iabb6689559752932f7e9a9bfb3c6d1077e844b1f --- 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