1# Copyright (c) 2020-2022 Huawei Device Co., Ltd. 2# Licensed under the Apache License, Version 2.0 (the "License"); 3# you may not use this file except in compliance with the License. 4# You may obtain a copy of the License at 5# 6# http://www.apache.org/licenses/LICENSE-2.0 7# 8# Unless required by applicable law or agreed to in writing, software 9# distributed under the License is distributed on an "AS IS" BASIS, 10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11# See the License for the specific language governing permissions and 12# limitations under the License. 13if (defined(ohos_lite)) { 14 import("//base/startup/init/begetd.gni") 15 import("//build/lite/config/component/lite_component.gni") 16 import("//build/lite/config/test.gni") 17 if (ohos_kernel_type == "linux" || ohos_kernel_type == "liteos_a") { 18 init_common_sources = [ 19 "//base/startup/init/services/init/adapter/init_adapter.c", 20 "//base/startup/init/services/init/init_capability.c", 21 "//base/startup/init/services/init/init_common_cmds.c", 22 "//base/startup/init/services/init/init_common_service.c", 23 "//base/startup/init/services/init/init_config.c", 24 "//base/startup/init/services/init/init_group_manager.c", 25 "//base/startup/init/services/init/init_service_file.c", 26 "//base/startup/init/services/init/init_service_manager.c", 27 "//base/startup/init/services/init/init_service_socket.c", 28 "//base/startup/init/services/init/lite/init.c", 29 "//base/startup/init/services/init/lite/init_cmds.c", 30 "//base/startup/init/services/init/lite/init_jobs.c", 31 "//base/startup/init/services/init/lite/init_reboot.c", 32 "//base/startup/init/services/init/lite/init_service.c", 33 "//base/startup/init/services/init/lite/init_signal_handler.c", 34 "//base/startup/init/services/log/init_log.c", 35 "//base/startup/init/services/utils/init_utils.c", 36 ] 37 } 38 param_common_sources = [ 39 "//base/startup/init/services/modules/init_hook/param_hook.c", 40 "//base/startup/init/services/modules/udid/udid_adp.c", 41 "//base/startup/init/services/modules/udid/udid_comm.c", 42 "//base/startup/init/services/param/manager/param_manager.c", 43 "//base/startup/init/services/param/manager/param_persist.c", 44 "//base/startup/init/services/param/manager/param_server.c", 45 ] 46 47 base_sources = [ 48 "//base/startup/init/services/log/init_commlog.c", 49 "//base/startup/init/services/param/base/param_base.c", 50 "//base/startup/init/services/param/base/param_comm.c", 51 "//base/startup/init/services/param/base/param_trie.c", 52 "//base/startup/init/services/utils/init_hashmap.c", 53 "//base/startup/init/services/utils/list.c", 54 ] 55 56 sysparam_source = [ 57 "//base/startup/init/interfaces/innerkits/syspara/param_comm.c", 58 "//base/startup/init/interfaces/innerkits/syspara/parameter.c", 59 "//base/startup/init/interfaces/innerkits/syspara/sysversion.c", 60 ] 61 62 unittest("init_test") { 63 output_extension = "bin" 64 output_dir = "$root_out_dir/test/unittest/startup" 65 ldflags = [ 66 "-lstdc++", 67 "-lpthread", 68 "-lm", 69 ] 70 defines = [ 71 "OHOS_LITE", 72 "__MUSL__", 73 "_GNU_SOURCE", 74 "READ_CHECK", 75 "STARTUP_INIT_TEST", 76 "PARAM_SUPPORT_DAC", 77 "USE_MBEDTLS", 78 ] 79 if (storage_type == "emmc") { 80 defines += [ "USE_EMMC_STORAGE" ] 81 } 82 83 include_dirs = [ 84 "//base/startup/init/services/begetctl", 85 "//base/startup/init/services/begetctl/shell", 86 "//base/startup/init/services/include", 87 "//base/startup/init/services/include/param", 88 "//base/startup/init/services/init/include", 89 "//base/startup/init/services/log", 90 "//base/startup/init/services/loopevent/include", 91 "//base/startup/init/services/loopevent/timer", 92 "//base/startup/init/services/loopevent/task", 93 "//base/startup/init/services/loopevent/utils", 94 "//base/startup/init/services/param/adapter", 95 "//base/startup/init/services/param/base", 96 "//base/startup/init/services/param/linux", 97 "//base/startup/init/services/param/include", 98 "//base/startup/init/services/param/watcher/agent", 99 "//base/startup/init/services/param/watcher/include", 100 "//base/startup/init/services/param/watcher/proxy", 101 "//base/startup/init/services/modules", 102 "//base/startup/init/services/modules/init_hook", 103 "//base/startup/init/services/modules/selinux", 104 "//base/startup/init/test/unittest", 105 "//base/startup/init/test/unittest/param", 106 "//base/startup/init/interfaces/innerkits/include", 107 "//base/startup/init/interfaces/innerkits/include/syspara", 108 "//base/startup/init/interfaces/innerkits/init_module_engine/include", 109 "//base/startup/init/interfaces/innerkits/syspara", 110 "//base/startup/init/ueventd", 111 "//base/startup/init/ueventd/include", 112 "//third_party/cJSON", 113 "//third_party/bounds_checking_function/include", 114 "//base/hiviewdfx/hilog_lite/interfaces/native/kits", 115 "//base/startup/init/interfaces/innerkits/fd_holder", 116 "//base/startup/init/interfaces/hals", 117 "//base/startup/init/services/modules/udid", 118 ] 119 120 sources = sysparam_source 121 sources += param_common_sources 122 sources += base_sources 123 deps = [ "//third_party/bounds_checking_function:libsec_static" ] 124 if (enable_ohos_startup_init_feature_begetctl_liteos) { 125 defines += [ "LITEOS_SUPPORT" ] 126 } 127 128 if (ohos_kernel_type == "liteos_a") { 129 defines += [ 130 "__LITEOS_A__", 131 "STARTUP_INIT_UT_PATH =\"/userdata/init_ut\"", 132 ] 133 include_dirs += [ 134 "//kernel/liteos_a/syscall", 135 "//base/startup/init/interfaces/kits/syscap", 136 "//base/startup/init/initsync/include", 137 ] 138 sources += init_common_sources 139 sources += [ 140 "//base/startup/init/services/param/adapter/param_persistadp.c", 141 "//base/startup/init/services/param/liteos/param_client.c", 142 "//base/startup/init/services/param/liteos/param_litedac.c", 143 "//base/startup/init/services/param/liteos/param_osadp.c", 144 "//base/startup/init/services/param/liteos/param_service.c", 145 ] 146 147 sources += [ 148 "../param/client_unittest.cpp", 149 "../param/param_stub.cpp", 150 "../param/param_unittest.cpp", 151 "../syspara/syspara_unittest.cpp", 152 "cmd_func_test.cpp", 153 ] 154 155 # add cfg.h 156 if (enable_ohos_startup_init_feature_begetctl_liteos) { 157 PRODUCT_HAL_SYSPARAM_PATH = 158 rebase_path("${ohos_product_adapter_dir}/utils/sys_param") 159 cmd = "if [ -f ${PRODUCT_HAL_SYSPARAM_PATH}/BUILD.gn ]; then echo true; else echo false; fi" 160 PRODUCT_HAL_SYSPARAM_EXISTS = 161 exec_script("//build/lite/run_shell_cmd.py", [ cmd ], "value") 162 if (PRODUCT_HAL_SYSPARAM_EXISTS) { 163 deps += [ "$ohos_product_adapter_dir/utils/sys_param:hal_sysparam" ] 164 } 165 deps += [ 166 "//base/startup/init/interfaces/hals/utils/sys_param:hal_sys_param", 167 ] 168 deps += 169 [ "//base/startup/init/services/param/liteos:lite_ohos_param_to" ] 170 include_dirs += [ "$root_out_dir/gen/init" ] 171 defines += [ "PARAM_LOAD_CFG_FROM_CODE" ] 172 } 173 deps += [ 174 "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared", 175 "//base/startup/init/initsync:initsync", 176 "//base/startup/init/services/loopevent:loopevent", 177 "//build/lite/config/component/cJSON:cjson_static", 178 "//third_party/mbedtls:mbedtls", 179 ] 180 } 181 182 if (ohos_kernel_type == "liteos_m") { 183 defines += [ 184 "__LITEOS_M__", 185 "STARTUP_INIT_UT_PATH =\"/\"", 186 ] 187 sources += [ 188 "//base/startup/init/services/param/liteos/param_client.c", 189 "//base/startup/init/services/param/liteos/param_hal.c", 190 "//base/startup/init/services/param/liteos/param_litedac.c", 191 "//base/startup/init/services/param/liteos/param_osadp.c", 192 "//base/startup/init/services/param/liteos/param_service.c", 193 ] 194 if (enable_ohos_startup_init_lite_use_posix_file_api) { 195 defines += [ "PARAM_SUPPORT_POSIX" ] 196 } 197 sources += [ 198 "../param/dac_unittest.cpp", 199 "../param/param_stub.cpp", 200 "../param/param_unittest.cpp", 201 "../syspara/syspara_unittest.cpp", 202 ] 203 204 # add cfg.h 205 if (enable_ohos_startup_init_feature_begetctl_liteos) { 206 deps += 207 [ "//base/startup/init/services/param/liteos:lite_ohos_param_to" ] 208 include_dirs += [ "$root_out_dir/gen/init" ] 209 defines += [ "PARAM_LOAD_CFG_FROM_CODE" ] 210 } 211 deps += [ 212 "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_static", 213 "//third_party/mbedtls:mbedtls", 214 ] 215 } 216 if (ohos_kernel_type == "linux") { 217 defines += [ 218 "__LINUX__", 219 "STARTUP_INIT_UT_PATH =\"/data/init_ut\"", 220 ] 221 222 sources += init_common_sources 223 sources += [ 224 "//base/startup/init/services/param/adapter/param_dac.c", 225 "//base/startup/init/services/param/adapter/param_persistadp.c", 226 "//base/startup/init/services/param/linux/param_message.c", 227 "//base/startup/init/services/param/linux/param_msgadp.c", 228 "//base/startup/init/services/param/linux/param_osadp.c", 229 "//base/startup/init/services/param/linux/param_request.c", 230 "//base/startup/init/services/param/linux/param_service.c", 231 "//base/startup/init/services/param/trigger/trigger_checker.c", 232 "//base/startup/init/services/param/trigger/trigger_manager.c", 233 "//base/startup/init/services/param/trigger/trigger_processor.c", 234 ] 235 sources += [ 236 "../param/client_unittest.cpp", 237 "../param/dac_unittest.cpp", 238 "../param/param_stub.cpp", 239 "../param/param_unittest.cpp", 240 "../param/paramservice_unittest.cpp", 241 "cmd_func_test.cpp", 242 ] 243 if (enable_ohos_startup_init_feature_begetctl_liteos) { 244 sources += [ "../syspara/syspara_unittest.cpp" ] 245 } 246 deps += [ 247 "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared", 248 "//base/startup/init/services/loopevent:loopevent", 249 "//build/lite/config/component/cJSON:cjson_static", 250 "//third_party/mbedtls:mbedtls", 251 ] 252 } 253 } 254} 255