diff --git a/tools/deps_guard/elf_file_mgr/elf_file_mgr.py b/tools/deps_guard/elf_file_mgr/elf_file_mgr.py index c505628493fe939c6e3d9990c8f8be1cc5ce0521..87caf5d21c63ec412d20dd5383f1d8d1614a1e56 100755 --- a/tools/deps_guard/elf_file_mgr/elf_file_mgr.py +++ b/tools/deps_guard/elf_file_mgr/elf_file_mgr.py @@ -57,6 +57,7 @@ class Dependency(dict): from .module_info import CompileInfoLoader from .hdi import HdiParser from .sa import SAParser +from .innerapi import InnerAPILoader class ElfFileMgr(object): def __init__(self, product_out_path=None, elfFileClass=None, dependenceClass = None): diff --git a/tools/deps_guard/elf_file_mgr/innerapi/__init__.py b/tools/deps_guard/elf_file_mgr/innerapi/__init__.py new file mode 100755 index 0000000000000000000000000000000000000000..78622a6e242f08a2b9d9173bacb2ff100cfd6dda --- /dev/null +++ b/tools/deps_guard/elf_file_mgr/innerapi/__init__.py @@ -0,0 +1,4 @@ +#! /usr/bin/env python +#coding=utf-8 + +from .innerapi import InnerAPILoader diff --git a/tools/deps_guard/elf_file_mgr/innerapi/innerapi.py b/tools/deps_guard/elf_file_mgr/innerapi/innerapi.py new file mode 100755 index 0000000000000000000000000000000000000000..aa4709e52e5e1e63359acc43cb1d18eebdf70082 --- /dev/null +++ b/tools/deps_guard/elf_file_mgr/innerapi/innerapi.py @@ -0,0 +1,33 @@ +#! /usr/bin/env python +#coding=utf-8 + +import os +import json + +class InnerAPILoader(object): + @staticmethod + def load(mgr, product_out_path): + print("Loading innerapis now ...") + try: + innerapis = InnerAPILoader.__load_innerapi_modules(product_out_path) + except: + innerapis = [] + + if not mgr: + return + + for elf in mgr.get_all(): + if elf["labelPath"] in innerapis: + elf["innerapi_declared"] = True + + def __load_innerapi_modules(product_out_path): + inner_kits_info = os.path.join(product_out_path, "build_configs/parts_info/inner_kits_info.json") + with open(inner_kits_info, "r") as f: + info = json.load(f) + + innerapis = [] + for name, component in info.items(): + for mod_name, innerapi in component.items(): + innerapis.append(innerapi["label"]) + + return innerapis diff --git a/tools/deps_guard/elf_file_mgr/module_info/compile_info_loader.py b/tools/deps_guard/elf_file_mgr/module_info/compile_info_loader.py index a927fba720220bf8ac8e3e7c5e2ff8541b700b44..ee300fefb11b0c924bb2e984be5fa4e55316fbf1 100755 --- a/tools/deps_guard/elf_file_mgr/module_info/compile_info_loader.py +++ b/tools/deps_guard/elf_file_mgr/module_info/compile_info_loader.py @@ -30,9 +30,8 @@ class CompileInfoLoader(object): else: #print("%s has no label" % info["name"]) info["labelPath"] = "" - pos = info["labelPath"].find("(") - if pos > 0: - info["labelPath"] = info["labelPath"][:pos] + if info["labelPath"].find("(") > 0: + info["labelPath"] = info["labelPath"][:info["labelPath"].find("(")] if "subsystem_name" in item: info["subsystem"] = item["subsystem_name"] else: @@ -57,14 +56,11 @@ class CompileInfoLoader(object): info["chipset"] = False info["napi"] = False info["innerapi"] = False + info["innerapi_declared"] = False if "shlib_type" in item: info["shlib_type"] = item["shlib_type"] - if "innerapi" == info["shlib_type"]: - info["innerapi"] = True if "innerapi_tags" in item: - info["innerapi_tags"] = ",".join(item["innerapi_tags"]) - if "chipsetsdk" in item["innerapi_tags"] or "platformsdk" in item["innerapi_tags"]: - info["innerapi"] = True + info["innerapi_tags"] = item["innerapi_tags"] info["sa_id"] = 0 res.append(info) return res @@ -80,12 +76,13 @@ class CompileInfoLoader(object): "third_party": False, "chipset": False, "napi": False, - "innerapi": False, "sa_id": 0, "labelPath": "", "version_script": "", "shlib_type": "", - "innerapi_tags": "" + "innerapi": False, + "innerapi_tags": [], + "innerapi_declared": False } if info: @@ -126,7 +123,7 @@ class CompileInfoLoader(object): if "shlib_type" not in elf: elf["shlib_type"] = "" if "innerapi_tags" not in elf: - elf["innerapi_tags"] = "" + elf["innerapi_tags"] = [] if elf["labelPath"].startswith("//third_party/"): elf["third_party"] = True @@ -186,6 +183,7 @@ class CompileInfoLoader(object): else: caller["deps_external"].append(dep) callee["dependedBy_external"].append(dep) + callee["innerapi"] = True dep["external"] = True callee["modGroup"] = "innerapi_cc" # Cross component diff --git a/tools/deps_guard/rules_checker/chipsetsdk.py b/tools/deps_guard/rules_checker/chipsetsdk.py index 88f3bcd7e82d503dfffef7779577e5606b6de796..425b23855584d191f76d27603cad0366c557ab8d 100755 --- a/tools/deps_guard/rules_checker/chipsetsdk.py +++ b/tools/deps_guard/rules_checker/chipsetsdk.py @@ -14,7 +14,7 @@ class ChipsetSDKRule(BaseRule): return False if "ndk" in mod["innerapi_tags"]: return True - if mod["innerapi_tags"].endswith("chipsetsdk") or "chipsetsdk," in mod["innerapi_tags"]: + if "chipsetsdk" in mod["innerapi_tags"]: return True return False @@ -80,7 +80,7 @@ class ChipsetSDKRule(BaseRule): # If callee is in Chipset SDK white list module, it is OK if callee["name"] in lists: continue - + # If callee is asan library, it is OK if callee["name"].endswith(".asan.so"): continue