BUILD.gn 7.0 KB
Newer Older
1
# Copyright (c) 2021-2023 Huawei Device Co., Ltd.
Z
zhong_ning 已提交
2 3 4 5 6 7 8 9 10 11
# 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
H
handyohos 已提交
12
# limitations under the License.
M
init  
Mupceet 已提交
13
import("//base/startup/init/begetd.gni")
Y
yanghongliang 已提交
14

M
Mupceet 已提交
15
common_include_dirs = [
M
init  
Mupceet 已提交
16 17 18 19 20 21 22 23 24 25 26 27
  "//base/startup/init/services/begetctl",
  "//base/startup/init/services/begetctl/shell",
  "//base/startup/init/services/param/include",
  "//base/startup/init/services/param/adapter",
  "//base/startup/init/services/param/linux",
  "//base/startup/init/services/param/base",
  "//base/startup/init/services/include/param",
  "//base/startup/init/services/include",
  "//base/startup/init/services/loopevent/include",
  "//base/startup/init/services/init/include",
  "//base/startup/init/services/log",
  "//base/startup/init/interfaces/innerkits/include",
C
cheng_jinsong 已提交
28
  "//base/startup/init/interfaces/innerkits/include/syspara",
A
an_xinwei 已提交
29
  "//base/security/selinux/interfaces/policycoreutils/include",
M
Mupceet 已提交
30
  "//third_party/bounds_checking_function/include",
A
an_xinwei 已提交
31
  "//third_party/selinux/libselinux/include",
M
Mupceet 已提交
32 33
]

M
Mupceet 已提交
34 35 36 37 38 39 40
if (defined(ohos_lite)) {
  executable("begetctl") {
    output_name = "begetctl"
    sources = [
      "main.c",
      "param_cmd.c",
      "shell/shell_bas.c",
X
xionglei6 已提交
41
    ]
M
Mupceet 已提交
42 43 44
    defines = [
      "_GNU_SOURCE",  #syscall function need this macro definition
      "__MUSL__",
M
Mupceet 已提交
45
      "OHOS_LITE",
M
Mupceet 已提交
46
    ]
M
Mupceet 已提交
47
    if (param_test) {
M
init  
Mupceet 已提交
48
      sources += [ "//base/startup/init/test/moduletest/syspara.cpp" ]
M
Mupceet 已提交
49
    }
M
Mupceet 已提交
50 51

    include_dirs = common_include_dirs
M
Mupceet 已提交
52 53
    deps = [
      "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared",
M
init  
Mupceet 已提交
54 55
      "//base/startup/init/interfaces/innerkits:libbegetutil",
      "//base/startup/init/services/utils:libinit_utils",
M
Mupceet 已提交
56 57
      "//build/lite/config/component/cJSON:cjson_static",
      "//third_party/bounds_checking_function:libsec_static",
X
xionglei6 已提交
58
    ]
C
chengjinsong2 已提交
59 60 61 62 63 64

    if (ohos_kernel_type == "linux") {
      deps += [ "//base/startup/init/services/param/linux:param_client" ]
    } else {
      deps += [ "//base/startup/init/services/param/liteos:param_client_lite" ]
    }
X
xionglei6 已提交
65
  }
M
Mupceet 已提交
66 67
} else {
  import("//build/ohos.gni")
X
xionglei6 已提交
68

M
Mupceet 已提交
69 70
  ohos_executable("begetctl") {
    sources = [
C
cheng_jinsong 已提交
71
      "begetctl_cmd.c",
M
Mupceet 已提交
72
      "bootchart_cmd.c",
M
Mupceet 已提交
73
      "dump_service.c",
M
Mupceet 已提交
74 75 76
      "init_cmd_reboot.c",
      "main.c",
      "misc_daemon.cpp",
77
      "modulectl.c",
M
Mupceet 已提交
78 79 80
      "param_cmd.c",
      "sandbox.cpp",
      "service_control.c",
C
cheng_jinsong 已提交
81
      "setloglevel.c",
M
Mupceet 已提交
82 83
      "shell/shell_bas.c",
    ]
X
xionglei6 已提交
84

M
Mupceet 已提交
85
    defines = [ "_GNU_SOURCE" ]
X
xionglei6 已提交
86

A
an_xinwei 已提交
87
    include_dirs = common_include_dirs
M
Mupceet 已提交
88
    deps = [
M
init  
Mupceet 已提交
89 90
      "//base/startup/init/interfaces/innerkits:libbegetutil",
      "//base/startup/init/interfaces/innerkits/control_fd:libcontrolfd",
C
chengjinsong2 已提交
91 92
      "//base/startup/init/services/log:agent_log",
      "//base/startup/init/services/param/linux:param_client",
93
      "//base/startup/init/services/sandbox:sandbox",
C
chengjinsong2 已提交
94
      "//base/startup/init/services/utils:libinit_utils",
M
Mupceet 已提交
95
      "//third_party/bounds_checking_function:libsec_shared",
H
handyohos 已提交
96
      "//third_party/cJSON:cjson",
X
xionglei6 已提交
97
    ]
C
chengjinsong2 已提交
98 99

    deps += [ "//base/startup/init/services/param/base:param_base" ]
H
hongtao 已提交
100
    external_deps = [ "c_utils:utils" ]
M
Mupceet 已提交
101 102

    if (param_test) {
M
Mupceet 已提交
103
      sources += [
M
init  
Mupceet 已提交
104 105
        "//base/startup/init/test/moduletest/param_test_cmds.c",
        "//base/startup/init/test/moduletest/syspara.cpp",
M
Mupceet 已提交
106
      ]
M
init  
Mupceet 已提交
107
      deps += [ "//base/startup/init/interfaces/innerkits:libbeget_proxy" ]
M
Mupceet 已提交
108 109 110 111 112 113 114
      defines += [
        "OHOS_SERVICE_DUMP",
        "INIT_TEST",
      ]
    }

    if (build_selinux) {
A
an_xinwei 已提交
115 116 117
      deps += [
        "//base/security/selinux:libselinux_parameter_static",
        "//third_party/selinux:libselinux",
M
Mupceet 已提交
118 119 120 121 122 123 124 125
      ]
      defines += [ "PARAM_SUPPORT_SELINUX" ]
    }

    symlink_target_name = [
      "reboot",
      "service_control",
    ]
C
slot  
chengjinsong 已提交
126

C
slot  
chengjinsong 已提交
127
    if (enable_ohos_startup_init_feature_ab_partition) {
C
slot  
chengjinsong 已提交
128
      sources += [ "partitionslot.cpp" ]
C
chengjinsong 已提交
129 130 131
      external_deps += [
        "drivers_interface_partitionslot:libpartitionslot_proxy_1.0",
        "hdf_core:libhdi",
132
        "hdf_core:libpub_utils",
C
chengjinsong 已提交
133
      ]
C
slot  
chengjinsong 已提交
134 135
    }

M
Mupceet 已提交
136 137 138
    install_images = [ "system" ]
    install_enable = true
    part_name = "init"
139
    subsystem_name = "startup"
X
xionglei6 已提交
140 141
  }

M
Mupceet 已提交
142 143 144 145 146 147 148 149
  ohos_executable("paramshell") {
    sources = [
      "param_cmd.c",
      "shell/shell_bas.c",
      "shell/shell_main.c",
    ]

    defines = [ "_GNU_SOURCE" ]
M
Mupceet 已提交
150
    include_dirs = common_include_dirs
M
Mupceet 已提交
151
    deps = [
M
init  
Mupceet 已提交
152
      "//base/startup/init/interfaces/innerkits:libbegetutil",
C
chengjinsong2 已提交
153 154 155
      "//base/startup/init/services/log:agent_log",
      "//base/startup/init/services/param/linux:param_client",
      "//base/startup/init/services/utils:libinit_utils",
A
an_xinwei 已提交
156
      "//third_party/bounds_checking_function:libsec_shared",
M
Mupceet 已提交
157 158
    ]

C
chengjinsong2 已提交
159 160
    deps += [ "//base/startup/init/services/param/base:param_base" ]

M
Mupceet 已提交
161
    if (build_selinux) {
A
an_xinwei 已提交
162 163 164 165
      deps += [
        "//base/security/selinux:libselinux_parameter_static",
        "//third_party/selinux:libselinux",
      ]
M
Mupceet 已提交
166 167
      defines += [ "PARAM_SUPPORT_SELINUX" ]
    }
X
xionglei6 已提交
168

M
Mupceet 已提交
169
    if (param_test) {
M
Mupceet 已提交
170
      sources += [
M
init  
Mupceet 已提交
171 172
        "//base/startup/init/test/moduletest/param_test_cmds.c",
        "//base/startup/init/test/moduletest/syspara.cpp",
M
Mupceet 已提交
173
      ]
M
init  
Mupceet 已提交
174
      deps += [ "//base/startup/init/interfaces/innerkits:libbeget_proxy" ]
M
Mupceet 已提交
175 176 177 178 179 180
      defines += [
        "OHOS_SERVICE_DUMP",
        "INIT_TEST",
      ]
    }

C
cheng_jinsong 已提交
181 182 183
    if (startup_init_test_performance) {
      defines += [ "PARAM_TEST_PERFORMANCE" ]
    }
M
Mupceet 已提交
184 185 186 187
    install_images = [ "system" ]
    install_enable = true

    part_name = "init"
188
    subsystem_name = "startup"
M
Mupceet 已提交
189
  }
M
Mupceet 已提交
190 191 192 193 194 195 196 197 198 199 200 201 202

  ohos_executable("param") {
    sources = [
      "main.c",
      "param_cmd.c",
      "shell/shell_bas.c",
    ]

    defines = [
      "INIT_AGENT",
      "_GNU_SOURCE",
    ]

M
Mupceet 已提交
203
    include_dirs = common_include_dirs
M
Mupceet 已提交
204
    deps = [
M
init  
Mupceet 已提交
205 206 207 208
      "//base/startup/init/services/log:agent_log",
      "//base/startup/init/services/loopevent:loopevent",
      "//base/startup/init/services/param/linux:param_client",
      "//base/startup/init/services/utils:libinit_utils",
Z
zhangyafei.echo 已提交
209
      "//third_party/bounds_checking_function:libsec_shared",
M
Mupceet 已提交
210
    ]
C
cheng_jinsong 已提交
211
    deps += [ "//base/startup/init/services/param/base:param_base" ]
M
Mupceet 已提交
212
    external_deps = [
H
hongtao 已提交
213
      "c_utils:utils",
M
Mupceet 已提交
214 215 216
      "hilog_native:libhilog_base",
    ]
    if (build_selinux) {
A
an_xinwei 已提交
217 218 219 220
      deps += [
        "//base/security/selinux:libselinux_parameter_static",
        "//third_party/selinux:libselinux",
      ]
M
Mupceet 已提交
221 222
      defines += [ "PARAM_SUPPORT_SELINUX" ]
    }
223 224
    install_images = [
      "system",
225
      "updater",
226
    ]
M
Mupceet 已提交
227 228
    install_enable = true
    part_name = "init"
229
    subsystem_name = "startup"
M
Mupceet 已提交
230
  }
M
Mupceet 已提交
231
}
M
Mupceet 已提交
232

M
Mupceet 已提交
233 234 235 236 237 238 239
group("begetctl_cmd") {
  if (defined(ohos_lite)) {
    if (enable_ohos_startup_init_feature_begetctl_liteos &&
        ohos_kernel_type != "liteos_m") {
      deps = [ ":begetctl" ]
    }
  } else {
M
Mupceet 已提交
240 241 242 243 244 245
    deps = [
      ":begetctl",
      ":param",
      ":paramshell",
    ]
  }
X
xionglei6 已提交
246
}