• 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
22class InnerAPILoader(object):
23	@staticmethod
24	def load(mgr, product_out_path):
25		print("Loading innerapis now ...")
26		try:
27			innerapis = InnerAPILoader.__load_innerapi_modules(product_out_path)
28		except:
29			innerapis = []
30
31		if not mgr:
32			return
33
34		for elf in mgr.get_all():
35			if elf["labelPath"] in innerapis:
36				elf["innerapi_declared"] = True
37
38	def __load_innerapi_modules(product_out_path):
39		inner_kits_info = os.path.join(product_out_path, "build_configs/parts_info/inner_kits_info.json")
40		with open(inner_kits_info, "r") as f:
41			info = json.load(f)
42
43		innerapis = []
44		for name, component in info.items():
45			for mod_name, innerapi in component.items():
46				innerapis.append(innerapi["label"])
47
48		return innerapis
49