1#!/usr/bin/env python3 2# -*- coding: utf-8 -*- 3# Copyright (c) 2023 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 os 17import sys 18import argparse 19 20import check_deps_handler 21import check_external_deps 22import check_part_subsystem_name 23sys.path.append( 24 os.path.dirname(os.path.dirname(os.path.dirname( 25 os.path.abspath(__file__))))) 26from scripts.util.build_utils import write_depfile, add_depfile_option, touch # noqa: E402 27 28 29def parse_args(): 30 parser = argparse.ArgumentParser() 31 add_depfile_option(parser) 32 parser.add_argument("--skip-check-subsystem", required=False, action="store_true") 33 parser.add_argument('--part-name', required=True) 34 parser.add_argument('--subsystem-name', required=True) 35 parser.add_argument('--target-path', required=True) 36 parser.add_argument('--deps', nargs='*', required=False) 37 parser.add_argument('--external-deps', nargs='*', required=False) 38 parser.add_argument('--output', required=True) 39 parser.add_argument('--compile-standard-allow-file', required=True) 40 args = parser.parse_args() 41 42 return args 43 44 45def main(): 46 args = parse_args() 47 48 depfiles = [] 49 if not args.skip_check_subsystem: 50 _depfile = check_part_subsystem_name.check(args) 51 depfiles.extend(_depfile) 52 53 if args.deps: 54 _depfile = check_deps_handler.check(args) 55 depfiles.extend(_depfile) 56 57 if args.external_deps: 58 _depfile = check_external_deps.check(args) 59 depfiles.extend(_depfile) 60 61 if depfiles: 62 depfiles = list(set(depfiles)) 63 write_depfile(args.depfile, args.output, depfiles) 64 65 touch(args.output) 66 67 return 0 68 69 70if __name__ == '__main__': 71 sys.exit(main()) 72