• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2021-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
15common_include_dirs = [
16  "//base/startup/init/services/begetctl",
17  "//base/startup/init/services/begetctl/shell",
18  "//base/startup/init/services/param/include",
19  "//base/startup/init/services/param/adapter",
20  "//base/startup/init/services/param/linux",
21  "//base/startup/init/services/param/base",
22  "//base/startup/init/services/include/param",
23  "//base/startup/init/services/include",
24  "//base/startup/init/services/loopevent/include",
25  "//base/startup/init/services/init/include",
26  "//base/startup/init/services/log",
27  "//base/startup/init/interfaces/innerkits/include",
28  "//base/startup/init/interfaces/innerkits/sandbox/include",
29  "//base/security/selinux/interfaces/policycoreutils/include",
30  "//third_party/bounds_checking_function/include",
31  "//third_party/selinux/libselinux/include",
32]
33
34if (defined(ohos_lite)) {
35  executable("begetctl") {
36    output_name = "begetctl"
37    sources = [
38      "main.c",
39      "param_cmd.c",
40      "shell/shell_bas.c",
41    ]
42    defines = [
43      "_GNU_SOURCE",  #syscall function need this macro definition
44      "__MUSL__",
45      "OHOS_LITE",
46    ]
47    if (param_test) {
48      sources += [ "//base/startup/init/test/moduletest/syspara.cpp" ]
49    }
50
51    include_dirs = common_include_dirs
52    deps = [
53      "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared",
54      "//base/startup/init/interfaces/innerkits:libbegetutil",
55      "//base/startup/init/services/utils:libinit_utils",
56      "//build/lite/config/component/cJSON:cjson_static",
57      "//third_party/bounds_checking_function:libsec_static",
58    ]
59  }
60} else {
61  import("//build/ohos.gni")
62
63  ohos_executable("begetctl") {
64    sources = [
65      "bootchart_cmd.c",
66      "dump_service.c",
67      "init_cmd_reboot.c",
68      "main.c",
69      "misc_daemon.cpp",
70      "modulectl.c",
71      "param_cmd.c",
72      "sandbox.cpp",
73      "service_control.c",
74      "setloglevel.c",
75      "shell/shell_bas.c",
76    ]
77
78    defines = [ "_GNU_SOURCE" ]
79
80    if (enable_ohos_startup_init_feature_loader) {
81      defines += [ "PRODUCT_RK" ]
82    }
83
84    include_dirs = common_include_dirs
85    deps = [
86      "//base/startup/init/interfaces/innerkits:libbegetutil",
87      "//base/startup/init/interfaces/innerkits/control_fd:libcontrolfd",
88      "//third_party/bounds_checking_function:libsec_shared",
89    ]
90    external_deps = [ "c_utils:utils" ]
91
92    if (param_test) {
93      sources += [
94        "//base/startup/init/test/moduletest/param_test_cmds.c",
95        "//base/startup/init/test/moduletest/syspara.cpp",
96      ]
97      deps += [ "//base/startup/init/interfaces/innerkits:libbeget_proxy" ]
98      defines += [
99        "OHOS_SERVICE_DUMP",
100        "INIT_TEST",
101      ]
102    }
103
104    if (build_selinux) {
105      deps += [
106        "//base/security/selinux:libselinux_parameter_static",
107        "//third_party/selinux:libselinux",
108      ]
109      defines += [ "PARAM_SUPPORT_SELINUX" ]
110    }
111
112    symlink_target_name = [
113      "misc_daemon",
114      "reboot",
115      "devctl",
116      "service",
117      "service_control",
118      "start_service",
119      "stop_service",
120      "service",
121      "sandbox",
122      "dump_service",
123      "setloglevel",
124      "getloglevel",
125    ]
126
127    if (enable_ohos_startup_init_feature_ab_partition) {
128      sources += [ "partitionslot.cpp" ]
129      include_dirs += [ "//drivers/hdf_core/adapter/uhdf2/include" ]
130      external_deps += [
131        "drivers_interface_partitionslot:libpartitionslot_proxy_1.0",
132        "hdf_core:libhdi",
133      ]
134      symlink_target_name += [ "partitionslot" ]
135    }
136
137    install_images = [ "system" ]
138    install_enable = true
139    part_name = "init"
140    subsystem_name = "startup"
141  }
142
143  ohos_executable("paramshell") {
144    sources = [
145      "param_cmd.c",
146      "shell/shell_bas.c",
147      "shell/shell_main.c",
148    ]
149
150    defines = [ "_GNU_SOURCE" ]
151    include_dirs = common_include_dirs
152    deps = [
153      "//base/startup/init/interfaces/innerkits:libbegetutil",
154      "//third_party/bounds_checking_function:libsec_shared",
155    ]
156
157    if (build_selinux) {
158      deps += [
159        "//base/security/selinux:libselinux_parameter_static",
160        "//third_party/selinux:libselinux",
161      ]
162      defines += [ "PARAM_SUPPORT_SELINUX" ]
163    }
164
165    if (param_test) {
166      sources += [
167        "//base/startup/init/test/moduletest/param_test_cmds.c",
168        "//base/startup/init/test/moduletest/syspara.cpp",
169      ]
170      deps += [ "//base/startup/init/interfaces/innerkits:libbeget_proxy" ]
171      defines += [
172        "OHOS_SERVICE_DUMP",
173        "INIT_TEST",
174      ]
175    }
176
177    install_images = [ "system" ]
178    install_enable = true
179
180    part_name = "init"
181    subsystem_name = "startup"
182  }
183
184  ohos_executable("param") {
185    sources = [
186      "main.c",
187      "param_cmd.c",
188      "shell/shell_bas.c",
189    ]
190
191    defines = [
192      "INIT_AGENT",
193      "_GNU_SOURCE",
194    ]
195
196    include_dirs = common_include_dirs
197    deps = [
198      "//base/startup/init/services/log:agent_log",
199      "//base/startup/init/services/loopevent:loopevent",
200      "//base/startup/init/services/param/linux:param_client",
201      "//base/startup/init/services/utils:libinit_utils",
202      "//third_party/bounds_checking_function:libsec_shared",
203    ]
204    deps += [ "//base/startup/init/services/param/base:param_base" ]
205    external_deps = [
206      "c_utils:utils",
207      "hilog_native:libhilog_base",
208    ]
209    if (build_selinux) {
210      deps += [
211        "//base/security/selinux:libselinux_parameter_static",
212        "//third_party/selinux:libselinux",
213      ]
214      defines += [ "PARAM_SUPPORT_SELINUX" ]
215    }
216    install_images = [ "system" ]
217    install_enable = true
218    part_name = "init"
219    subsystem_name = "startup"
220  }
221}
222
223group("begetctl_cmd") {
224  if (defined(ohos_lite)) {
225    if (enable_ohos_startup_init_feature_begetctl_liteos &&
226        ohos_kernel_type != "liteos_m") {
227      deps = [ ":begetctl" ]
228    }
229  } else {
230    deps = [
231      ":begetctl",
232      ":param",
233      ":paramshell",
234    ]
235  }
236}
237