# Copyright (c) 2020-2022 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. if (defined(ohos_lite)) { import("//base/startup/init/begetd.gni") import("//build/lite/config/component/lite_component.gni") import("//build/lite/config/test.gni") if (ohos_kernel_type == "linux" || ohos_kernel_type == "liteos_a") { init_common_sources = [ "//base/startup/init/services/init/adapter/init_adapter.c", "//base/startup/init/services/init/init_capability.c", "//base/startup/init/services/init/init_common_cmds.c", "//base/startup/init/services/init/init_common_service.c", "//base/startup/init/services/init/init_config.c", "//base/startup/init/services/init/init_group_manager.c", "//base/startup/init/services/init/init_service_file.c", "//base/startup/init/services/init/init_service_manager.c", "//base/startup/init/services/init/init_service_socket.c", "//base/startup/init/services/init/lite/init.c", "//base/startup/init/services/init/lite/init_cmds.c", "//base/startup/init/services/init/lite/init_jobs.c", "//base/startup/init/services/init/lite/init_reboot.c", "//base/startup/init/services/init/lite/init_service.c", "//base/startup/init/services/init/lite/init_signal_handler.c", "//base/startup/init/services/log/init_log.c", "//base/startup/init/services/utils/init_utils.c", ] } param_common_sources = [ "//base/startup/init/services/modules/init_hook/param_hook.c", "//base/startup/init/services/param/manager/param_manager.c", "//base/startup/init/services/param/manager/param_persist.c", "//base/startup/init/services/param/manager/param_server.c", ] base_sources = [ "//base/startup/init/services/log/init_commlog.c", "//base/startup/init/services/param/base/param_base.c", "//base/startup/init/services/param/base/param_comm.c", "//base/startup/init/services/param/base/param_trie.c", "//base/startup/init/services/utils/init_hashmap.c", "//base/startup/init/services/utils/list.c", ] sysparam_source = [ "//base/startup/init/interfaces/innerkits/syspara/param_comm.c", "//base/startup/init/interfaces/innerkits/syspara/parameter.c", "//base/startup/init/interfaces/innerkits/syspara/sysversion.c", ] unittest("init_test") { output_extension = "bin" output_dir = "$root_out_dir/test/unittest/startup" ldflags = [ "-lstdc++", "-lpthread", "-lm", ] defines = [ "OHOS_LITE", "__MUSL__", "_GNU_SOURCE", "READ_CHECK", "STARTUP_INIT_TEST", "PARAM_SUPPORT_DAC", "USE_MBEDTLS", "STARTUP_INIT_UT_PATH =\"/userdata/init_ut\"", ] if (storage_type == "emmc") { defines += [ "USE_EMMC_STORAGE" ] } include_dirs = [ "//base/startup/init/services/include", "//base/startup/init/services/include/param", "//base/startup/init/services/init/include", "//base/startup/init/services/log", "//base/startup/init/services/loopevent/include", "//base/startup/init/services/loopevent/timer", "//base/startup/init/services/loopevent/task", "//base/startup/init/services/loopevent/utils", "//base/startup/init/services/param/adapter", "//base/startup/init/services/param/base", "//base/startup/init/services/param/linux", "//base/startup/init/services/param/include", "//base/startup/init/services/param/watcher/agent", "//base/startup/init/services/param/watcher/include", "//base/startup/init/services/param/watcher/proxy", "//base/startup/init/services/modules", "//base/startup/init/services/modules/init_hook", "//base/startup/init/services/modules/selinux", "//base/startup/init/test/unittest", "//base/startup/init/test/unittest/param", "//base/startup/init/interfaces/innerkits/include", "//base/startup/init/interfaces/innerkits/include/syspara", "//base/startup/init/interfaces/innerkits/init_module_engine/include", "//base/startup/init/interfaces/innerkits/syspara", "//third_party/cJSON", "//third_party/bounds_checking_function/include", "//base/hiviewdfx/hilog_lite/interfaces/native/kits", "//base/startup/init/interfaces/innerkits/fd_holder", "//base/startup/init/interfaces/hals", ] sources = sysparam_source sources += param_common_sources sources += base_sources deps = [ "//third_party/bounds_checking_function:libsec_static" ] if (ohos_kernel_type == "liteos_a") { defines += [ "__LITEOS_A__" ] include_dirs += [ "//kernel/liteos_a/syscall", "//base/startup/init/interfaces/kits/syscap", "//base/startup/init/initsync/include", ] sources += init_common_sources sources += [ "//base/startup/init/services/param/adapter/param_persistadp.c", "//base/startup/init/services/param/liteos/param_client.c", "//base/startup/init/services/param/liteos/param_litedac.c", "//base/startup/init/services/param/liteos/param_osadp.c", "//base/startup/init/services/param/liteos/param_service.c", ] sources += [ "../param/client_unittest.cpp", "../param/param_stub.cpp", "../param/param_unittest.cpp", "../syspara/syspara_unittest.cpp", "cmd_func_test.cpp", ] # add cfg.h if (enable_ohos_startup_init_feature_begetctl_liteos) { PRODUCT_HAL_SYSPARAM_PATH = rebase_path("//${ohos_product_adapter_dir}/utils/sys_param") cmd = "if [ -f ${PRODUCT_HAL_SYSPARAM_PATH}/BUILD.gn ]; then echo true; else echo false; fi" PRODUCT_HAL_SYSPARAM_EXISTS = exec_script("//build/lite/run_shell_cmd.py", [ cmd ], "value") if (PRODUCT_HAL_SYSPARAM_EXISTS) { deps += [ "$ohos_product_adapter_dir/utils/sys_param:hal_sysparam" ] } deps += [ "//base/startup/init/interfaces/hals/utils/sys_param:hal_sys_param", ] deps += [ "//base/startup/init/services/param/liteos:lite_ohos_param_to" ] include_dirs += [ "$root_out_dir/gen/init" ] defines += [ "PARAM_LOAD_CFG_FROM_CODE" ] } deps += [ "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared", "//base/startup/init/initsync:initsync", "//base/startup/init/services/loopevent:loopevent", "//build/lite/config/component/cJSON:cjson_static", "//third_party/mbedtls:mbedtls", ] } if (ohos_kernel_type == "liteos_m") { defines += [ "__LITEOS_M__" ] sources += [ "//base/startup/init/services/param/liteos/param_client.c", "//base/startup/init/services/param/liteos/param_hal.c", "//base/startup/init/services/param/liteos/param_litedac.c", "//base/startup/init/services/param/liteos/param_osadp.c", "//base/startup/init/services/param/liteos/param_service.c", ] if (enable_ohos_startup_init_lite_use_posix_file_api) { defines += [ "PARAM_SUPPORT_POSIX" ] } sources += [ "../param/dac_unittest.cpp", "../param/param_stub.cpp", "../param/param_unittest.cpp", "../syspara/syspara_unittest.cpp", ] # add cfg.h if (enable_ohos_startup_init_feature_begetctl_liteos) { deps += [ "//base/startup/init/services/param/liteos:lite_ohos_param_to" ] include_dirs += [ "$root_out_dir/gen/init" ] defines += [ "PARAM_LOAD_CFG_FROM_CODE" ] } deps += [ "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_static", "//third_party/mbedtls:mbedtls", ] } if (ohos_kernel_type == "linux") { defines += [ "__LINUX__" ] sources += init_common_sources sources += [ "//base/startup/init/services/param/adapter/param_dac.c", "//base/startup/init/services/param/adapter/param_persistadp.c", "//base/startup/init/services/param/linux/param_message.c", "//base/startup/init/services/param/linux/param_msgadp.c", "//base/startup/init/services/param/linux/param_osadp.c", "//base/startup/init/services/param/linux/param_request.c", "//base/startup/init/services/param/linux/param_service.c", "//base/startup/init/services/param/trigger/trigger_checker.c", "//base/startup/init/services/param/trigger/trigger_manager.c", "//base/startup/init/services/param/trigger/trigger_processor.c", ] sources += [ "../param/client_unittest.cpp", "../param/dac_unittest.cpp", "../param/param_stub.cpp", "../param/param_unittest.cpp", "../param/paramservice_unittest.cpp", "cmd_func_test.cpp", ] if (enable_ohos_startup_init_feature_begetctl_liteos) { sources += [ "../syspara/syspara_unittest.cpp" ] } deps += [ "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared", "//base/startup/init/services/loopevent:loopevent", "//build/lite/config/component/cJSON:cjson_static", "//third_party/mbedtls:mbedtls", ] } } }