BUILD.gn 7.2 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_service_file.c",
20 21 22 23 24 25 26 27
  "init/init_service_manager.c",
  "init/init_service_socket.c",
  "init/main.c",
  "log/init_log.c",
  "utils/init_utils.c",
  "utils/list.c",
]

Z
zhong_ning 已提交
28 29
if (defined(ohos_lite)) {
  # feature: init
30 31
  executable("init_lite") {
    output_name = "init"
Z
zhong_ning 已提交
32 33
    defines = [
      "_GNU_SOURCE",  #syscall function need this macro definition
Z
zhong_ning 已提交
34
      "OHOS_LITE",
Z
zhong_ning 已提交
35 36
    ]
    sources = [
37 38 39 40 41 42 43
      "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",
Z
zhong_ning 已提交
44
    ]
M
mamingshuai 已提交
45

46 47
    sources += init_common_sources

Z
zhong_ning 已提交
48
    include_dirs = [
Z
zhong_ning 已提交
49
      "//base/startup/init_lite/services/include",
50
      "//base/startup/init_lite/services/init/include",
Z
zhong_ning 已提交
51
      "//base/startup/init_lite/services/log",
Z
zhong_ning 已提交
52 53 54
      "//third_party/cJSON",
      "//third_party/bounds_checking_function/include",
      "//base/startup/syspara_lite/interfaces/kits",
Z
zhong_ning 已提交
55
      "//base/hiviewdfx/hilog_lite/interfaces/native/kits",
Z
zhong_ning 已提交
56
    ]
M
mamingshuai 已提交
57

Z
zhong_ning 已提交
58
    cflags = [ "-Wall" ]
M
mamingshuai 已提交
59

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

Z
zhong_ning 已提交
89 90
  if (ohos_build_type == "debug") {
    group("unittest") {
X
add ut  
xionglei6 已提交
91
      deps = [ "//base/startup/init_lite/test/unittest/common:unittest" ]
Z
zhong_ning 已提交
92 93 94 95
    }
  }
} else {
  import("//build/ohos.gni")
M
mamingshuai 已提交
96

Z
zhong_ning 已提交
97
  ohos_executable("init") {
98
    sources = [
99 100 101 102 103
      "init/adapter/init_adapter.c",
      "init/standard/device.c",
      "init/standard/init.c",
      "init/standard/init_cmds.c",
      "init/standard/init_jobs.c",
S
sun_fan 已提交
104
      "init/standard/init_mount.c",
105 106 107 108
      "init/standard/init_reboot.c",
      "init/standard/init_service.c",
      "init/standard/init_signal_handler.c",
      "init/standard/switch_root.c",
109
    ]
110 111 112

    sources += init_common_sources

113
    include_dirs = [
Z
zhong_ning 已提交
114
      "//base/startup/init_lite/services/include/param",
Z
zhong_ning 已提交
115
      "//base/startup/init_lite/services/include",
116
      "//base/startup/init_lite/services/init/include",
Z
zhong_ning 已提交
117
      "//base/startup/init_lite/services/log",
118
      "//base/startup/init_lite/interfaces/innerkits/include",
X
xionglei6 已提交
119
      "//base/startup/init_lite/ueventd/include",
120 121
      "//third_party/cJSON",
      "//third_party/bounds_checking_function/include",
Z
zhong_ning 已提交
122
      "//third_party/libuv/include",
123 124
    ]
    deps = [
125
      "//base/startup/init_lite/interfaces/innerkits/fs_manager:libfsmanager_static",
Z
zhong_ning 已提交
126
      "//base/startup/init_lite/services/log:init_log",
S
sun_fan 已提交
127
      "//base/startup/init_lite/services/param:param_service",
X
xionglei6 已提交
128
      "//base/startup/init_lite/ueventd:libueventd_static",
129 130 131
      "//third_party/bounds_checking_function:libsec_static",
      "//third_party/cJSON:cjson_static",
    ]
Q
Qin Fandong 已提交
132 133
    cflags = []

Z
zhong_ning 已提交
134 135 136
    if (use_musl) {
      deps += [
        "//third_party/mksh:sh",
Z
zhong_ning 已提交
137
        "//third_party/toybox:toybox",
Z
zhong_ning 已提交
138 139
      ]
    }
S
sun_fan 已提交
140

Q
Qin Fandong 已提交
141 142 143 144 145 146 147 148 149 150 151 152 153
    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 已提交
154
    if (!enable_ramdisk) {
S
sun_fan 已提交
155 156 157
      defines = [ "DISABLE_INIT_TWO_STAGES" ]
    }

Y
yanghongliang 已提交
158 159 160 161
    if (defined(product_name) && product_name == "rk3568") {
      defines += [ "PRODUCT_RK" ]
    }

Z
zhong_ning 已提交
162 163 164
    install_images = [
      "system",
      "updater",
X
xionglei6 已提交
165
      "ramdisk",
Z
zhong_ning 已提交
166
    ]
167
    install_enable = true
Z
zhong_ning 已提交
168
    part_name = "init"
M
mamingshuai 已提交
169 170
  }

Z
zhong_ning 已提交
171 172 173 174
  group("startup_init") {
    deps = [
      ":init",
      ":init_etc",
S
sun_fan 已提交
175
      "//base/startup/init_lite/interfaces/innerkits/dynamic_service:dynamic_service",
X
xionglei6 已提交
176
      "//base/startup/init_lite/interfaces/innerkits/file:libfile",
177
      "//base/startup/init_lite/interfaces/innerkits/fs_manager:libfsmanager_shared",
X
xionglei6 已提交
178
      "//base/startup/init_lite/interfaces/innerkits/reboot:libreboot",
X
xionglei6 已提交
179
      "//base/startup/init_lite/interfaces/innerkits/socket:libsocket",
S
sun_fan 已提交
180 181 182 183 184 185
      "//base/startup/init_lite/services/param:param_client",
      "//base/startup/init_lite/services/param:param_service",
      "//base/startup/init_lite/services/param:param_watcher",
      "//base/startup/init_lite/services/param:param_watcher.rc",
      "//base/startup/init_lite/services/param:param_watcheragent",
      "//base/startup/init_lite/services/param/watcher/sa_profile:param_watcher_profile",
Z
zhong_ning 已提交
186 187 188 189
    ]
  }

  # init etc files group
Z
zhong_ning 已提交
190
  ohos_prebuilt_etc("init.cfg") {
X
xionglei6 已提交
191
    if (!enable_ramdisk) {
S
sun_fan 已提交
192 193 194 195 196
      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 已提交
197 198 199
    part_name = "init"
  }

Z
zhong_ning 已提交
200 201
  ohos_prebuilt_etc("passwd") {
    source = "//base/startup/init_lite/services/etc/passwd"
Z
zhong_ning 已提交
202 203 204 205
    install_images = [
      "system",
      "updater",
    ]
Z
zhong_ning 已提交
206 207 208
    part_name = "init"
  }

S
sun_fan 已提交
209 210
  ohos_prebuilt_etc("group") {
    source = "//base/startup/init_lite/services/etc/group"
Z
zhong_ning 已提交
211 212 213 214
    install_images = [
      "system",
      "updater",
    ]
S
sun_fan 已提交
215 216 217
    part_name = "init"
  }

Z
zhong_ning 已提交
218 219 220 221 222 223 224 225 226 227
  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 已提交
228
  ohos_prebuilt_etc("ohos.para") {
S
sun_fan 已提交
229
    source = "//base/startup/init_lite/services/etc/param/ohos.para"
Z
zhong_ning 已提交
230
    part_name = "init"
S
sun_fan 已提交
231 232 233 234 235 236 237
    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 已提交
238 239
  }

Z
zhong_ning 已提交
240
  group("init_etc") {
Z
zhong_ning 已提交
241
    deps = [
Z
zhong_ning 已提交
242
      ":group",
Z
zhong_ning 已提交
243
      ":init.cfg",
Z
zhong_ning 已提交
244 245
      ":init.usb.cfg",
      ":init.usb.configfs.cfg",
Z
zhong_ning 已提交
246
      ":ohos.para",
S
sun_fan 已提交
247
      ":ohos.para.dac",
Z
zhong_ning 已提交
248
      ":passwd",
Z
zhong_ning 已提交
249
    ]
M
mamingshuai 已提交
250 251
  }
}