• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2021-2023 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/interfaces/innerkits/include/param",
23  "//base/startup/init/interfaces/innerkits/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/include/syspara",
29]
30
31if (defined(ohos_lite)) {
32  executable("begetctl") {
33    output_name = "begetctl"
34    sources = [
35      "main.c",
36      "param_cmd.c",
37      "shell/shell_bas.c",
38    ]
39    defines = [
40      "_GNU_SOURCE",  #syscall function need this macro definition
41      "__MUSL__",
42      "OHOS_LITE",
43    ]
44    if (param_test) {
45      sources += [ "//base/startup/init/test/moduletest/syspara.cpp" ]
46    }
47
48    include_dirs = common_include_dirs
49    include_dirs +=
50        [ "//base/security/selinux_adapter/interfaces/policycoreutils/include" ]
51    deps = [
52      "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared",
53      "//base/startup/init/interfaces/innerkits:libbegetutil",
54      "//base/startup/init/services/utils:libinit_utils",
55      "//build/lite/config/component/cJSON:cjson_static",
56    ]
57    external_deps = [ "bounds_checking_function:libsec_static" ]
58
59    if (ohos_kernel_type == "linux") {
60      deps += [ "//base/startup/init/services/param/linux:param_client" ]
61    } else {
62      deps += [ "//base/startup/init/services/param/liteos:param_client_lite" ]
63    }
64  }
65} else {
66  import("//build/ohos.gni")
67
68  ohos_executable("begetctl") {
69    sources = [
70      "appspawntime_cmd.c",
71      "begetctl_cmd.c",
72      "bootchart_cmd.c",
73      "dump_service.c",
74      "init_cmd_reboot.c",
75      "main.c",
76      "misc_daemon.cpp",
77      "modulectl.c",
78      "param_cmd.c",
79      "sandbox.cpp",
80      "service_control.c",
81      "setloglevel.c",
82      "shell/shell_bas.c",
83    ]
84
85    defines = [ "_GNU_SOURCE" ]
86
87    include_dirs = common_include_dirs
88    deps = [
89      "//base/startup/init/interfaces/innerkits:libbegetutil",
90      "//base/startup/init/interfaces/innerkits/control_fd:libcontrolfd",
91      "//base/startup/init/services/log:agent_log",
92      "//base/startup/init/services/param/linux:param_client",
93      "//base/startup/init/services/sandbox:sandbox",
94      "//base/startup/init/services/utils:libinit_utils",
95    ]
96
97    deps += [ "//base/startup/init/services/param/base:param_base" ]
98    external_deps = [
99      "bounds_checking_function:libsec_shared",
100      "cJSON:cjson",
101      "c_utils:utils",
102    ]
103    if (init_appspawn_client_module && defined(global_parts_info) &&
104        defined(global_parts_info.startup_appspawn)) {
105      defines += [ "ENABLE_ENTER_APPSPAWN_SANDBOX" ]
106      external_deps += [ "appspawn:appspawn_client" ]
107    }
108    if (param_test) {
109      sources += [
110        "//base/startup/init/test/moduletest/param_test_cmds.c",
111        "//base/startup/init/test/moduletest/syspara.cpp",
112      ]
113      deps += [ "//base/startup/init/interfaces/innerkits:libbeget_proxy" ]
114      defines += [
115        "OHOS_SERVICE_DUMP",
116        "INIT_TEST",
117      ]
118    }
119
120    if (build_selinux) {
121      external_deps += [
122        "selinux:libselinux",
123        "selinux_adapter:libselinux_parameter_static",
124      ]
125      defines += [ "PARAM_SUPPORT_SELINUX" ]
126    }
127
128    if (init_extra_static_modules == "") {
129      defines += [ "SUPPORT_REBOOT_CHARGE" ]
130    }
131
132    symlink_target_name = [
133      "reboot",
134      "service_control",
135    ]
136
137    if (init_feature_ab_partition) {
138      sources += [ "partitionslot.cpp" ]
139      external_deps += [
140        "drivers_interface_partitionslot:libpartitionslot_proxy_1.0",
141        "hdf_core:libhdi",
142        "hdf_core:libpub_utils",
143      ]
144    }
145
146    install_images = [ "system" ]
147    install_enable = true
148    part_name = "init"
149    subsystem_name = "startup"
150  }
151
152  ohos_executable("reboot") {
153    sources = [
154      "init_cmd_reboot.c",
155      "main.c",
156      "param_cmd.c",
157      "shell/shell_bas.c",
158    ]
159
160    defines = [ "_GNU_SOURCE" ]
161
162    include_dirs = common_include_dirs
163    deps = [
164      "//base/startup/init/interfaces/innerkits:libbegetutil",
165      "//base/startup/init/services/log:agent_log",
166      "//base/startup/init/services/param/linux:param_client",
167      "//base/startup/init/services/utils:libinit_utils",
168    ]
169
170    deps += [ "//base/startup/init/services/param/base:param_base" ]
171    external_deps = [
172      "bounds_checking_function:libsec_shared",
173      "cJSON:cjson",
174      "c_utils:utils",
175      "selinux:libselinux",
176      "selinux_adapter:libselinux_parameter_static",
177    ]
178
179    if (init_extra_static_modules == "") {
180      defines += [ "SUPPORT_REBOOT_CHARGE" ]
181    }
182
183    install_images = [ "updater" ]
184    install_enable = true
185    part_name = "init"
186    subsystem_name = "startup"
187  }
188
189  ohos_executable("paramshell") {
190    sources = [
191      "param_cmd.c",
192      "shell/shell_bas.c",
193      "shell/shell_main.c",
194    ]
195
196    defines = [ "_GNU_SOURCE" ]
197    include_dirs = common_include_dirs
198    deps = [
199      "//base/startup/init/interfaces/innerkits:libbegetutil",
200      "//base/startup/init/services/log:agent_log",
201      "//base/startup/init/services/param/linux:param_client",
202      "//base/startup/init/services/utils:libinit_utils",
203    ]
204    external_deps = [ "bounds_checking_function:libsec_shared" ]
205
206    if (build_selinux) {
207      external_deps += [
208        "selinux:libselinux",
209        "selinux_adapter:libselinux_parameter_static",
210      ]
211      defines += [ "PARAM_SUPPORT_SELINUX" ]
212    }
213
214    if (param_test) {
215      sources += [
216        "//base/startup/init/test/moduletest/param_test_cmds.c",
217        "//base/startup/init/test/moduletest/syspara.cpp",
218      ]
219      deps += [ "//base/startup/init/interfaces/innerkits:libbeget_proxy" ]
220      defines += [
221        "OHOS_SERVICE_DUMP",
222        "INIT_TEST",
223      ]
224    }
225
226    install_images = [ "system" ]
227    install_enable = true
228
229    part_name = "init"
230    subsystem_name = "startup"
231  }
232
233  ohos_executable("param") {
234    sources = [
235      "main.c",
236      "param_cmd.c",
237      "shell/shell_bas.c",
238    ]
239
240    defines = [
241      "INIT_AGENT",
242      "_GNU_SOURCE",
243    ]
244
245    include_dirs = common_include_dirs
246    deps = [
247      "//base/startup/init/services/log:agent_log",
248      "//base/startup/init/services/loopevent:loopevent",
249      "//base/startup/init/services/param/linux:param_client",
250      "//base/startup/init/services/utils:libinit_utils",
251    ]
252    deps += [ "//base/startup/init/services/param/base:param_base" ]
253    external_deps = [
254      "bounds_checking_function:libsec_shared",
255      "c_utils:utils",
256      "hilog:libhilog_base",
257    ]
258    if (build_selinux) {
259      defines += [ "PARAM_SUPPORT_SELINUX" ]
260      external_deps += [
261        "selinux:libselinux",
262        "selinux_adapter:libselinux_parameter_static",
263      ]
264    }
265    install_images = [
266      "system",
267      "updater",
268    ]
269    install_enable = true
270    part_name = "init"
271    subsystem_name = "startup"
272  }
273}
274
275group("begetctl_cmd") {
276  if (defined(ohos_lite)) {
277    if (init_feature_begetctl_liteos && ohos_kernel_type != "liteos_m") {
278      deps = [ ":begetctl" ]
279    }
280  } else {
281    deps = [
282      ":begetctl",
283      ":param",
284      ":paramshell",
285      ":reboot",
286    ]
287  }
288}
289