1#!/usr/bin/env python 2# -*- coding: utf-8 -*- 3# Copyright (c) 2021 Huawei Device Co., Ltd. 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15 16import argparse 17import sys 18import os 19import zipfile 20import json 21 22sys.path.append( 23 os.path.dirname(os.path.dirname( 24 os.path.abspath(__file__)))) 25from scripts.util import build_utils # noqa: E402 26 27 28def get_java_sources_file(build_config: str): 29 with open(build_config, 'r') as file: 30 data = json.load(file) 31 return data.get('deps_info').get('java_sources_file') 32 33 34def main(): 35 parser = argparse.ArgumentParser() 36 build_utils.add_depfile_option(parser) 37 38 parser.add_argument('--input', required=True) 39 parser.add_argument('--output', default=None) 40 41 options = parser.parse_args() 42 43 depfiles = [] 44 with open(options.input, 'r') as file: 45 kits_info = json.load(file) 46 for module in kits_info: 47 if module.get('type') != 'jar': 48 continue 49 build_config = module.get('build_config') 50 depfiles.append(build_config) 51 module['source_list_file'] = get_java_sources_file(build_config) 52 53 build_utils.write_json(kits_info, options.output) 54 55 build_utils.write_depfile(options.depfile, 56 options.output, 57 depfiles, 58 add_pydeps=False) 59 60 61if __name__ == '__main__': 62 sys.exit(main()) 63