15f9996aaSopenharmony_ci#!/usr/bin/env python3 25f9996aaSopenharmony_ci# -*- coding: utf-8 -*- 35f9996aaSopenharmony_ci# Copyright (c) 2021 Huawei Device Co., Ltd. 45f9996aaSopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License"); 55f9996aaSopenharmony_ci# you may not use this file except in compliance with the License. 65f9996aaSopenharmony_ci# You may obtain a copy of the License at 75f9996aaSopenharmony_ci# 85f9996aaSopenharmony_ci# http://www.apache.org/licenses/LICENSE-2.0 95f9996aaSopenharmony_ci# 105f9996aaSopenharmony_ci# Unless required by applicable law or agreed to in writing, software 115f9996aaSopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS, 125f9996aaSopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 135f9996aaSopenharmony_ci# See the License for the specific language governing permissions and 145f9996aaSopenharmony_ci# limitations under the License. 155f9996aaSopenharmony_ci 165f9996aaSopenharmony_ciimport sys 175f9996aaSopenharmony_ciimport os 185f9996aaSopenharmony_ciimport argparse 195f9996aaSopenharmony_ci 205f9996aaSopenharmony_ci 215f9996aaSopenharmony_cidef run(args): 225f9996aaSopenharmony_ci exist_targets = [] 235f9996aaSopenharmony_ci for ndk_lib in args.ndk_lib_target_list: 245f9996aaSopenharmony_ci if not ndk_lib.startswith("//"): 255f9996aaSopenharmony_ci raise Exception( 265f9996aaSopenharmony_ci "ndk target '{}' configuration error.".format(ndk_lib)) 275f9996aaSopenharmony_ci _build_gn_file = ndk_lib[len('//'):].split(':')[0] 285f9996aaSopenharmony_ci ndk_lib_def_file = os.path.realpath( 295f9996aaSopenharmony_ci os.path.join(args.source_root_dir, _build_gn_file)) 305f9996aaSopenharmony_ci if not os.path.exists(ndk_lib_def_file): 315f9996aaSopenharmony_ci continue 325f9996aaSopenharmony_ci exist_targets.append(ndk_lib) 335f9996aaSopenharmony_ci return exist_targets 345f9996aaSopenharmony_ci 355f9996aaSopenharmony_ci 365f9996aaSopenharmony_cidef main(argv): 375f9996aaSopenharmony_ci parser = argparse.ArgumentParser() 385f9996aaSopenharmony_ci parser.add_argument('--ndk-lib-target-list', nargs='+', required=True) 395f9996aaSopenharmony_ci parser.add_argument('--source-root-dir', required=True) 405f9996aaSopenharmony_ci args = parser.parse_args(argv) 415f9996aaSopenharmony_ci exist_targets = run(args) 425f9996aaSopenharmony_ci for _target in exist_targets: 435f9996aaSopenharmony_ci print(_target) 445f9996aaSopenharmony_ci 455f9996aaSopenharmony_ci 465f9996aaSopenharmony_ciif __name__ == '__main__': 475f9996aaSopenharmony_ci sys.exit(main(sys.argv[1:])) 48