BUILD.gn 10.1 KB
Newer Older
1
# Copyright (c) 2020-2021 Huawei Device Co., Ltd.
M
mamingshuai 已提交
2 3 4 5 6 7 8 9 10 11 12
# 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.
13 14 15 16 17

init_common_sources = [
  "init/init_capability.c",
  "init/init_common_cmds.c",
  "init/init_common_service.c",
S
sun_fan 已提交
18
  "init/init_config.c",
X
xionglei6 已提交
19
  "init/init_group_manager.c",
X
xionglei6 已提交
20
  "init/init_service_file.c",
21 22 23 24 25
  "init/init_service_manager.c",
  "init/init_service_socket.c",
  "init/main.c",
]

Z
zhong_ning 已提交
26 27
if (defined(ohos_lite)) {
  # feature: init
28 29
  executable("init_lite") {
    output_name = "init"
Z
zhong_ning 已提交
30 31
    defines = [
      "_GNU_SOURCE",  #syscall function need this macro definition
Z
zhong_ning 已提交
32
      "OHOS_LITE",
Z
zhong_ning 已提交
33
    ]
34
    defines += [ "__MUSL__" ]
Z
zhong_ning 已提交
35
    sources = [
36 37 38 39 40 41 42
      "init/adapter/init_adapter.c",
      "init/lite/init.c",
      "init/lite/init_cmds.c",
      "init/lite/init_jobs.c",
      "init/lite/init_reboot.c",
      "init/lite/init_service.c",
      "init/lite/init_signal_handler.c",
X
xionglei6 已提交
43 44 45 46
      "log/init_log.c",
      "utils/init_hashmap.c",
      "utils/init_utils.c",
      "utils/list.c",
Z
zhong_ning 已提交
47
    ]
M
mamingshuai 已提交
48

49 50
    sources += init_common_sources

Z
zhong_ning 已提交
51
    include_dirs = [
Z
zhong_ning 已提交
52
      "//base/startup/init_lite/services/include",
53
      "//base/startup/init_lite/services/init/include",
Z
zhong_ning 已提交
54
      "//base/startup/init_lite/services/log",
55
      "//base/startup/init_lite/services/loopevent/include",
X
xionglei6 已提交
56
      "//base/startup/init_lite/interfaces/innerkits/include",
Z
zhong_ning 已提交
57 58 59
      "//third_party/cJSON",
      "//third_party/bounds_checking_function/include",
      "//base/startup/syspara_lite/interfaces/kits",
Z
zhong_ning 已提交
60
      "//base/hiviewdfx/hilog_lite/interfaces/native/kits",
X
xionglei6 已提交
61
      "//base/startup/init_lite/interfaces/innerkits/fd_holder",
Z
zhong_ning 已提交
62
    ]
M
mamingshuai 已提交
63

Z
zhong_ning 已提交
64
    cflags = [ "-Wall" ]
M
mamingshuai 已提交
65

Z
zhong_ning 已提交
66
    deps = [
Z
zhong_ning 已提交
67
      "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared",
68
      "//base/startup/init_lite/initsync:initsync",
69
      "//base/startup/init_lite/services/loopevent:loopevent",
Z
zhong_ning 已提交
70
      "//base/startup/syspara_lite/frameworks/parameter:parameter",
Z
zhong_ning 已提交
71 72 73 74 75
      "//build/lite/config/component/cJSON:cjson_shared",
      "//third_party/bounds_checking_function:libsec_shared",
    ]
    ldflags = []
    if (ohos_kernel_type == "liteos_a") {
76
      include_dirs += [
S
sun_fan 已提交
77
        "//kernel/liteos_a/syscall",
78 79 80 81
        "//base/startup/init_lite/interfaces/kits",
        "//base/startup/init_lite/initsync/include",
      ]
      deps += [ "//base/startup/init_lite/initsync:initsync" ]
Z
zhong_ning 已提交
82 83 84
    }
    if (ohos_kernel_type == "linux") {
      defines += [ "NEED_EXEC_RCS_LINUX" ]
X
xionglei6 已提交
85
      defines += [ "_GNU_SOURCE" ]
Z
zhong_ning 已提交
86 87 88 89
      ldflags += [
        "-lm",
        "-lpthread",
      ]
Y
yangming_ha 已提交
90
      deps += [
91 92 93
        "//third_party/mksh",
        "//third_party/toybox",
      ]
Z
zhong_ning 已提交
94 95
    }
  }
M
mamingshuai 已提交
96

Z
zhong_ning 已提交
97 98
  if (ohos_build_type == "debug") {
    group("unittest") {
X
add ut  
xionglei6 已提交
99
      deps = [ "//base/startup/init_lite/test/unittest/common:unittest" ]
Z
zhong_ning 已提交
100 101 102
    }
  }
} else {
H
handyohos 已提交
103
  import("//base/startup/init_lite/begetd.gni")
Z
zhong_ning 已提交
104
  import("//build/ohos.gni")
M
mamingshuai 已提交
105

Z
zhong_ning 已提交
106
  ohos_executable("init") {
107
    sources = [
X
xionglei6 已提交
108
      "//base/startup/init_lite/interfaces/innerkits/fd_holder/fd_holder_internal.c",
109 110
      "init/adapter/init_adapter.c",
      "init/standard/device.c",
X
xionglei6 已提交
111
      "init/standard/fd_holder_service.c",
112 113 114
      "init/standard/init.c",
      "init/standard/init_cmds.c",
      "init/standard/init_jobs.c",
S
sun_fan 已提交
115
      "init/standard/init_mount.c",
X
xionglei6 已提交
116
      "init/standard/init_plugin_manager.c",
117 118 119 120
      "init/standard/init_reboot.c",
      "init/standard/init_service.c",
      "init/standard/init_signal_handler.c",
      "init/standard/switch_root.c",
121
    ]
122 123 124

    sources += init_common_sources

125
    include_dirs = [
126 127
      "//base/security/access_token/interfaces/innerkits/token_setproc/include",
      "//base/security/access_token/interfaces/innerkits/nativetoken/include",
X
xionglei6 已提交
128
      "//base/startup/init_lite/interfaces/innerkits/sandbox/include",
Z
zhong_ning 已提交
129
      "//base/startup/init_lite/services/include/param",
Z
zhong_ning 已提交
130
      "//base/startup/init_lite/services/include",
131
      "//base/startup/init_lite/services/init/include",
Z
zhong_ning 已提交
132
      "//base/startup/init_lite/services/log",
133
      "//base/startup/init_lite/interfaces/innerkits/include",
X
xionglei6 已提交
134 135 136
      "//base/startup/init_lite/services/loopevent/include",
      "//base/startup/init_lite/interfaces/innerkits/include",
      "//base/startup/init_lite/interfaces/innerkits/fd_holder",
X
xionglei6 已提交
137
      "//base/startup/init_lite/ueventd/include",
138 139 140 141
      "//third_party/cJSON",
      "//third_party/bounds_checking_function/include",
    ]
    deps = [
142 143
      "//base/security/access_token/interfaces/innerkits/nativetoken:libnativetoken",
      "//base/security/access_token/interfaces/innerkits/token_setproc:libtoken_setproc",
144
      "//base/startup/init_lite/interfaces/innerkits:libfsmanager_static",
X
xionglei6 已提交
145
      "//base/startup/init_lite/interfaces/innerkits/sandbox:libsandbox_static",
Z
zhong_ning 已提交
146
      "//base/startup/init_lite/services/log:init_log",
X
xionglei6 已提交
147
      "//base/startup/init_lite/services/loopevent:loopevent",
S
sun_fan 已提交
148
      "//base/startup/init_lite/services/param:param_service",
X
xionglei6 已提交
149 150
      "//base/startup/init_lite/services/utils:libinit_tools",
      "//base/startup/init_lite/services/utils:libinit_utils",
X
xionglei6 已提交
151
      "//base/startup/init_lite/ueventd:libueventd_ramdisk_static",
152 153 154
      "//third_party/bounds_checking_function:libsec_static",
      "//third_party/cJSON:cjson_static",
    ]
155

Q
Qin Fandong 已提交
156 157
    cflags = []

Z
zhong_ning 已提交
158 159 160
    if (use_musl) {
      deps += [
        "//third_party/mksh:sh",
Z
zhong_ning 已提交
161
        "//third_party/toybox:toybox",
Z
zhong_ning 已提交
162 163
      ]
    }
S
sun_fan 已提交
164

Q
Qin Fandong 已提交
165 166 167 168 169 170 171 172 173 174 175 176 177
    if (build_selinux) {
      include_dirs += [
        "//third_party/selinux/libselinux/include/",
        "//base/security/selinux/interfaces/policycoreutils/include/",
      ]
      deps += [
        "//base/security/selinux:libload_policy",
        "//base/security/selinux:librestorecon",
        "//third_party/selinux:libselinux",
      ]
      cflags += [ "-DWITH_SELINUX" ]
    }

X
xionglei6 已提交
178 179 180 181 182 183 184 185
    defines = []
    if (param_test) {
      defines += [
        "OHOS_SERVICE_DUMP",
        "INIT_TEST",
      ]
    }

X
xionglei6 已提交
186
    if (!enable_ramdisk) {
X
xionglei6 已提交
187
      defines += [ "DISABLE_INIT_TWO_STAGES" ]
S
sun_fan 已提交
188
    }
189 190 191
    if (support_jsapi) {
      defines += [ "SUPPORT_PROFILER_HIDEBUG" ]
    }
S
sun_fan 已提交
192

Y
yanghongliang 已提交
193 194 195
    if (defined(product_name) && product_name == "rk3568") {
      defines += [ "PRODUCT_RK" ]
    }
X
xionglei6 已提交
196
    defines += [ "_GNU_SOURCE" ]
Z
zhong_ning 已提交
197 198 199
    install_images = [
      "system",
      "updater",
X
xionglei6 已提交
200
      "ramdisk",
Z
zhong_ning 已提交
201
    ]
202
    install_enable = true
Z
zhong_ning 已提交
203
    part_name = "init"
M
mamingshuai 已提交
204 205
  }

Z
zhong_ning 已提交
206 207 208 209
  group("startup_init") {
    deps = [
      ":init",
      ":init_etc",
S
sun_fan 已提交
210 211
      "//base/startup/init_lite/services/param:param_client",
      "//base/startup/init_lite/services/param:param_service",
Z
zhong_ning 已提交
212
    ]
H
handyohos 已提交
213 214 215 216 217 218 219 220
    if (param_feature_watcher) {
      deps += [
        "//base/startup/init_lite/services/param/watcher:param_watcher",
        "//base/startup/init_lite/services/param/watcher:param_watcher.rc",
        "//base/startup/init_lite/services/param/watcher:param_watcheragent",
        "//base/startup/init_lite/services/param/watcher/sa_profile:param_watcher_profile",
      ]
    }
Z
zhong_ning 已提交
221 222 223
  }

  # init etc files group
Z
zhong_ning 已提交
224
  ohos_prebuilt_etc("init.cfg") {
X
xionglei6 已提交
225
    if (!enable_ramdisk) {
S
sun_fan 已提交
226 227 228 229 230
      source =
          "//base/startup/init_lite/services/etc/init.without_two_stages.cfg"
    } else {
      source = "//base/startup/init_lite/services/etc/init.cfg"
    }
Z
zhong_ning 已提交
231 232 233
    part_name = "init"
  }

Z
zhong_ning 已提交
234 235
  ohos_prebuilt_etc("passwd") {
    source = "//base/startup/init_lite/services/etc/passwd"
Z
zhong_ning 已提交
236 237 238 239
    install_images = [
      "system",
      "updater",
    ]
Z
zhong_ning 已提交
240 241 242
    part_name = "init"
  }

S
sun_fan 已提交
243 244
  ohos_prebuilt_etc("group") {
    source = "//base/startup/init_lite/services/etc/group"
Z
zhong_ning 已提交
245 246 247 248
    install_images = [
      "system",
      "updater",
    ]
S
sun_fan 已提交
249 250 251
    part_name = "init"
  }

Z
zhong_ning 已提交
252 253 254 255 256 257 258 259 260 261
  ohos_prebuilt_etc("init.usb.cfg") {
    source = "//base/startup/init_lite/services/etc/init.usb.cfg"
    part_name = "init"
  }

  ohos_prebuilt_etc("init.usb.configfs.cfg") {
    source = "//base/startup/init_lite/services/etc/init.usb.configfs.cfg"
    part_name = "init"
  }

Z
zhong_ning 已提交
262
  ohos_prebuilt_etc("ohos.para") {
S
sun_fan 已提交
263
    source = "//base/startup/init_lite/services/etc/param/ohos.para"
Z
zhong_ning 已提交
264
    part_name = "init"
S
sun_fan 已提交
265 266 267 268 269 270 271
    module_install_dir = "etc/param"
  }

  ohos_prebuilt_etc("ohos.para.dac") {
    source = "//base/startup/init_lite/services/etc/param/ohos.para.dac"
    part_name = "init"
    module_install_dir = "etc/param"
Z
zhong_ning 已提交
272 273
  }

X
xionglei6 已提交
274 275 276 277 278
  ohos_prebuilt_etc("boot.group") {
    source = "//base/startup/init_lite/services/etc/device.boot.group.cfg"
    part_name = "init"
  }

X
xionglei6 已提交
279 280 281 282 283
  ohos_prebuilt_etc("charing.group") {
    source = "//base/startup/init_lite/services/etc/device.charing.group.cfg"
    part_name = "init"
  }

L
lnlan 已提交
284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300
  ohos_prebuilt_etc("syscap.para") {
    source =
        "${preloader_output_dir}/${product_name}/system/etc/param/syscap.para"
    module_install_dir = "etc/param/"
    part_name = "init"
  }

  ohos_prebuilt_etc("syscap.json") {
    source = "${preloader_output_dir}/${product_name}/system/etc/syscap.json"
    part_name = "init"
  }

  ohos_prebuilt_etc("systemcapability.json") {
    source = "${preloader_output_dir}/${product_name}/system/etc/SystemCapability.json"
    part_name = "init"
  }

X
xionglei6 已提交
301 302 303 304 305
  ohos_prebuilt_etc("plugin_modules") {
    source = "//base/startup/init_lite/services/etc/plugin_modules.cfg"
    part_name = "init"
  }

X
xionglei6 已提交
306 307 308 309 310 311 312 313 314 315 316 317
  ohos_prebuilt_etc("system-sandbox.json") {
    source = "//base/startup/init_lite/interfaces/innerkits/sandbox/system-sandbox.json"
    part_name = "init"
    module_install_dir = "etc/sandbox"
  }

  ohos_prebuilt_etc("chipset-sandbox.json") {
    source = "//base/startup/init_lite/interfaces/innerkits/sandbox/chipset-sandbox.json"
    part_name = "init"
    module_install_dir = "etc/sandbox"
  }

Z
zhong_ning 已提交
318
  group("init_etc") {
Z
zhong_ning 已提交
319
    deps = [
X
xionglei6 已提交
320
      ":boot.group",
X
xionglei6 已提交
321
      ":charing.group",
X
xionglei6 已提交
322
      ":chipset-sandbox.json",
Z
zhong_ning 已提交
323
      ":group",
Z
zhong_ning 已提交
324
      ":init.cfg",
Z
zhong_ning 已提交
325 326
      ":init.usb.cfg",
      ":init.usb.configfs.cfg",
Z
zhong_ning 已提交
327
      ":ohos.para",
S
sun_fan 已提交
328
      ":ohos.para.dac",
Z
zhong_ning 已提交
329
      ":passwd",
X
xionglei6 已提交
330
      ":plugin_modules",
L
lnlan 已提交
331 332
      ":syscap.json",
      ":syscap.para",
X
xionglei6 已提交
333
      ":system-sandbox.json",
L
lnlan 已提交
334
      ":systemcapability.json",
Z
zhong_ning 已提交
335
    ]
M
mamingshuai 已提交
336 337
  }
}