1#!/usr/bin/env python3 2# 3# Copyright (C) 2016 The Android Open Source Project 4# 5# Licensed under the Apache License, Version 2.0 (the 'License'); 6# you may not use this file except in compliance with the License. 7# You may obtain a copy of the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an 'AS IS' BASIS, 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14# See the License for the specific language governing permissions and 15# limitations under the License. 16 17import json 18import os 19import sys 20 21def main(): 22 try: 23 product_out = os.environ["ANDROID_PRODUCT_OUT"] 24 except KeyError: 25 sys.stderr.write("Can't get ANDROID_PRODUCT_OUT. Run lunch first.\n") 26 sys.exit(1) 27 28 filename = os.path.join(product_out, "module-info.json") 29 try: 30 with open(filename) as f: 31 modules = json.load(f) 32 except FileNotFoundError: 33 sys.stderr.write(f"File not found: {filename}\n") 34 sys.exit(1) 35 except json.JSONDecodeError: 36 sys.stderr.write(f"Invalid json: {filename}\n") 37 return None 38 39 classes = {} 40 41 for name, info in modules.items(): 42 make = info.get("make") 43 make_gen = info.get("make_generated_module_info") 44 if not make and make_gen: 45 classes.setdefault(frozenset(info.get("class")), []).append(name) 46 47 for cl, names in classes.items(): 48 print(" ".join(cl)) 49 for name in names: 50 print(" ", name) 51 52if __name__ == "__main__": 53 main() 54