BUILD.gn 8.0 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
    ]
    sources = [
35 36 37 38 39 40 41
      "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 已提交
42 43 44 45
      "log/init_log.c",
      "utils/init_hashmap.c",
      "utils/init_utils.c",
      "utils/list.c",
Z
zhong_ning 已提交
46
    ]
M
mamingshuai 已提交
47

48 49
    sources += init_common_sources

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

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

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

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

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

    sources += init_common_sources

123
    include_dirs = [
Z
zhong_ning 已提交
124
      "//base/startup/init_lite/services/include/param",
Z
zhong_ning 已提交
125
      "//base/startup/init_lite/services/include",
126
      "//base/startup/init_lite/services/init/include",
Z
zhong_ning 已提交
127
      "//base/startup/init_lite/services/log",
128
      "//base/startup/init_lite/interfaces/innerkits/include",
X
xionglei6 已提交
129 130 131
      "//base/startup/init_lite/services/loopevent/include",
      "//base/startup/init_lite/interfaces/innerkits/include",
      "//base/startup/init_lite/interfaces/innerkits/fd_holder",
X
xionglei6 已提交
132
      "//base/startup/init_lite/ueventd/include",
133 134 135 136
      "//third_party/cJSON",
      "//third_party/bounds_checking_function/include",
    ]
    deps = [
137
      "//base/startup/init_lite/interfaces/innerkits:libfsmanager_static",
Z
zhong_ning 已提交
138
      "//base/startup/init_lite/services/log:init_log",
X
xionglei6 已提交
139
      "//base/startup/init_lite/services/loopevent:loopevent",
S
sun_fan 已提交
140
      "//base/startup/init_lite/services/param:param_service",
X
xionglei6 已提交
141 142
      "//base/startup/init_lite/services/utils:libinit_tools",
      "//base/startup/init_lite/services/utils:libinit_utils",
X
xionglei6 已提交
143
      "//base/startup/init_lite/ueventd:libueventd_ramdisk_static",
144 145 146
      "//third_party/bounds_checking_function:libsec_static",
      "//third_party/cJSON:cjson_static",
    ]
Q
Qin Fandong 已提交
147 148
    cflags = []

Z
zhong_ning 已提交
149 150 151
    if (use_musl) {
      deps += [
        "//third_party/mksh:sh",
Z
zhong_ning 已提交
152
        "//third_party/toybox:toybox",
Z
zhong_ning 已提交
153 154
      ]
    }
S
sun_fan 已提交
155

Q
Qin Fandong 已提交
156 157 158 159 160 161 162 163 164 165 166 167 168
    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 已提交
169
    defines = [ "OHOS_SERVICE_DUMP" ]
X
xionglei6 已提交
170
    if (!enable_ramdisk) {
X
xionglei6 已提交
171
      defines += [ "DISABLE_INIT_TWO_STAGES" ]
S
sun_fan 已提交
172 173
    }

Y
yanghongliang 已提交
174 175 176
    if (defined(product_name) && product_name == "rk3568") {
      defines += [ "PRODUCT_RK" ]
    }
X
xionglei6 已提交
177
    defines += [ "_GNU_SOURCE" ]
Z
zhong_ning 已提交
178 179 180
    install_images = [
      "system",
      "updater",
X
xionglei6 已提交
181
      "ramdisk",
Z
zhong_ning 已提交
182
    ]
183
    install_enable = true
Z
zhong_ning 已提交
184
    part_name = "init"
M
mamingshuai 已提交
185 186
  }

Z
zhong_ning 已提交
187 188 189 190
  group("startup_init") {
    deps = [
      ":init",
      ":init_etc",
S
sun_fan 已提交
191 192
      "//base/startup/init_lite/services/param:param_client",
      "//base/startup/init_lite/services/param:param_service",
Z
zhong_ning 已提交
193
    ]
H
handyohos 已提交
194 195 196 197 198 199 200 201
    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 已提交
202 203 204
  }

  # init etc files group
Z
zhong_ning 已提交
205
  ohos_prebuilt_etc("init.cfg") {
X
xionglei6 已提交
206
    if (!enable_ramdisk) {
S
sun_fan 已提交
207 208 209 210 211
      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 已提交
212 213 214
    part_name = "init"
  }

Z
zhong_ning 已提交
215 216
  ohos_prebuilt_etc("passwd") {
    source = "//base/startup/init_lite/services/etc/passwd"
Z
zhong_ning 已提交
217 218 219 220
    install_images = [
      "system",
      "updater",
    ]
Z
zhong_ning 已提交
221 222 223
    part_name = "init"
  }

S
sun_fan 已提交
224 225
  ohos_prebuilt_etc("group") {
    source = "//base/startup/init_lite/services/etc/group"
Z
zhong_ning 已提交
226 227 228 229
    install_images = [
      "system",
      "updater",
    ]
S
sun_fan 已提交
230 231 232
    part_name = "init"
  }

Z
zhong_ning 已提交
233 234 235 236 237 238 239 240 241 242
  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 已提交
243
  ohos_prebuilt_etc("ohos.para") {
S
sun_fan 已提交
244
    source = "//base/startup/init_lite/services/etc/param/ohos.para"
Z
zhong_ning 已提交
245
    part_name = "init"
S
sun_fan 已提交
246 247 248 249 250 251 252
    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 已提交
253 254
  }

X
xionglei6 已提交
255 256 257 258 259
  ohos_prebuilt_etc("boot.group") {
    source = "//base/startup/init_lite/services/etc/device.boot.group.cfg"
    part_name = "init"
  }

Z
zhong_ning 已提交
260
  group("init_etc") {
Z
zhong_ning 已提交
261
    deps = [
X
xionglei6 已提交
262
      ":boot.group",
Z
zhong_ning 已提交
263
      ":group",
Z
zhong_ning 已提交
264
      ":init.cfg",
Z
zhong_ning 已提交
265 266
      ":init.usb.cfg",
      ":init.usb.configfs.cfg",
Z
zhong_ning 已提交
267
      ":ohos.para",
S
sun_fan 已提交
268
      ":ohos.para.dac",
Z
zhong_ning 已提交
269
      ":passwd",
Z
zhong_ning 已提交
270
    ]
M
mamingshuai 已提交
271 272
  }
}