• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3
4#
5# Copyright (c) 2020 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
19import os
20import sys
21from hb_internal import CONFIG_JSON
22from hb_internal.common.utils import read_json_file
23from hb_internal.common.utils import hb_info
24from scripts.tools_checker import check_build_requried_packages, check_os_version
25sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "../../../")))
26
27
28OPTIONS_FUN_LIST = [
29        {
30            "para": "check",
31            "function":"check_dep"
32        }
33]
34
35
36def add_options(parser):
37    parser.add_argument('--check',
38                        help='compile-time environment dependencies',
39                        action='store_true')
40
41
42def check_dep():
43    host_info = check_os_version()
44    packages_info = check_build_requried_packages(host_info[1], check=False)
45    hb_info('necessary_package: {}'.format(','.join(packages_info[0])))
46    hb_info('installed_package: {}'.format(','.join(packages_info[1])))
47    hb_info('uninstalled_package: {}'.format(','.join(packages_info[2])))
48
49
50def check_os_info():
51    json_data = read_json_file(CONFIG_JSON)
52    root_path = json_data.get('root_path', 'not set')
53    board = json_data.get('board', 'not set')
54    kernel = json_data.get('kernel', 'not set')
55    product = json_data.get('product', 'not set')
56    product_path = json_data.get('product_path', 'not set')
57    device_path = json_data.get('device_path', 'not set')
58    device_company = json_data.get('device_company', 'not set')
59
60    hb_info('root path: {}'.format(root_path))
61    hb_info('board: {}'.format(board))
62    hb_info('kernel: {}'.format(kernel))
63    hb_info('product: {}'.format(product))
64    hb_info('product path: {}'.format(product_path))
65    hb_info('device path: {}'.format(device_path))
66    hb_info('device company: {}'.format(device_company))
67
68
69def para_to_function(para):
70    for options in OPTIONS_FUN_LIST:
71        if options["para"] == para:
72            eval(options["function"])()
73
74
75def exec_command(args):
76    args_list = [e for e in dir(args) if not e.startswith('_')]
77    for para in args_list:
78        options_list = []
79        options_list.append("args.{}".format(para))
80        for _options in options_list:
81            if eval(_options):
82                para_to_function(para)
83                break
84        else:
85            check_os_info()
86