• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python
2#coding=utf-8
3
4#
5# Copyright (c) 2023-2024 Huawei Device Co., Ltd.
6# Licensed under the Apache License, Version 2.0 (the "License");
7# you may not use this file except in compliance with the License.
8# You may obtain a copy of the License at
9#
10#     http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS,
14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15# See the License for the specific language governing permissions and
16# limitations under the License.
17#
18
19from config_parser_mgr import ConfigParserMgr
20
21
22def __create_arg_parser():
23    import argparse
24    parser = argparse.ArgumentParser(description='Check startup architecture information from compiled output files.')
25    parser.add_argument('-i', '--input',
26                        help='input config files base directory example "out/rk3568" ', required=True)
27    parser.add_argument('-c', '--target_cpu',
28                    help='target_cpu cpu type" ', required=True)
29    parser.add_argument('-r', '--rules', action='append',
30                        help='rules directory', required=False)
31    parser.add_argument('-n', '--no_fail',
32                        help='force to pass all rules', required=False)
33    return parser
34
35def startup_guard(out_path, target_cpu ,args=None):
36    mgr = ConfigParserMgr()
37    mgr.load_all_parser(out_path, target_cpu)
38
39    from startup_checker import check_all_rules
40    passed = check_all_rules(mgr, args)
41    if passed:
42        print("All rules passed")
43    else:
44        print("Please modify according to README.md")
45
46if __name__ == '__main__':
47    parser = __create_arg_parser()
48    args = parser.parse_args()
49    startup_guard(args.input, args.target_cpu, args)
50