BUILD.gn 6.0 KB
Newer Older
M
mamingshuai 已提交
1 2 3 4 5 6 7 8 9 10 11 12
# Copyright (c) 2020 Huawei Device Co., Ltd.
# 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.
Z
zhong_ning 已提交
13 14
if (defined(ohos_lite)) {
  # feature: init
15 16
  executable("init_lite") {
    output_name = "init"
Z
zhong_ning 已提交
17 18
    defines = [
      "_GNU_SOURCE",  #syscall function need this macro definition
Z
zhong_ning 已提交
19
      "OHOS_LITE",
Z
zhong_ning 已提交
20 21
    ]
    sources = [
Z
zhong_ning 已提交
22
      "log/init_log.c",
Z
zhong_ning 已提交
23
      "src/init_adapter.c",
Z
zhong_ning 已提交
24
      "src/init_capability.c",
Z
zhong_ning 已提交
25
      "src/init_cmds.c",
Z
zhong_ning 已提交
26
      "src/init_import.c",
Z
zhong_ning 已提交
27 28
      "src/init_jobs.c",
      "src/init_read_cfg.c",
Z
zhong_ning 已提交
29
      "src/init_reboot.c",
Z
zhong_ning 已提交
30 31
      "src/init_service.c",
      "src/init_service_manager.c",
Z
zhong_ning 已提交
32
      "src/init_service_socket.c",
Z
zhong_ning 已提交
33
      "src/init_signal_handler.c",
Z
zhong_ning 已提交
34
      "src/init_utils.c",
Z
zhong_ning 已提交
35 36
      "src/main.c",
    ]
M
mamingshuai 已提交
37

Z
zhong_ning 已提交
38
    include_dirs = [
Z
zhong_ning 已提交
39
      "//base/startup/init_lite/services/include",
Z
zhong_ning 已提交
40 41
      "//base/startup/init_lite/services/param/include",
      "//base/startup/init_lite/services/log",
Z
zhong_ning 已提交
42 43 44
      "//third_party/cJSON",
      "//third_party/bounds_checking_function/include",
      "//base/startup/syspara_lite/interfaces/kits",
Z
zhong_ning 已提交
45
      "//base/hiviewdfx/hilog_lite/interfaces/native/kits",
Z
zhong_ning 已提交
46
    ]
M
mamingshuai 已提交
47

Z
zhong_ning 已提交
48
    cflags = [ "-Wall" ]
M
mamingshuai 已提交
49

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

Z
zhong_ning 已提交
79 80
  if (ohos_build_type == "debug") {
    group("unittest") {
Z
zhong_ning 已提交
81 82
      deps =
          [ "//base/startup/init_lite/services/test/unittest/common:unittest" ]
Z
zhong_ning 已提交
83 84 85 86
    }
  }
} else {
  import("//build/ohos.gni")
M
mamingshuai 已提交
87

Z
zhong_ning 已提交
88
  ohos_executable("init") {
89 90 91
    sources = [
      "src/device.c",
      "src/init_adapter.c",
Z
zhong_ning 已提交
92
      "src/init_capability.c",
93
      "src/init_cmds.c",
Z
zhong_ning 已提交
94
      "src/init_import.c",
95 96
      "src/init_jobs.c",
      "src/init_read_cfg.c",
Z
zhong_ning 已提交
97
      "src/init_reboot.c",
98 99
      "src/init_service.c",
      "src/init_service_manager.c",
Z
zhong_ning 已提交
100
      "src/init_service_socket.c",
101
      "src/init_signal_handler.c",
Z
zhong_ning 已提交
102
      "src/init_utils.c",
103 104 105
      "src/main.c",
    ]
    include_dirs = [
Z
zhong_ning 已提交
106
      "//base/startup/init_lite/services/include/param",
Z
zhong_ning 已提交
107
      "//base/startup/init_lite/services/include",
Z
zhong_ning 已提交
108
      "//base/startup/init_lite/services/log",
109 110
      "//third_party/cJSON",
      "//third_party/bounds_checking_function/include",
Z
zhong_ning 已提交
111
      "//third_party/libuv/include",
112 113
    ]
    deps = [
Z
zhong_ning 已提交
114
      "//base/startup/init_lite/services/log:init_log",
S
sun_fan 已提交
115
      "//base/startup/init_lite/services/param:param_service",
116 117 118
      "//third_party/bounds_checking_function:libsec_static",
      "//third_party/cJSON:cjson_static",
    ]
Z
zhong_ning 已提交
119 120 121
    if (use_musl) {
      deps += [
        "//third_party/mksh:sh",
Z
zhong_ning 已提交
122
        "//third_party/toybox:toybox",
Z
zhong_ning 已提交
123 124
      ]
    }
Z
zhong_ning 已提交
125 126 127 128
    install_images = [
      "system",
      "updater",
    ]
129
    install_enable = true
Z
zhong_ning 已提交
130
    part_name = "init"
M
mamingshuai 已提交
131 132
  }

Z
zhong_ning 已提交
133 134 135 136
  group("startup_init") {
    deps = [
      ":init",
      ":init_etc",
S
sun_fan 已提交
137
      "//base/startup/init_lite/interfaces/innerkits/dynamic_service:dynamic_service",
Z
zhong_ning 已提交
138
      "//base/startup/init_lite/interfaces/innerkits/socket:libsocket",
Z
zhong_ning 已提交
139 140
      "//base/startup/init_lite/services/cmds/reboot:reboot",
      "//base/startup/init_lite/services/cmds/service_control:service_control",
S
sun_fan 已提交
141 142 143 144 145 146 147
      "//base/startup/init_lite/services/param:param",
      "//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 已提交
148 149 150 151
    ]
  }

  # init etc files group
Z
zhong_ning 已提交
152
  ohos_prebuilt_etc("init.cfg") {
S
sun_fan 已提交
153
    source = "//base/startup/init_lite/services/etc/init.cfg"
Z
zhong_ning 已提交
154 155 156
    part_name = "init"
  }

Z
zhong_ning 已提交
157 158
  ohos_prebuilt_etc("passwd") {
    source = "//base/startup/init_lite/services/etc/passwd"
Z
zhong_ning 已提交
159 160 161 162
    install_images = [
      "system",
      "updater",
    ]
Z
zhong_ning 已提交
163 164 165
    part_name = "init"
  }

S
sun_fan 已提交
166 167
  ohos_prebuilt_etc("group") {
    source = "//base/startup/init_lite/services/etc/group"
Z
zhong_ning 已提交
168 169 170 171
    install_images = [
      "system",
      "updater",
    ]
S
sun_fan 已提交
172 173 174
    part_name = "init"
  }

Z
zhong_ning 已提交
175 176 177 178 179 180 181 182 183 184
  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 已提交
185
  ohos_prebuilt_etc("ohos.para") {
S
sun_fan 已提交
186
    source = "//base/startup/init_lite/services/etc/param/ohos.para"
Z
zhong_ning 已提交
187
    part_name = "init"
S
sun_fan 已提交
188 189 190 191 192 193 194
    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 已提交
195 196
  }

Z
zhong_ning 已提交
197
  group("init_etc") {
Z
zhong_ning 已提交
198
    deps = [
Z
zhong_ning 已提交
199
      ":group",
Z
zhong_ning 已提交
200
      ":init.cfg",
Z
zhong_ning 已提交
201 202
      ":init.usb.cfg",
      ":init.usb.configfs.cfg",
Z
zhong_ning 已提交
203
      ":ohos.para",
S
sun_fan 已提交
204
      ":ohos.para.dac",
Z
zhong_ning 已提交
205
      ":passwd",
Z
zhong_ning 已提交
206
    ]
M
mamingshuai 已提交
207 208
  }
}