• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python
2#coding=utf-8
3
4#
5# Copyright (c) 2022 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 json
21
22
23class InnerAPILoader(object):
24    @staticmethod
25    def load(mgr, product_out_path):
26        print("Loading innerapis now ...")
27        try:
28            innerapis = InnerAPILoader.__load_innerapi_modules(product_out_path)
29        except:
30            innerapis = []
31
32        if not mgr:
33            return
34
35        for elf in mgr.get_all():
36            if elf["labelPath"] in innerapis:
37                elf["innerapi_declared"] = True
38
39    def __load_innerapi_modules(product_out_path):
40        inner_kits_info = os.path.join(product_out_path, "build_configs/parts_info/inner_kits_info.json")
41        with open(inner_kits_info, "r") as f:
42            info = json.load(f)
43
44        innerapis = []
45        for name, component in info.items():
46            for mod_name, innerapi in component.items():
47                innerapis.append(innerapi["label"])
48
49        return innerapis
50