BUILD.gn 8.4 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",
Z
zhong_ning 已提交
128
      "//base/startup/init_lite/services/include/param",
Z
zhong_ning 已提交
129
      "//base/startup/init_lite/services/include",
130
      "//base/startup/init_lite/services/init/include",
Z
zhong_ning 已提交
131
      "//base/startup/init_lite/services/log",
132
      "//base/startup/init_lite/interfaces/innerkits/include",
X
xionglei6 已提交
133 134 135
      "//base/startup/init_lite/services/loopevent/include",
      "//base/startup/init_lite/interfaces/innerkits/include",
      "//base/startup/init_lite/interfaces/innerkits/fd_holder",
X
xionglei6 已提交
136
      "//base/startup/init_lite/ueventd/include",
137 138 139 140
      "//third_party/cJSON",
      "//third_party/bounds_checking_function/include",
    ]
    deps = [
141 142
      "//base/security/access_token/interfaces/innerkits/nativetoken:libnativetoken",
      "//base/security/access_token/interfaces/innerkits/token_setproc:libtoken_setproc",
143
      "//base/startup/init_lite/interfaces/innerkits:libfsmanager_static",
Z
zhong_ning 已提交
144
      "//base/startup/init_lite/services/log:init_log",
X
xionglei6 已提交
145
      "//base/startup/init_lite/services/loopevent:loopevent",
S
sun_fan 已提交
146
      "//base/startup/init_lite/services/param:param_service",
X
xionglei6 已提交
147 148
      "//base/startup/init_lite/services/utils:libinit_tools",
      "//base/startup/init_lite/services/utils:libinit_utils",
X
xionglei6 已提交
149
      "//base/startup/init_lite/ueventd:libueventd_ramdisk_static",
150 151 152
      "//third_party/bounds_checking_function:libsec_static",
      "//third_party/cJSON:cjson_static",
    ]
Q
Qin Fandong 已提交
153 154
    cflags = []

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

Q
Qin Fandong 已提交
162 163 164 165 166 167 168 169 170 171 172 173 174
    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 已提交
175
    defines = [ "OHOS_SERVICE_DUMP" ]
X
xionglei6 已提交
176
    if (!enable_ramdisk) {
X
xionglei6 已提交
177
      defines += [ "DISABLE_INIT_TWO_STAGES" ]
S
sun_fan 已提交
178 179
    }

Y
yanghongliang 已提交
180 181 182
    if (defined(product_name) && product_name == "rk3568") {
      defines += [ "PRODUCT_RK" ]
    }
X
xionglei6 已提交
183
    defines += [ "_GNU_SOURCE" ]
Z
zhong_ning 已提交
184 185 186
    install_images = [
      "system",
      "updater",
X
xionglei6 已提交
187
      "ramdisk",
Z
zhong_ning 已提交
188
    ]
189
    install_enable = true
Z
zhong_ning 已提交
190
    part_name = "init"
M
mamingshuai 已提交
191 192
  }

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

  # init etc files group
Z
zhong_ning 已提交
211
  ohos_prebuilt_etc("init.cfg") {
X
xionglei6 已提交
212
    if (!enable_ramdisk) {
S
sun_fan 已提交
213 214 215 216 217
      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 已提交
218 219 220
    part_name = "init"
  }

Z
zhong_ning 已提交
221 222
  ohos_prebuilt_etc("passwd") {
    source = "//base/startup/init_lite/services/etc/passwd"
Z
zhong_ning 已提交
223 224 225 226
    install_images = [
      "system",
      "updater",
    ]
Z
zhong_ning 已提交
227 228 229
    part_name = "init"
  }

S
sun_fan 已提交
230 231
  ohos_prebuilt_etc("group") {
    source = "//base/startup/init_lite/services/etc/group"
Z
zhong_ning 已提交
232 233 234 235
    install_images = [
      "system",
      "updater",
    ]
S
sun_fan 已提交
236 237 238
    part_name = "init"
  }

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

X
xionglei6 已提交
261 262 263 264 265
  ohos_prebuilt_etc("boot.group") {
    source = "//base/startup/init_lite/services/etc/device.boot.group.cfg"
    part_name = "init"
  }

Z
zhong_ning 已提交
266
  group("init_etc") {
Z
zhong_ning 已提交
267
    deps = [
X
xionglei6 已提交
268
      ":boot.group",
Z
zhong_ning 已提交
269
      ":group",
Z
zhong_ning 已提交
270
      ":init.cfg",
Z
zhong_ning 已提交
271 272
      ":init.usb.cfg",
      ":init.usb.configfs.cfg",
Z
zhong_ning 已提交
273
      ":ohos.para",
S
sun_fan 已提交
274
      ":ohos.para.dac",
Z
zhong_ning 已提交
275
      ":passwd",
Z
zhong_ning 已提交
276
    ]
M
mamingshuai 已提交
277 278
  }
}