BUILD.gn 15.4 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
# Copyright (c) 2021 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.
M
init  
Mupceet 已提交
13
import("//base/startup/init/begetd.gni")
14 15 16 17 18 19 20 21
import("//build/test.gni")

config("utest_config") {
  visibility = [ ":*" ]

  cflags = [
    "-Wno-implicit-fallthrough",
    "-Wno-unused-function",
C
cheng_jinsong 已提交
22 23
    "-Dprivate=public",
    "-Dprotected=public",
C
cheng_jinsong 已提交
24 25 26 27 28 29 30 31 32 33
    "-Dsprintf_s=SprintfStub",
    "-Dmount=MountStub",
    "-Dumount=UmountStub",
    "-Dumount2=Umount2Stub",
    "-Dsymlink=SymlinkStub",
    "-Dprctl=PrctlStub",
    "-Dexecv=ExecvStub",
    "-Dlchown=LchownStub",
    "-Dkill=KillStub",
    "-Dexecve=ExecveStub",
34 35 36 37 38 39 40
  ]
  cflags_cc = [
    "-Wno-implicit-fallthrough",
    "-fexceptions",
  ]
}

41 42 43
FSCRYPT_PATH =
    "//foundation/filemanagement/storage_service/services/storage_daemon"

L
laiguizhong 已提交
44
ohos_unittest("init_unittest") {
45 46
  module_out_path = "startup/init"
  sources = [
M
init  
Mupceet 已提交
47 48
    "//base/startup/init/device_info/device_info.cpp",
    "//base/startup/init/device_info/device_info_stub.cpp",
C
cheng_jinsong 已提交
49 50 51 52
    "//base/startup/init/interfaces/innerkits/control_fd/control_fd_client.c",
    "//base/startup/init/interfaces/innerkits/control_fd/control_fd_service.c",
    "//base/startup/init/interfaces/innerkits/fd_holder/fd_holder.c",
    "//base/startup/init/interfaces/innerkits/fd_holder/fd_holder_internal.c",
M
init  
Mupceet 已提交
53 54 55 56 57 58 59 60
    "//base/startup/init/interfaces/innerkits/file/init_file.c",
    "//base/startup/init/interfaces/innerkits/fs_manager/fstab.c",
    "//base/startup/init/interfaces/innerkits/fs_manager/fstab_mount.c",
    "//base/startup/init/interfaces/innerkits/reboot/init_reboot_innerkits.c",
    "//base/startup/init/interfaces/innerkits/socket/init_socket.c",
    "//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",
C
cheng_jinsong 已提交
61 62 63 64 65 66
    "//base/startup/init/services/begetctl/begetctl_cmd.c",
    "//base/startup/init/services/begetctl/bootchart_cmd.c",
    "//base/startup/init/services/begetctl/dump_service.c",
    "//base/startup/init/services/begetctl/init_cmd_reboot.c",
    "//base/startup/init/services/begetctl/misc_daemon.cpp",
    "//base/startup/init/services/begetctl/modulectl.c",
M
init  
Mupceet 已提交
67
    "//base/startup/init/services/begetctl/param_cmd.c",
C
cheng_jinsong 已提交
68 69 70
    "//base/startup/init/services/begetctl/sandbox.cpp",
    "//base/startup/init/services/begetctl/service_control.c",
    "//base/startup/init/services/begetctl/setloglevel.c",
M
init  
Mupceet 已提交
71 72 73 74 75 76 77 78 79 80 81 82
    "//base/startup/init/services/begetctl/shell/shell_bas.c",
    "//base/startup/init/services/begetctl/shell/shell_main.c",
    "//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/standard/device.c",
C
cheng_jinsong 已提交
83
    "//base/startup/init/services/init/standard/fd_holder_service.c",
M
init  
Mupceet 已提交
84 85 86
    "//base/startup/init/services/init/standard/init.c",
    "//base/startup/init/services/init/standard/init_cmdexecutor.c",
    "//base/startup/init/services/init/standard/init_cmds.c",
M
Mupceet 已提交
87
    "//base/startup/init/services/init/standard/init_control_fd_service.c",
M
init  
Mupceet 已提交
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
    "//base/startup/init/services/init/standard/init_jobs.c",
    "//base/startup/init/services/init/standard/init_mount.c",
    "//base/startup/init/services/init/standard/init_reboot.c",
    "//base/startup/init/services/init/standard/init_service.c",
    "//base/startup/init/services/init/standard/init_signal_handler.c",
    "//base/startup/init/services/log/init_commlog.c",
    "//base/startup/init/services/log/init_log.c",
    "//base/startup/init/services/loopevent/loop/le_epoll.c",
    "//base/startup/init/services/loopevent/loop/le_loop.c",
    "//base/startup/init/services/loopevent/signal/le_signal.c",
    "//base/startup/init/services/loopevent/socket/le_socket.c",
    "//base/startup/init/services/loopevent/task/le_asynctask.c",
    "//base/startup/init/services/loopevent/task/le_streamtask.c",
    "//base/startup/init/services/loopevent/task/le_task.c",
    "//base/startup/init/services/loopevent/task/le_watchtask.c",
    "//base/startup/init/services/loopevent/timer/le_timer.c",
    "//base/startup/init/services/loopevent/utils/le_utils.c",
C
cheng_jinsong 已提交
105 106
    "//base/startup/init/services/modules/bootchart/bootchart.c",
    "//base/startup/init/services/modules/bootchart/bootchart_static.c",
M
Mupceet 已提交
107
    "//base/startup/init/services/modules/bootevent/bootevent.c",
M
Mupceet 已提交
108 109
    "//base/startup/init/services/modules/init_hook/init_hook.c",
    "//base/startup/init/services/modules/init_hook/param_hook.c",
C
cheng_jinsong 已提交
110
    "//base/startup/init/services/modules/reboot/reboot.c",
C
cheng_jinsong 已提交
111
    "//base/startup/init/services/modules/reboot/reboot_misc.c",
C
cheng_jinsong 已提交
112
    "//base/startup/init/services/modules/reboot/reboot_static.c",
M
init  
Mupceet 已提交
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
    "//base/startup/init/services/param/adapter/param_dac.c",
    "//base/startup/init/services/param/adapter/param_persistadp.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/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/manager/param_manager.c",
    "//base/startup/init/services/param/manager/param_persist.c",
    "//base/startup/init/services/param/manager/param_server.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",
129 130
    "//base/startup/init/services/sandbox/sandbox.c",
    "//base/startup/init/services/sandbox/sandbox_namespace.c",
M
init  
Mupceet 已提交
131 132 133 134 135 136 137 138 139
    "//base/startup/init/services/utils/init_hashmap.c",
    "//base/startup/init/services/utils/init_utils.c",
    "//base/startup/init/services/utils/list.c",
    "//base/startup/init/ueventd/standard/ueventd_parameter.c",
    "//base/startup/init/ueventd/ueventd.c",
    "//base/startup/init/ueventd/ueventd_device_handler.c",
    "//base/startup/init/ueventd/ueventd_firmware_handler.c",
    "//base/startup/init/ueventd/ueventd_read_cfg.c",
    "//base/startup/init/ueventd/ueventd_socket.c",
140 141
  ]

142 143 144 145 146 147 148
  sources += [
    "${FSCRYPT_PATH}/libfscrypt/src/fscrypt_control.c",
    "${FSCRYPT_PATH}/libfscrypt/src/fscrypt_utils.c",
    "${FSCRYPT_PATH}/libfscrypt/src/key_control.c",
    "${FSCRYPT_PATH}/libfscrypt/src/sysparam_static.c",
  ]

M
Mupceet 已提交
149
  if (defined(build_selinux) && build_selinux) {
M
init  
Mupceet 已提交
150
    sources += [ "//base/startup/init/services/param/adapter/param_selinux.c" ]
M
Mupceet 已提交
151 152
  }

M
Mupceet 已提交
153
  if (enable_ohos_startup_init_feature_watcher) {
H
handyohos 已提交
154
    sources += [
M
init  
Mupceet 已提交
155 156 157 158 159 160 161
      "//base/startup/init/services/param/watcher/agent/watcher.cpp",
      "//base/startup/init/services/param/watcher/agent/watcher_manager_kits.cpp",
      "//base/startup/init/services/param/watcher/agent/watcher_manager_proxy.cpp",
      "//base/startup/init/services/param/watcher/agent/watcher_stub.cpp",
      "//base/startup/init/services/param/watcher/proxy/watcher_manager.cpp",
      "//base/startup/init/services/param/watcher/proxy/watcher_manager_stub.cpp",
      "//base/startup/init/services/param/watcher/proxy/watcher_proxy.cpp",
H
handyohos 已提交
162 163 164
    ]
  }

165
  sources += [
X
xionglei6 已提交
166
    "begetctl/begetctl_unittest.cpp",
M
Mupceet 已提交
167
    "deviceinfo/DeviceInfoUnittest.cpp",
168
    "init/cmds_unittest.cpp",
X
xionglei6 已提交
169
    "init/group_unittest.cpp",
X
add ut  
xionglei6 已提交
170
    "init/init_reboot_unittest.cpp",
C
cheng_jinsong 已提交
171
    "init/init_unittest.cpp",
X
add ut  
xionglei6 已提交
172
    "init/mount_unittest.cpp",
M
Mupceet 已提交
173
    "init/sandbox_unittest.cpp",
X
add ut  
xionglei6 已提交
174 175
    "init/service_file_unittest.cpp",
    "init/service_socket_unittest.cpp",
C
cheng_jinsong 已提交
176
    "init/service_unittest.cpp",
X
add ut  
xionglei6 已提交
177
    "init/utils_unittest.cpp",
L
laiguizhong 已提交
178
    "innerkits/innerkits_unittest.cpp",
C
cheng_jinsong 已提交
179 180 181
    "loopevent/loopevent_unittest.cpp",
    "loopevent/loopsignal_unittest.cpp",
    "modules/modules_unittest.cpp",
182 183
    "param/client_unittest.cpp",
    "param/dac_unittest.cpp",
X
xlei1030 已提交
184
    "param/param_shell_unittest.cpp",
M
Mupceet 已提交
185
    "param/param_stub.cpp",
186
    "param/param_unittest.cpp",
M
Mupceet 已提交
187
    "param/paramservice_unittest.cpp",
188
    "param/trigger_unittest.cpp",
M
Mupceet 已提交
189
    "syspara/syspara_unittest.cpp",
X
add ut  
xionglei6 已提交
190
    "ueventd/ueventd_config_unittest.cpp",
C
cheng_jinsong 已提交
191
    "ueventd/ueventd_event_unittest.cpp",
192 193
  ]

194
  sources += [
M
init  
Mupceet 已提交
195
    "//base/startup/init/interfaces/innerkits/hookmgr/hookmgr.c",
M
Mupceet 已提交
196
    "//base/startup/init/interfaces/innerkits/init_module_engine/init_modulemgr.c",
M
init  
Mupceet 已提交
197
    "//base/startup/init/interfaces/innerkits/modulemgr/modulemgr.c",
C
cheng_jinsong 已提交
198 199 200 201
    "//base/startup/init/interfaces/innerkits/service_control/service_control.c",
    "//base/startup/init/interfaces/innerkits/service_watcher/service_watcher.c",
    "//base/startup/init/interfaces/innerkits/syscap/init_syscap.c",
    "//base/startup/init/interfaces/innerkits/syspara/param_wrapper.cpp",
202 203 204 205
    "innerkits/hookmgr_unittest.cpp",
    "innerkits/modulemgr_unittest.cpp",
  ]

M
init  
Mupceet 已提交
206
  configs = [ "//base/startup/init/test/unittest:utest_config" ]
207 208

  include_dirs = [
Z
zhr758 已提交
209
    "//base/customization/config_policy/interfaces/innerkits/include",
M
init  
Mupceet 已提交
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229
    "//base/startup/init/device_info",
    "//base/startup/init/services/init/standard",
    "//base/startup/init/interfaces/innerkits/include",
    "//base/startup/init/interfaces/innerkits/include/syspara",
    "//base/startup/init/interfaces/innerkits/fd_holder",
    "//base/startup/init/interfaces/innerkits/syspara",
    "//base/startup/init/interfaces/innerkits/control_fd",
    "//base/startup/init/services/begetctl",
    "//base/startup/init/services/begetctl/shell",
    "//base/startup/init/services/include",
    "//base/startup/init/services/init/include",
    "//base/startup/init/services/include/param",
    "//base/startup/init/services/log",
    "//base/startup/init/services/loopevent/include",
    "//base/startup/init/services/loopevent/loop",
    "//base/startup/init/services/loopevent/socket",
    "//base/startup/init/services/loopevent/signal",
    "//base/startup/init/services/loopevent/task",
    "//base/startup/init/services/loopevent/timer",
    "//base/startup/init/services/loopevent/utils",
M
Mupceet 已提交
230
    "//base/startup/init/services/modules",
C
cheng_jinsong 已提交
231
    "//base/startup/init/services/modules/bootchart",
M
Mupceet 已提交
232 233
    "//base/startup/init/services/modules/init_hook",
    "//base/startup/init/services/modules/selinux",
C
cheng_jinsong 已提交
234
    "//base/startup/init/services/modules/reboot",
M
Mupceet 已提交
235
    "//base/startup/init/services/loopevent/utils",
M
init  
Mupceet 已提交
236 237 238 239 240 241 242 243 244
    "//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/test/unittest",
    "//base/startup/init/test/unittest/param",
H
huangxiaolinabc123 已提交
245 246 247 248 249
    "//foundation/systemabilitymgr/samgr/interfaces/innerkits/samgr_proxy/include",
    "//foundation/systemabilitymgr/safwk/services/safwk/include",
    "//foundation/systemabilitymgr/safwk/interfaces/innerkits/safwk",
    "//foundation/systemabilitymgr/samgr/adapter/interfaces/innerkits/include",
    "//foundation/systemabilitymgr/samgr/interfaces/innerkits/samgr_proxy/include",
M
init  
Mupceet 已提交
250
    "//base/startup/init/ueventd/include",
251 252 253
    "//utils/system/safwk/native/include",
    "//third_party/bounds_checking_function/include",
    "//third_party/cJSON",
254 255
    "//base/security/access_token/interfaces/innerkits/token_setproc/include",
    "//base/security/access_token/interfaces/innerkits/nativetoken/include",
256
    "//base/startup/init/services/sandbox/include",
M
init  
Mupceet 已提交
257
    "//base/startup/init/interfaces/innerkits/hals",
258
    "${FSCRYPT_PATH}/include/libfscrypt",
259 260 261
  ]

  deps = [
Z
zhr758 已提交
262
    "//base/customization/config_policy/frameworks/config_policy:configpolicy_util_for_init_static",
263 264
    "//base/security/access_token/interfaces/innerkits/nativetoken:libnativetoken",
    "//base/security/access_token/interfaces/innerkits/token_setproc:libtoken_setproc",
265
    "//third_party/bounds_checking_function:libsec_static",
L
laiguizhong 已提交
266
    "//third_party/cJSON:cjson",
267 268
    "//third_party/googletest:gmock",
    "//third_party/googletest:gtest",
M
Mupceet 已提交
269
    "//third_party/mbedtls:mbedtls_shared",
270 271 272
  ]

  defines = [
X
xionglei6 已提交
273
    "READ_CHECK",
274
    "INIT_AGENT",
C
cheng_jinsong 已提交
275 276
    "INIT_DMESG",
    "INIT_FILE",
277 278
    "STARTUP_INIT_TEST",
    "PARAM_SUPPORT_DAC",
279
    "_GNU_SOURCE",
M
Mupceet 已提交
280
    "PARAM_SUPPORT_TRIGGER",
M
Mupceet 已提交
281
    "USE_MBEDTLS",
C
cheng_jinsong 已提交
282
    "PARAM_DECODE_GROUPID_FROM_FILE",
C
cheng_jinsong 已提交
283
    "WORKSPACE_AREA_NEED_MUTEX",
C
cheng_jinsong 已提交
284
    "PARAMWORKSPACE_NEED_MUTEX",
C
cheng_jinsong 已提交
285 286
    "PARAM_SUPPORT_REAL_CHECK",
    "DISABLE_INIT_TWO_STAGES",
287
  ]
X
xionglei6 已提交
288
  defines += [ "_GNU_SOURCE" ]
289

290 291 292
  if (target_cpu == "arm64") {
    defines += [ "SUPPORT_64BIT" ]
  }
C
cheng_jinsong 已提交
293 294 295
  if (use_musl) {
    defines += [ "__MUSL__" ]
  }
296

H
handyohos 已提交
297
  external_deps = [
H
hongtao 已提交
298
    "c_utils:utils",
H
handyohos 已提交
299
    "hiviewdfx_hilog_native:libhilog",
300
    "init:libinit_module_engine",
H
handyohos 已提交
301
  ]
H
handyohos 已提交
302

C
cheng_jinsong 已提交
303 304 305 306 307 308 309 310 311
  if (enable_ohos_startup_init_feature_ab_partition) {
    include_dirs += [ "//drivers/hdf_core/adapter/uhdf2/include" ]
    sources += [ "//base/startup/init/services/begetctl/partitionslot.cpp" ]
    external_deps += [
      "drivers_interface_partitionslot:libpartitionslot_proxy_1.0",
      "hdf_core:libhdi",
    ]
  }

M
Mupceet 已提交
312
  if (!defined(ohos_lite) && enable_ohos_startup_init_feature_watcher) {
M
Mupceet 已提交
313 314 315 316
    sources += [
      "param/watcher_agent_unittest.cpp",
      "param/watcher_proxy_unittest.cpp",
    ]
H
handyohos 已提交
317 318 319
    external_deps += [
      "ipc:ipc_core",
      "safwk:system_ability_fwk",
H
huangxiaolinabc123 已提交
320
      "samgr:samgr_proxy",
H
handyohos 已提交
321 322
    ]
  }
323

X
<fix>  
xiacong 已提交
324
  if (defined(build_seccomp) && build_seccomp) {
X
<fix>  
xiacong 已提交
325 326 327 328
    sources += [
      "../../services/modules/seccomp/seccomp_policy.c",
      "seccomp/seccomp_unittest.cpp",
    ]
X
<fix>  
xiacong 已提交
329 330
    include_dirs +=
        [ "//base/startup/init/interfaces/innerkits/seccomp/include" ]
X
<fix>  
xiacong 已提交
331 332 333 334 335 336 337 338

    if (build_variant == "root") {
      defines += [ "WITH_SECCOMP_DEBUG" ]
    }

    if (use_clang_coverage) {
      defines += [ "COVERAGE_TEST" ]
    }
X
<fix>  
xiacong 已提交
339 340
  }

M
Mupceet 已提交
341 342 343 344 345 346
  if (defined(build_selinux) && build_selinux) {
    sources += [ "param/selinux_unittest.cpp" ]
    include_dirs += [
      "//third_party/selinux/libselinux/include/",
      "//base/security/selinux/interfaces/policycoreutils/include/",
    ]
C
cheng_jinsong 已提交
347 348 349
    sources += [
      "//base/startup/init/services/modules/selinux/selinux_adp.c",
      "//base/startup/init/services/modules/selinux/selinux_static.c",
M
Mupceet 已提交
350
    ]
C
cheng_jinsong 已提交
351

M
Mupceet 已提交
352 353 354 355 356
    defines += [
      "WITH_SELINUX",
      "PARAM_SUPPORT_SELINUX",
    ]
  }
M
Mupceet 已提交
357 358
  if (enable_ohos_startup_init_feature_deviceinfo) {
    sources += [
M
init  
Mupceet 已提交
359 360 361
      "//base/startup/init/device_info/device_info_kits.cpp",
      "//base/startup/init/device_info/device_info_load.cpp",
      "//base/startup/init/device_info/device_info_proxy.cpp",
M
Mupceet 已提交
362
    ]
C
cheng_jinsong 已提交
363 364 365 366 367
    include_dirs += [
      "//third_party/selinux/libselinux/include/",
      "//base/security/access_token/interfaces/innerkits/accesstoken/include",
    ]

M
Mupceet 已提交
368 369
    defines += [ "PARAM_FEATURE_DEVICEINFO" ]
  }
370 371
  cflags_cc = [ "-fexceptions" ]
}