1# Copyright (c) 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.
13import("//base/startup/init/begetd.gni")
14
15init_common_sources = [
16  "../init_capability.c",
17  "../init_common_cmds.c",
18  "../init_common_service.c",
19  "../init_config.c",
20  "../init_group_manager.c",
21  "../init_service_file.c",
22  "../init_service_manager.c",
23  "../init_service_socket.c",
24  "../main.c",
25]
26
27# feature: init
28executable("init") {
29  output_name = "init"
30  defines = [
31    "_GNU_SOURCE",
32    "OHOS_LITE",
33    "__MUSL__",
34  ]
35  if (init_feature_begetctl_liteos) {
36    defines += [ "LITEOS_SUPPORT" ]
37  }
38  sources = [
39    "../adapter/init_adapter.c",
40    "../lite/init.c",
41    "../lite/init_cmds.c",
42    "../lite/init_jobs.c",
43    "../lite/init_reboot.c",
44    "../lite/init_service.c",
45    "../lite/init_signal_handler.c",
46  ]
47  sources += init_common_sources
48
49  include_dirs = [
50    "//base/startup/init/interfaces/innerkits/include",
51    "//base/startup/init/interfaces/innerkits/fd_holder",
52    "//base/startup/init/interfaces/innerkits/include/param",
53    "//base/startup/init/services/init/include",
54    "//third_party/cJSON",
55    "//base/hiviewdfx/hilog_lite/interfaces/native/kits",
56  ]
57
58  ldflags = []
59  deps = [
60    "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared",
61    "//base/startup/init/services/log:init_log",
62    "//base/startup/init/services/loopevent:loopevent",
63    "//base/startup/init/services/modules/init_hook:inithook",
64    "//base/startup/init/services/param/base:param_base",
65    "//base/startup/init/services/utils:libinit_utils",
66    "//build/lite/config/component/cJSON:cjson_static",
67  ]
68  external_deps = [ "bounds_checking_function:libsec_static" ]
69
70  if (ohos_kernel_type == "liteos_a") {
71    defines += [ "__LITEOS_A__" ]
72    include_dirs += [
73      "//kernel/liteos_a/syscall",
74      "//kernel/liteos_a/kernel/include",
75      "//base/startup/init/interfaces/kits/syscap",
76      "//base/startup/init/initsync/include",
77    ]
78    deps += [
79      "//base/startup/init/initsync:initsync",
80      "//base/startup/init/services/param/liteos:param_init_lite",
81    ]
82  }
83  if (ohos_kernel_type == "linux") {
84    defines += [
85      "NEED_EXEC_RCS_LINUX",
86      "__LINUX__",
87    ]
88    ldflags += [
89      "-lm",
90      "-lpthread",
91    ]
92    deps += [
93      "//base/startup/init/services/param/linux:param_init",
94      "//third_party/mksh",
95    ]
96    external_deps += [ "toybox:toybox" ]
97  }
98}
99