diff --git a/tools/deps_guard/deps_guard.py b/tools/deps_guard/deps_guard.py index 5572aab0fd0a1712e7fa22fdae4ae8ce22f0b946..987619b6e0957cf6a02c93378e137227adda3417 100755 --- a/tools/deps_guard/deps_guard.py +++ b/tools/deps_guard/deps_guard.py @@ -62,7 +62,7 @@ def _startup_guard_module(out_path, args): def deps_guard(out_path, args=None): _deps_guard_module(out_path, args) - _startup_guard_module(out_path, args) + #_startup_guard_module(out_path, args) if __name__ == '__main__': diff --git a/tools/deps_guard/elf_file_mgr/sa/sa.py b/tools/deps_guard/elf_file_mgr/sa/sa.py index 0665fbfb68b7096c04e7374f02818620303c7f8e..ada67e43e091ba0b016832db5367fb7874ab70c3 100755 --- a/tools/deps_guard/elf_file_mgr/sa/sa.py +++ b/tools/deps_guard/elf_file_mgr/sa/sa.py @@ -30,17 +30,15 @@ def xml_node_find_by_name(node, name): class SAParser(object): @staticmethod - def __parse_sa_profile(all_sa, f): - root = ET.parse(f).getroot() - process = xml_node_find_by_name(root, "process") - for sa in root.findall("systemability"): - libpath = xml_node_find_by_name(sa, "libpath") + def __parse_sa_profile(all_sa, full_name): + with open(full_name, "r") as f: + profile = json.load(f) + process = profile["process"] + for sa in profile["systemability"]: + libpath = sa["libpath"] sa_key = os.path.basename(libpath) - sa_item = {} - for item in sa: - sa_item[item.tag] = item.text - sa_item["process"] = process - all_sa[sa_key] = sa_item + sa["process"] = process + all_sa[sa_key] = sa @staticmethod def __add_sa_info(all_sa, mgr): @@ -61,10 +59,14 @@ class SAParser(object): for f in os.listdir(path): full_name = os.path.join(path, f) - if os.path.isfile(full_name) and f.endswith(".xml"): + if os.path.isfile(full_name) and f.endswith(".json"): try: SAParser.__parse_sa_profile(all_sa, full_name) except: pass SAParser.__add_sa_info(all_sa, mgr) + +if __name__ == '__main__': + parser = SAParser() + parser.load(None, "/home/handy/qemu/out/rk3568") diff --git a/tools/deps_guard/rules/ChipsetSDK/README.md b/tools/deps_guard/rules/ChipsetSDK/README.md index 5a4e825ea640556e928e832a6cfd021912ed618d..bb0141fbc2b89eb3d581badc1529535de260f408 100755 --- a/tools/deps_guard/rules/ChipsetSDK/README.md +++ b/tools/deps_guard/rules/ChipsetSDK/README.md @@ -1,4 +1,4 @@ -# ChipsetSDK白名单规则说明 +# Chipset SDK白名单规则说明 @@ -8,66 +8,119 @@ 芯片组件模块:安装到chipset.img中的模块,与芯片或硬件强相关。 +![image-20230630112928911](./images/chipsetsdk.png) +如上图所示:Chipset SDK是指允许被芯片组件进程加载的系统组件动态库模块集合。 -Chipset SDK是指允许被芯片组件模块依赖的系统组件动态库模块集合。 +Chipset SDK集合中的单个模块称之为Chipset SDK模块。Chipset SDK模块分为两类,在BUILD.gn中通过innerapi_tags字段来标识,可选值为: -Chipset SDK集合中的单个模块称之为ChipsetSDK模块。 +- chipsetsdk: 芯片组件直接依赖的模块 +- chipsetsdk_indirect: chipsetsdk模块间接依赖的模块 -## 2. 规则解释 - -Chipset SDK白名单规则有几个方面的含义: - -### 2.1 Chipset SDK模块需要在编译模板中标识 - -如下图所示,每个Chipset SDK模块需要在对应的BUILD.gn中通过innerapi_tags增加chipsetsdk标签来标识其类型: +在BUILD.gn中的使用样例如下: ```go -ohos_shared_library(sample_sa_module) { +ohos_shared_library(sample_chipsetsdk_module) { ... - innerapi_tags = [ "chipsetsdk" ] + innerapi_tags = [ "chipsetsdk|chipsetsdk_indirect" ] ... } ``` -如果没有此标记,编译时会提示如下类型的告警: +chipsetsdk和chipsetsdk_indirect类型的模块都需要被芯片组件进程加载,这两个类型的模块都会安装到/chipset/lib{64}/chipset-sdk或/chipset/lib{64}/chipset-pub-sdk目录下,都可以被芯片组件沙盒访问。 -```shell -[WARNING]: Chipset SDK module libinit_stub_empty.so has no innerapi_tags with "chipsetsdk" or "csdk", add it in //base/startup/init/interfaces/innerkits/init_module_engine:libinit_stub_empty -``` +相比较于/chipset/lib{64}/chipset-sdk目录,/chipset/lib{64}/chipset-pub-sdk目录下的模块既能被芯片组件沙盒访问,也能被应用进程沙盒访问。 -同样,非Chipset SDK不要增加此标记。 +## 2. 规则解释 + +Chipset SDK白名单规则有几个方面的含义: -### 2.2 芯片组件模块不允许依赖Chipset SDK集合之外的模块 +### 2.1 芯片组件模块编译时能且仅能依赖系统组件中的chipsetsdk类型的ChipsetSDK模块 -违法此规则时,会产生如下格式的NOT ALLOWED错误: +违反此规则时,编译过程会产生如下格式的NOT ALLOWED错误: ``` [NOT ALLOWED]: chipset module libNNN.z.so depends on non Chipset SDK module libsystemMMM.z.so in //NNNpath:libNNN ``` -该错误的含义是:芯片组件的libNNN.z.so模块依赖了libsystemMMM.z.so,而libsystemMMM.z.so并不是被认可(白名单中)的模块。 +该错误的含义是:芯片组件的libNNN.z.so模块依赖了libsystemMMM.z.so,而libsystemMMM.z.so并不是Chipset SDK的模块。 -违法此规则时,参考下一章节的处理方案进行消除: +处理方法: -## 3. 违规场景及处理方案建议 +1)检查libNNN.z.so是否需要安装到芯片组件中?如果是系统组件的产物,就不受此规则约束。一般是在BUILD.gn中的install_images字段决定安装到哪个组件中。 -### 3.1 检查违规模块的安装组件是否正确 +2)如果libNNN.z.so确实需要安装到芯片组件中,则分析对libsystemMMM.z.so的依赖是否是必须的。经常会出现libNNN.z.so是一个巨型库,对libsystemMMM.z.so的依赖部分并不会被芯片组件实际使用,此时可以考虑把libNNN.z.so进行拆分,把芯片组件确实需要使用的部分保留在芯片组件中;不需要的部分放在系统组件其它的库里。 -首先确认libNNN.z.so是否应该是芯片组件产物,只有与硬件相关的HDI实现模块才需要安装到芯片组件。 +3)如果以上都不满足,需要联系libsystemMMM.z.so的提供者,把此模块整改为Chipset SDK模块。参考第3章Chipset SDK模块基本要求。 -如下所示,每个模块是通过install_images选项来决定安装到系统组件还是芯片组件;如果系统组件模块错误的安装到芯片组件,可能会因为该模块依赖了Chipset SDK之外的系统组件模块而违反此规则。 +### 2.2 Chipset SDK模块能且仅能依赖其它的Chipset SDK模块 + +违反此规则时,编译过程会产生如下格式的NOT ALLOWED错误: -```go -ohos_shared_library(libNNN) { - ... - install_images = [ chipset_base_dir ] - ... -} ``` +[NOT ALLOWED]: Chipset SDK module libNNN.z.so depends on non Chipset SDK module libsystemMMM.z.so in //NNNpath:libNNN +``` + +该错误的含义是:系统组件中的libNNN.z.so模块是Chipset SDK模块,其依赖的libsystemMMM.z.so并不是Chipset SDK模块。 + +处理方法: + +1)分析新增对libsystemMMM.z.so的依赖是否合理。 + +2)如果以上都不满足,可以有两种处理方法: + +a)为libsystemMMM.z.so增加chipsetsdk_indirect类型的innerapi_tags,表示此模块为间接依赖模块。 + +b)联系libsystemMMM.z.so的提供者,把此模块整改为Chipset SDK模块,增加chipsetsdk类型的innerapi_tags。参考第3章Chipset SDK模块基本要求。 + +### 2.3 Chipset SDK模块白名单管理 + +- Chipset SDK模块没有标记类型 + + 每个Chipset SDK模块都需要在innerapi_tags中加上chipsetsdk或chipsetsdk_indirect标记;否则会报以下类型的错误: + + ```shell + [ERROR]: Chipset SDK module libxxx.so has no innerapi_tags with "chipsetsdk", add it in //base/startup/init/interfaces/innerkits/init_module_engine:libinit_stub_empty + ``` + + 处理方法:按照提示在对应的BUILD.gn中添加innerapi_tags标记。 + +- 非Chipset SDK模块添加了Chipset SDK模块标记 + + 非Chipset SDK模块不要添加chipsetsdk或chipsetsdk_indirect标记;否则会报以下类型的错误: + + ```shell + [ERROR]: non chipsetsdk_indirect module libdfx_dumpcatcher.z.so with innerapi_tags="chipsetsdk_indirect", //base/hiviewdfx/faultloggerd/interfaces/innerkits/dump_catcher:libdfx_dumpcatcher + ``` + + 处理方法:按照提示在对应的BUILD.gn中去掉innerapi_tags中的标记。 + + + +## 3. Chipset SDK模块基本要求 + +### 3.1 Chipset SDK模块所属部件必须加入最小系统部件集 + +为了支持芯片组件独立编译,每个Chipset SDK模块所属的部件必须是[最小系统部件集合](https://gitee.com/openharmony/productdefine_common/base/standard_system.json)中的部件,确保最小系统可以正常编译;防止芯片组件编译时需要引入其他过多的系统组件部件。 + +--- + +三方库模块不需要加入最小系统部件集合。 + +---- + +### 3.2 Chipset SDK模块对外API需稳定 + +Chipset SDK模块提供了跨组件的接口,需要维护稳定的对外API。基本要求如下: + +1)对外头文件需要在所属部件bundle.json中标注 + +2)对外头文件需要清晰的文档注释 + +3)对外API变更时需要向前兼容 -因此,首先需要检查违规模块是否安装到了错误的组件;如果libNNN.z.so不是芯片组件的产物,则install_images里不能填chipset_base_dir;删除install_images后,默认就是安装到系统组件。 +### 3.3 Chipset SDK模块需加入到白名单列表 -### 3.2 申请新的Chipset SDK模块 +chipsetsdk_indirect类型的Chipset SDK模块需加入到[chipsetsdk_indirect.json](chipsetsdk_indirect.json)文件中 -如果经过分析,芯片组件的libNNN.z.so确实需要引入新的Chipset SDK模块,可向架构SIG申请加入Chipset SDK白名单。 +chipsetsdk类型的Chipset SDK模块需加入到[whitelist.json](whitelist.json)文件中,同时需要更新模块描述信息文件[chipsetsdk_info.json](chipsetsdk_info.json)。 diff --git a/tools/deps_guard/rules/ChipsetSDK/chipsetsdk_indirect.json b/tools/deps_guard/rules/ChipsetSDK/chipsetsdk_indirect.json new file mode 100755 index 0000000000000000000000000000000000000000..ff4205b49effcfc3a1869fa8b1091ff77b4f7998 --- /dev/null +++ b/tools/deps_guard/rules/ChipsetSDK/chipsetsdk_indirect.json @@ -0,0 +1,12 @@ +[ + "libclang_rt.ubsan_minimal.so", + "libdisplay_buffer_proxy_1.0.z.so", + "libeventhandler.z.so", + "libselinux.z.so", + "libpcre2.z.so", + "libhitracechain.so", + "libdisplay_buffer_hdi_impl.z.so", + "libipc_common.z.so", + "libnghttp2_shared.z.so", + "libssl_openssl.z.so" +] \ No newline at end of file diff --git a/tools/deps_guard/rules/ChipsetSDK/chipsetsdk_info.json b/tools/deps_guard/rules/ChipsetSDK/chipsetsdk_info.json new file mode 100644 index 0000000000000000000000000000000000000000..dc6068c39bb3ba383755f732211fa2ce0736471b --- /dev/null +++ b/tools/deps_guard/rules/ChipsetSDK/chipsetsdk_info.json @@ -0,0 +1,350 @@ +[ + { + "name": "hdf_core:libhdf_utils", + "so_file_name": "libhdf_utils.z.so", + "path": "//drivers/hdf_core/adapter/uhdf2/utils:libhdf_utils", + "headers": [ + "//drivers/hdf_core/interfaces/inner_api/osal/shared/osal_mem.h", + "//drivers/hdf_core/interfaces/inner_api/osal/shared/osal_time.h", + "//drivers/hdf_core/interfaces/inner_api/osal/uhdf/hdf_log_adapter.h", + "//drivers/hdf_core/interfaces/inner_api/osal/uhdf/hdf_types.h", + "//drivers/hdf_core/interfaces/inner_api/utils/hdf_base.h", + "//drivers/hdf_core/interfaces/inner_api/utils/hdf_log.h", + "//drivers/hdf_core/interfaces/inner_api/utils/hdf_sbuf.h", + "//drivers/hdf_core/interfaces/inner_api/utils/hdf_dlist.h", + "//drivers/hdf_core/interfaces/inner_api/core/hdf_device_class.h", + "//drivers/hdf_core/interfaces/inner_api/core/hdf_object.h", + "//drivers/hdf_core/interfaces/inner_api/core/hdf_service_status.h" + ] + }, + { + "name": "hilog:libhilog", + "so_file_name": "libhilog.so", + "path": "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", + "headers": [ + "//base/hiviewdfx/hilog/interfaces/native/innerkits/include/hilog/log.h", + "//base/hiviewdfx/hilog/interfaces/native/innerkits/include/hilog/log_c.h", + "//base/hiviewdfx/hilog/interfaces/native/innerkits/include/hilog/log_cpp.h", + "//base/hiviewdfx/hilog/interfaces/native/innerkits/include/hilog_trace.h" + ] + }, + { + "name": "bounds_checking_function:libsec_shared", + "so_file_name": "libsec_shared.z.so", + "path": "//third_party/bounds_checking_function:libsec_shared", + "headers": [ + "//third_party/bounds_checking_function/include/securec.h", + "//third_party/bounds_checking_function/include/securectype.h" + ] + }, + { + "name": "common:musl-libc.so", + "so_file_name": "libc.so", + "path": "//build/common/musl:musl-libc.so", + "headers": [] + }, + { + "name": "c_utils:utils", + "so_file_name": "libutils.z.so", + "path": "//commonlibrary/c_utils/base:utils", + "headers": [ + "//commonlibrary/c_utils/base/include/ashmem.h", + "//commonlibrary/c_utils/base/include/common_errors.h", + "//commonlibrary/c_utils/base/include/common_timer_errors.h", + "//commonlibrary/c_utils/base/include/datetime_ex.h", + "//commonlibrary/c_utils/base/include/directory_ex.h", + "//commonlibrary/c_utils/base/include/errors.h", + "//commonlibrary/c_utils/base/include/file_ex.h", + "//commonlibrary/c_utils/base/include/flat_obj.h", + "//commonlibrary/c_utils/base/include/nocopyable.h", + "//commonlibrary/c_utils/base/include/observer.h", + "//commonlibrary/c_utils/base/include/parcel.h", + "//commonlibrary/c_utils/base/include/pubdef.h", + "//commonlibrary/c_utils/base/include/refbase.h", + "//commonlibrary/c_utils/base/include/rwlock.h", + "//commonlibrary/c_utils/base/include/safe_block_queue.h", + "//commonlibrary/c_utils/base/include/safe_map.h", + "//commonlibrary/c_utils/base/include/safe_queue.h", + "//commonlibrary/c_utils/base/include/semaphore_ex.h", + "//commonlibrary/c_utils/base/include/singleton.h", + "//commonlibrary/c_utils/base/include/sorted_vector.h", + "//commonlibrary/c_utils/base/include/string_ex.h", + "//commonlibrary/c_utils/base/include/thread_ex.h", + "//commonlibrary/c_utils/base/include/thread_pool.h", + "//commonlibrary/c_utils/base/include/timer.h", + "//commonlibrary/c_utils/base/include/unique_fd.h" + ] + }, + { + "name": "hdf_core:libhdi", + "so_file_name": "libhdi.z.so", + "path": "//drivers/hdf_core/adapter/uhdf2/hdi:libhdi", + "headers": [ + "//drivers/hdf_core/interfaces/inner_api/hdi/hdi_base.h", + "//drivers/hdf_core/interfaces/inner_api/hdi/hdi_support.h", + "//drivers/hdf_core/interfaces/inner_api/hdi/stub_collector.h", + "//drivers/hdf_core/interfaces/inner_api/hdi/object_collector.h", + "//drivers/hdf_core/interfaces/inner_api/hdi/devmgr_hdi.h", + "//drivers/hdf_core/interfaces/inner_api/hdi/idevmgr_hdi.h", + "//drivers/hdf_core/interfaces/inner_api/hdi/servmgr_hdi.h", + "//drivers/hdf_core/interfaces/inner_api/hdi/iservmgr_hdi.h", + "//drivers/hdf_core/interfaces/inner_api/hdi/servstat_listener_hdi.h", + "//drivers/hdf_core/interfaces/inner_api/hdi/iservstat_listener_hdi.h", + "//drivers/hdf_core/interfaces/inner_api/hdi/base/buffer_handle.h", + "//drivers/hdf_core/interfaces/inner_api/hdi/base/buffer_util.h", + "//drivers/hdf_core/interfaces/inner_api/hdi/base/hdi_smq.h", + "//drivers/hdf_core/interfaces/inner_api/hdi/base/hdi_smq_meta.h", + "//drivers/hdf_core/interfaces/inner_api/hdi/base/hdi_smq_syncer.h", + "//drivers/hdf_core/interfaces/inner_api/hdi/base/native_buffer.h", + "//drivers/hdf_core/interfaces/inner_api/core/hdf_device_class.h", + "//drivers/hdf_core/interfaces/inner_api/core/hdf_object.h", + "//drivers/hdf_core/interfaces/inner_api/core/hdf_service_status.h" + ] + }, + { + "name": "ipc:ipc_single", + "so_file_name": "libipc_single.z.so", + "path": "//foundation/communication/ipc/interfaces/innerkits/ipc_single:ipc_single", + "headers": [ + "//foundation/communication/ipc/interfaces/innerkits/ipc_core/include/ipc_types.h", + "//foundation/communication/ipc/interfaces/innerkits/ipc_core/include/ipc_skeleton.h", + "//foundation/communication/ipc/interfaces/innerkits/ipc_core/include/iremote_object.h", + "//foundation/communication/ipc/interfaces/innerkits/ipc_core/include/iremote_proxy.h", + "//foundation/communication/ipc/interfaces/innerkits/ipc_core/include/iremote_stub.h", + "//foundation/communication/ipc/interfaces/innerkits/ipc_core/include/message_parcel.h", + "//foundation/communication/ipc/interfaces/innerkits/ipc_core/include/message_option.h", + "//foundation/communication/ipc/interfaces/innerkits/ipc_core/include/iremote_broker.h", + "//foundation/communication/ipc/interfaces/innerkits/ipc_core/include/ipc_object_proxy.h", + "//foundation/communication/ipc/interfaces/innerkits/ipc_core/include/ipc_object_stub.h", + "//foundation/communication/ipc/interfaces/innerkits/ipc_core/include/peer_holder.h", + "//foundation/communication/ipc/interfaces/innerkits/ipc_core/include/ipc_file_descriptor.h", + "//foundation/communication/ipc/interfaces/innerkits/ipc_core/include/jni_help.h" + ] + }, + { + "name": "common:musl-libcxx.so", + "so_file_name": "libc++.so", + "path": "//build/common/musl:musl-libcxx.so", + "headers": [] + }, + { + "name": "hitrace:hitrace_meter", + "so_file_name": "libhitrace_meter.so", + "path": "//base/hiviewdfx/hitrace/interfaces/native/innerkits:hitrace_meter", + "headers": [ + "//base/hiviewdfx/hitrace/interfaces/native/innerkits/include/hitrace_meter/hitrace_meter.h" + ] + }, + { + "name": "hdf_core:libhdf_ipc_adapter", + "so_file_name": "libhdf_ipc_adapter.z.so", + "path": "//drivers/hdf_core/adapter/uhdf2/ipc:libhdf_ipc_adapter", + "headers": [ + "//drivers/hdf_core/interfaces/inner_api/ipc/hdf_dump_reg.h", + "//drivers/hdf_core/interfaces/inner_api/ipc/hdf_remote_service.h", + "//drivers/hdf_core/interfaces/inner_api/ipc/hdf_sbuf_ipc.h", + "//drivers/hdf_core/interfaces/inner_api/core/hdf_object.h" + ] + }, + { + "name": "drivers_interface_camera:metadata", + "so_file_name": "libmetadata.z.so", + "path": "//drivers/interface/camera/metadata:metadata", + "headers": [ + "//drivers/interface/camera/metadata/include/camera_device_ability_items.h", + "//drivers/interface/camera/metadata/include/camera_metadata_info.h", + "//drivers/interface/camera/metadata/include/camera_metadata_item_info.h", + "//drivers/interface/camera/metadata/include/camera_metadata_operator.h", + "//drivers/interface/camera/metadata/include/metadata_log.h", + "//drivers/interface/camera/metadata/include/metadata_utils.h" + ] + }, + { + "name": "openssl:libcrypto_shared", + "so_file_name": "libcrypto_openssl.z.so", + "path": "//third_party/openssl:libcrypto_shared", + "headers": [] + }, + { + "name": "init:libbegetutil", + "so_file_name": "libbegetutil.z.so", + "path": "//base/startup/init/interfaces/innerkits:libbegetutil", + "headers": [ + "//base/startup/init/interfaces/innerkits/include/init_socket.h", + "//base/startup/init/interfaces/innerkits/include/init_file.h", + "//base/startup/init/interfaces/innerkits/include/init_reboot.h", + "//base/startup/init/interfaces/innerkits/include/service_control.h", + "//base/startup/init/interfaces/innerkits/include/beget_ext.h", + "//base/startup/init/interfaces/innerkits/include/systemcapability.h", + "//base/startup/init/interfaces/innerkits/include/syspara/parameter.h", + "//base/startup/init/interfaces/innerkits/include/syspara/parameters.h", + "//base/startup/init/interfaces/innerkits/include/syspara/param_wrapper.h", + "//base/startup/init/interfaces/innerkits/include/syspara/sysparam_errno.h", + "//base/startup/init/interfaces/innerkits/include/syspara/sysversion.h" + ] + }, + { + "name": "libdrm:libdrm", + "so_file_name": "libdrm.so", + "path": "//third_party/libdrm:libdrm", + "headers": [] + }, + { + "name": "libxml2:xml2", + "so_file_name": "libxml2.z.so", + "path": "//third_party/libxml2:xml2", + "headers": [] + }, + { + "name": "drivers_interface_display:libhdifd_parcelable", + "so_file_name": "libhdifd_parcelable.z.so", + "path": "//drivers/interface/display/composer/hdifd_parcelable:libhdifd_parcelable", + "headers": [] + }, + { + "name": "hdf_core:libpub_utils", + "so_file_name": "libpub_utils.z.so", + "path": "//drivers/hdf_core/adapter/uhdf2/pub_utils:libpub_utils", + "headers": [ + "//drivers/hdf_core/interfaces/inner_api/osal/shared/osal_mem.h", + "//drivers/hdf_core/interfaces/inner_api/osal/shared/osal_time.h", + "//drivers/hdf_core/interfaces/inner_api/osal/uhdf/hdf_log_adapter.h", + "//drivers/hdf_core/interfaces/inner_api/osal/uhdf/hdf_types.h", + "//drivers/hdf_core/interfaces/inner_api/utils/hdf_base.h", + "//drivers/hdf_core/interfaces/inner_api/utils/hdf_log.h", + "//drivers/hdf_core/interfaces/inner_api/utils/hdf_sbuf.h", + "//drivers/hdf_core/interfaces/inner_api/utils/hdf_dlist.h", + "//drivers/hdf_core/interfaces/inner_api/core/hdf_device_class.h", + "//drivers/hdf_core/interfaces/inner_api/core/hdf_object.h", + "//drivers/hdf_core/interfaces/inner_api/core/hdf_service_status.h" + ] + }, + { + "name": "drivers_interface_camera:libbuffer_producer_sequenceable_1.0", + "so_file_name": "libbuffer_producer_sequenceable_1.0.z.so", + "path": "//drivers/interface/camera/sequenceable/buffer_producer:libbuffer_producer_sequenceable_1.0", + "headers": [ + "//drivers/interface/camera/sequenceable/buffer_producer/buffer_producer_sequenceable.h" + ] + }, + { + "name": "hisysevent:libhisysevent", + "so_file_name": "libhisysevent.z.so", + "path": "//base/hiviewdfx/hisysevent/interfaces/native/innerkits/hisysevent:libhisysevent", + "headers": [ + "//base/hiviewdfx/hisysevent/interfaces/native/innerkits/hisysevent/include/hisysevent_c.h", + "//base/hiviewdfx/hisysevent/interfaces/native/innerkits/hisysevent/include/hisysevent.h" + ] + }, + { + "name": "ffmpeg:libohosffmpeg", + "so_file_name": "libohosffmpeg.z.so", + "path": "//third_party/ffmpeg:libohosffmpeg", + "headers": [] + }, + { + "name": "samgr:samgr_proxy", + "so_file_name": "libsamgr_proxy.z.so", + "path": "//foundation/systemabilitymgr/samgr/interfaces/innerkits/samgr_proxy:samgr_proxy", + "headers": [ + "//foundation/systemabilitymgr/samgr/interfaces/innerkits/samgr_proxy/include/if_system_ability_manager.h", + "//foundation/systemabilitymgr/samgr/interfaces/innerkits/samgr_proxy/include/iservice_registry.h", + "//foundation/systemabilitymgr/samgr/interfaces/innerkits/samgr_proxy/include/isystem_ability_load_callback.h", + "//foundation/systemabilitymgr/samgr/interfaces/innerkits/samgr_proxy/include/isystem_ability_status_change.h", + "//foundation/systemabilitymgr/samgr/interfaces/innerkits/samgr_proxy/include/isystem_process_status_change.h", + "//foundation/systemabilitymgr/samgr/interfaces/innerkits/samgr_proxy/include/system_ability_definition.h", + "//foundation/systemabilitymgr/samgr/interfaces/innerkits/samgr_proxy/include/system_ability_manager_proxy.h", + "//foundation/systemabilitymgr/samgr/interfaces/innerkits/samgr_proxy/include/system_ability_load_callback_stub.h", + "//foundation/systemabilitymgr/samgr/interfaces/innerkits/samgr_proxy/include/system_ability_status_change_stub.h", + "//foundation/systemabilitymgr/samgr/interfaces/innerkits/samgr_proxy/include/system_process_status_change_stub.h", + "//foundation/systemabilitymgr/samgr/interfaces/innerkits/samgr_proxy/include/sam_log.h" + ] + }, + { + "name": "bluetooth:btcommon", + "so_file_name": "libbtcommon.z.so", + "path": "//foundation/communication/bluetooth/frameworks/inner:btcommon", + "headers": [] + }, + { + "name": "cJSON:cjson", + "so_file_name": "libcjson.z.so", + "path": "//third_party/cJSON:cjson", + "headers": [] + }, + { + "name": "jsoncpp:jsoncpp", + "so_file_name": "libjsoncpp.z.so", + "path": "//third_party/jsoncpp:jsoncpp", + "headers": [] + }, + { + "name": "graphic_2d:surface", + "so_file_name": "libsurface.z.so", + "path": "//foundation/graphic/graphic_2d/frameworks/surface:surface", + "headers": [ + "//foundation/graphic/graphic_2d/interfaces/inner_api/surface/buffer_extra_data.h", + "//foundation/graphic/graphic_2d/interfaces/inner_api/surface/egl_data.h", + "//foundation/graphic/graphic_2d/interfaces/inner_api/surface/egl_surface.h", + "//foundation/graphic/graphic_2d/interfaces/inner_api/surface/external_window.h", + "//foundation/graphic/graphic_2d/interfaces/inner_api/surface/native_buffer.h", + "//foundation/graphic/graphic_2d/interfaces/inner_api/surface/native_buffer_inner.h", + "//foundation/graphic/graphic_2d/interfaces/inner_api/surface/native_image.h", + "//foundation/graphic/graphic_2d/interfaces/inner_api/surface/ibuffer_consumer_listener.h", + "//foundation/graphic/graphic_2d/interfaces/inner_api/surface/ibuffer_producer.h", + "//foundation/graphic/graphic_2d/interfaces/inner_api/surface/iconsumer_surface.h", + "//foundation/graphic/graphic_2d/interfaces/inner_api/surface/surface.h", + "//foundation/graphic/graphic_2d/interfaces/inner_api/surface/surface_buffer.h", + "//foundation/graphic/graphic_2d/interfaces/inner_api/surface/surface_type.h", + "//foundation/graphic/graphic_2d/interfaces/inner_api/surface/surface_utils.h", + "//foundation/graphic/graphic_2d/interfaces/inner_api/surface/window.h" + ] + }, + { + "name": "graphic_2d:sync_fence", + "so_file_name": "libsync_fence.z.so", + "path": "//foundation/graphic/graphic_2d/utils/sync_fence:sync_fence", + "headers": [ + "//foundation/graphic/graphic_2d/utils/sync_fence/export/sync_fence.h" + ] + }, + { + "name": "eudev:libudev", + "so_file_name": "libudev.z.so", + "path": "//third_party/eudev:libudev", + "headers": [] + }, + { + "name": "config_policy:configpolicy_util", + "so_file_name": "libconfigpolicy_util.z.so", + "path": "//base/customization/config_policy/frameworks/config_policy:configpolicy_util", + "headers": [ + "//base/customization/config_policy/interfaces/inner_api/include/config_policy_utils.h" + ] + }, + { + "name": "init:libbeget_proxy", + "so_file_name": "libbeget_proxy.z.so", + "path": "//base/startup/init/interfaces/innerkits:libbeget_proxy", + "headers": [ + "//base/startup/init/interfaces/innerkits/include/service_watcher.h", + "//base/startup/init/interfaces/innerkits/include/syspara/parameter.h", + "//base/startup/init/interfaces/innerkits/include/syspara/sysparam_errno.h" + ] + }, + { + "name": "libexif:libexif", + "so_file_name": "libexif.z.so", + "path": "//third_party/libexif:libexif", + "headers": [] + }, + { + "name": "selinux_adapter:libservice_checker", + "so_file_name": "libservice_checker.z.so", + "path": "//base/security/selinux_adapter:libservice_checker", + "headers": [ + "//base/security/selinux_adapter/interfaces/policycoreutils/include/service_checker.h", + "//base/security/selinux_adapter/interfaces/policycoreutils/include/hdf_service_checker.h" + ] + } +] \ No newline at end of file diff --git a/tools/deps_guard/rules/ChipsetSDK/images/._chipsetsdk.png b/tools/deps_guard/rules/ChipsetSDK/images/._chipsetsdk.png new file mode 100755 index 0000000000000000000000000000000000000000..158c72aaa784bbd27d9384c44af5a161a6be14bf Binary files /dev/null and b/tools/deps_guard/rules/ChipsetSDK/images/._chipsetsdk.png differ diff --git a/tools/deps_guard/rules/ChipsetSDK/images/chipsetsdk.png b/tools/deps_guard/rules/ChipsetSDK/images/chipsetsdk.png new file mode 100755 index 0000000000000000000000000000000000000000..014059a2a3715e87f9f057b4805e9cdf256187f3 Binary files /dev/null and b/tools/deps_guard/rules/ChipsetSDK/images/chipsetsdk.png differ diff --git a/tools/deps_guard/rules/NO-Depends-On-SA/whitelist.json b/tools/deps_guard/rules/NO-Depends-On-SA/whitelist.json index 7259656a82fbbb1b05f24c9f0ef79b841ee92875..80e52e51c23c968170fb18725fa8fa30e932b9bc 100755 --- a/tools/deps_guard/rules/NO-Depends-On-SA/whitelist.json +++ b/tools/deps_guard/rules/NO-Depends-On-SA/whitelist.json @@ -4,5 +4,7 @@ "libavsession_service.z.so", "libsg_collect_service.z.so", "libabnormal_efficiency_mgr_service.z.so", - "libquickfix_engine_service.z.so" + "libquickfix_engine_service.z.so", + "libscreenlock_server.z.so", + "libdistributedhardwarefwksvr.z.so" ] diff --git a/tools/deps_guard/rules_checker/__init__.py b/tools/deps_guard/rules_checker/__init__.py index 7537a0be8d150023a719403982a0673c68c97772..1819e208d3416b185ae2c78d1470db5e4ffa78d2 100755 --- a/tools/deps_guard/rules_checker/__init__.py +++ b/tools/deps_guard/rules_checker/__init__.py @@ -35,8 +35,6 @@ def check_all_rules(mgr, args): r.log("Do %s rule checking now:" % rule.RULE_NAME) if not r.check(): passed = False - - if not passed: r.log(" Please refer to: \033[91m%s\x1b[0m" % r.get_help_url()) if args and args.no_fail: diff --git a/tools/deps_guard/rules_checker/chipsetsdk.py b/tools/deps_guard/rules_checker/chipsetsdk.py index 1f91a1afa35827978c4df48365bf6d3fd154d82f..3fb8ca6993a01a1a37be6d23933ace568e9d81ac 100755 --- a/tools/deps_guard/rules_checker/chipsetsdk.py +++ b/tools/deps_guard/rules_checker/chipsetsdk.py @@ -27,21 +27,29 @@ class ChipsetSDKRule(BaseRule): def __is_chipsetsdk_tagged(self, mod): if not "innerapi_tags" in mod: return False - if "ndk" in mod["innerapi_tags"]: - return True + #if "ndk" in mod["innerapi_tags"]: + # return True if "chipsetsdk" in mod["innerapi_tags"]: return True return False - def __write_innerkits_header_files(self, chipsetsdks): + def __is_chipsetsdk_indirect(self, mod): + if not "innerapi_tags" in mod: + return False + if "chipsetsdk_indirect" in mod["innerapi_tags"]: + return True + return False + + def __write_innerkits_header_files(self): inner_kits_info = os.path.join(self.get_mgr().get_product_out_path(), "build_configs/parts_info/inner_kits_info.json") with open(inner_kits_info, "r") as f: info = json.load(f) headers = [] - for sdk in chipsetsdks: + for sdk in self.__chipsetsdks: path = sdk["labelPath"][:sdk["labelPath"].find(":")] - item = {"chipsetsdk": sdk["name"], "path": path, "headers": []} + target_name = sdk["labelPath"][sdk["labelPath"].find(":")+1:] + item = {"name": sdk["componentName"] + ":" + target_name, "so_file_name": sdk["name"], "path": sdk["labelPath"], "headers": []} if sdk["componentName"] not in info: headers.append(item) continue @@ -63,18 +71,44 @@ class ChipsetSDKRule(BaseRule): return headers + def __check_chipsetsdk_indirect(self): + passed = True + for mod in self.__chipsetsdks: + for dep in mod["deps"]: + callee = dep["callee"] + + # Chipset SDK is OK + if callee["name"] in self.get_white_lists(): + continue + + # chipsetsdk_indirect module is OK + if self.__is_chipsetsdk_indirect(callee): + continue + + # Not correct + passed = False + self.error('Chipset SDK module %s should not depends on non Chipset SDK module %s in %s with "chipsetsdk_indirect"' % (mod["name"], callee["name"], callee["labelPath"])) + + return passed + def __check_depends_on_chipsetsdk(self): lists = self.get_white_lists() passed = True - chipsetsdks = [] - modules_with_chipsetsdk_tag = [] + self.__chipsetsdks = [] + self.__modules_with_chipsetsdk_tag = [] + self.__modules_with_chipsetsdk_indirect_tag = [] # Check if any napi modules has dependedBy for mod in self.get_mgr().get_all(): + # Collect all modules with chipsetsdk tag if self.__is_chipsetsdk_tagged(mod): - modules_with_chipsetsdk_tag.append(mod) + self.__modules_with_chipsetsdk_tag.append(mod) + + # Collect all modules with chipsetsdk_indirect tag + if self.__is_chipsetsdk_indirect(mod): + self.__modules_with_chipsetsdk_indirect_tag.append(mod) # Check chipset modules only if mod["path"].startswith("system"): @@ -88,9 +122,11 @@ class ChipsetSDKRule(BaseRule): if not callee["path"].startswith("system"): continue - if callee not in chipsetsdks: + # Add to list + if callee not in self.__chipsetsdks: if "hdiType" not in callee or callee["hdiType"] != "hdi_proxy": - chipsetsdks.append(callee) + self.__chipsetsdks.append(callee) + # If callee is in Chipset SDK white list module, it is OK if callee["name"] in lists: continue @@ -107,37 +143,49 @@ class ChipsetSDKRule(BaseRule): passed = False self.error("chipset module %s depends on non Chipset SDK module %s in %s" % (mod["name"], callee["name"], mod["labelPath"])) - # Check chipset modules dependedBy - for dep in mod["dependedBy"]: - caller = dep["caller"] - - # Called by chipset module, it is OK - if not caller["path"].startswith("system"): - continue - - if mod not in chipsetsdks: - chipsetsdks.append(mod) + return passed - # If chipset module is in Chipset SDK white list module, it is OK - if mod["name"] in lists: - continue - # Not allowed - passed = False - self.error("system module %s depends on chipset module %s in %s" % (caller["name"], mod["name"], caller["labelPath"])) - - for mod in chipsetsdks: + def __check_if_tagged_correctly(self): + passed = True + for mod in self.__chipsetsdks: if not self.__is_chipsetsdk_tagged(mod): - self.warn('Chipset SDK module %s has no innerapi_tags with "chipsetsdk" or "csdk", add it in %s' % (mod["name"], mod["labelPath"])) + #passed = False + self.warn('Chipset SDK module %s has no innerapi_tags with "chipsetsdk", add it in %s' % (mod["name"], mod["labelPath"])) - for mod in modules_with_chipsetsdk_tag: - if mod["name"] not in lists: + for mod in self.__modules_with_chipsetsdk_tag: + if mod["name"] not in self.get_white_lists(): passed = False - self.error('non chipsetsdk module %s with innerapi_tags="chipsetsdk" or "csdk", %s' % (mod["name"], mod["labelPath"])) + self.error('non chipsetsdk module %s with innerapi_tags="chipsetsdk", %s' % (mod["name"], mod["labelPath"])) - self.__write_innerkits_header_files(chipsetsdks) + for mod in self.__modules_with_chipsetsdk_indirect_tag: + if mod["name"] not in self.__indirects and mod["name"] not in self.get_white_lists(): + #passed = False + self.warn('non chipsetsdk_indirect module %s with innerapi_tags="chipsetsdk_indirect", %s' % (mod["name"], mod["labelPath"])) return passed + def __load_chipsetsdk_indirects(self): + self.__indirects = self.load_files("chipsetsdk_indirect") + def check(self): - return self.__check_depends_on_chipsetsdk() + self.__load_chipsetsdk_indirects() + + # Check if all chipset modules depends on chipsetsdk modules only + passed = self.__check_depends_on_chipsetsdk() + if not passed: + return passed + + # Check if all chipsetsdk module depends on chipsetsdk or chipsetsdk_indirect modules only + passed = self.__check_chipsetsdk_indirect() + if not passed: + return passed + + # Check if all ChipsetSDK modules are correctly tagged by innerapi_tags + passed = self.__check_if_tagged_correctly() + if not passed: + return passed + + self.__write_innerkits_header_files() + + return True