BUILD.gn 9.6 KB
Newer Older
M
Mupceet 已提交
1
# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
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.
M
init  
Mupceet 已提交
13
import("//base/startup/init/begetd.gni")
M
Mupceet 已提交
14
if (!defined(ohos_lite) || enable_ohos_startup_init_feature_begetctl_liteos) {
M
Mupceet 已提交
15 16 17 18 19 20 21
  syspara_sources = [
    "syscap/init_syscap.c",
    "syspara/param_comm.c",
    "syspara/parameter.c",
    "syspara/sysversion.c",
  ]
}
M
Mupceet 已提交
22 23 24 25

config("exported_header_files") {
  visibility = [ ":*" ]
  include_dirs = [
M
init  
Mupceet 已提交
26 27 28 29
    "//base/startup/init/interfaces/innerkits/include",
    "//base/startup/init/interfaces/innerkits/include/syspara",
    "//base/startup/init/interfaces/innerkits/include/token",
    "//base/startup/init/services/include",
M
Mupceet 已提交
30 31
  ]
}
32

M
Mupceet 已提交
33 34 35 36
include_common = [
  "./include",
  "//base/hiviewdfx/hilog_lite/interfaces/native/kits",
  "//third_party/bounds_checking_function/include",
M
init  
Mupceet 已提交
37 38 39 40 41 42 43 44
  "//base/startup/init/services/include",
  "//base/startup/init/services/include/param",
  "//base/startup/init/interfaces/innerkits/fd_holder",
  "//base/startup/init/services/param/include",
  "//base/startup/init/interfaces/innerkits/include",
  "//base/startup/init/interfaces/innerkits/include/syspara",
  "//base/startup/init/interfaces/hals",
  "//base/startup/init/interfaces/innerkits/syspara",
M
Mupceet 已提交
45 46
]

X
xionglei6 已提交
47
if (defined(ohos_lite)) {
M
Mupceet 已提交
48 49 50 51 52
  import("//build/lite/config/component/lite_component.gni")
  import("//build/lite/ndk/ndk.gni")

  if (ohos_kernel_type == "liteos_a" || ohos_kernel_type == "linux") {
    shared_library("libbegetutil") {
M
Mupceet 已提交
53
      cflags = [ "-fPIC" ]
M
Mupceet 已提交
54 55 56
      defines = [
        "_GNU_SOURCE",
        "OHOS_LITE",
M
Mupceet 已提交
57
        "USE_MBEDTLS",
M
Mupceet 已提交
58
      ]
M
Mupceet 已提交
59
      sources = []
M
Mupceet 已提交
60
      include_dirs = include_common
M
Mupceet 已提交
61 62 63
      public_configs = [ ":exported_header_files" ]
      deps = [
        "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared",
M
Mupceet 已提交
64
        "//base/startup/init/services/modules/init_hook:inithook",
M
Mupceet 已提交
65 66 67 68
        "//third_party/bounds_checking_function:libsec_shared",
        "//third_party/mbedtls:mbedtls_shared",
      ]
      deps += [
M
init  
Mupceet 已提交
69 70
        "//base/startup/init/services/log:init_log",
        "//base/startup/init/services/utils:libinit_utils",
M
Mupceet 已提交
71
      ]
M
Mupceet 已提交
72 73 74
      if (enable_ohos_startup_init_feature_begetctl_liteos) {
        sources += syspara_sources
        defines += [ "LITEOS_SUPPORT" ]
M
Mupceet 已提交
75
        deps += [ "$ohos_product_adapter_dir/utils/sys_param:hal_sysparam" ]
M
Mupceet 已提交
76 77 78
      } else {
        sources += [ "syscap/init_syscap.c" ]
      }
M
Mupceet 已提交
79 80
      if (ohos_kernel_type == "liteos_a") {
        defines += [ "__LITEOS_A__" ]
M
init  
Mupceet 已提交
81 82
        deps +=
            [ "//base/startup/init/services/param/liteos:param_client_lite" ]
M
Mupceet 已提交
83
      } else if (ohos_kernel_type == "linux") {
M
Mupceet 已提交
84
        sources += [ "socket/init_socket.c" ]
M
Mupceet 已提交
85
        defines += [ "__LINUX__" ]
M
Mupceet 已提交
86
        deps += [
M
init  
Mupceet 已提交
87 88 89
          "//base/startup/init/services/loopevent:loopevent",
          "//base/startup/init/services/param/base:parameterbase",
          "//base/startup/init/services/param/linux:param_client",
M
Mupceet 已提交
90
        ]
M
Mupceet 已提交
91 92 93 94 95 96 97 98 99
      }
    }
  }
  if (ohos_kernel_type == "liteos_m") {
    static_library("libbegetutil") {
      public_configs = [ ":exported_header_files" ]
      defines = [
        "_GNU_SOURCE",
        "OHOS_LITE",
M
Mupceet 已提交
100
        "__LITEOS_M__",
M
Mupceet 已提交
101
      ]
M
Mupceet 已提交
102

M
Mupceet 已提交
103
      include_dirs = include_common
M
Mupceet 已提交
104 105
      deps = [
        "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_static",
M
Mupceet 已提交
106
        "//base/startup/init/services/modules/init_hook:inithook",
M
Mupceet 已提交
107 108 109
        "//third_party/bounds_checking_function:libsec_static",
      ]

L
laiguizhong 已提交
110
      sources = []
M
Mupceet 已提交
111 112 113 114 115 116 117 118
      if (enable_ohos_startup_init_feature_begetctl_liteos) {
        deps += [ "$ohos_product_adapter_dir/utils/sys_param:hal_sysparam" ]
        defines += [ "LITEOS_SUPPORT" ]
        sources += syspara_sources
      } else {
        sources += [ "syscap/init_syscap.c" ]
      }

M
Mupceet 已提交
119 120 121 122
      if (enable_ohos_startup_init_lite_use_thirdparty_mbedtls) {
        deps += [ "//third_party/mbedtls:mbedtls" ]
        defines += [ "USE_MBEDTLS" ]
      }
M
Mupceet 已提交
123 124
      if (enable_ohos_startup_init_feature_begetctl_liteos) {
        deps += [
125 126 127
          "//base/startup/init/services/log:init_log",
          "//base/startup/init/services/param/liteos:param_client_lite",
          "//base/startup/init/services/utils:libinit_utils",
M
Mupceet 已提交
128 129
        ]
      }
M
Mupceet 已提交
130
    }
X
xionglei6 已提交
131
  }
132

M
Mupceet 已提交
133 134
  lite_component("parameter") {
    features = [ ":libbegetutil" ]
X
xionglei6 已提交
135
  }
136

M
Mupceet 已提交
137 138 139 140 141
  ndk_lib("parameter_notes") {
    if (ohos_kernel_type != "liteos_m") {
      lib_extension = ".so"
    }
    deps = [ ":libbegetutil" ]
M
init  
Mupceet 已提交
142
    head_files = [ "//base/startup/init/interfaces/innerkits/include/syspara" ]
M
Mupceet 已提交
143
  }
M
Mupceet 已提交
144 145 146

  group("libbeget_proxy") {
  }
M
Mupceet 已提交
147 148
} else {
  import("//build/ohos.gni")
149 150 151 152 153
  modulemgr_sources = [
    "hookmgr/hookmgr.c",
    "modulemgr/modulemgr.c",
  ]

X
xionglei6 已提交
154 155
  ohos_shared_library("libbegetutil") {
    sources = [
L
laiguizhong 已提交
156
      "fd_holder/fd_holder.c",
X
xionglei6 已提交
157 158 159
      "reboot/init_reboot_innerkits.c",
      "service_control/service_control.c",
    ]
M
Mupceet 已提交
160 161
    sources += syspara_sources
    sources += [ "syspara/param_wrapper.cpp" ]
162
    sources += modulemgr_sources
X
xionglei6 已提交
163

M
Mupceet 已提交
164 165 166
    defines = [
      "INIT_AGENT",
      "_GNU_SOURCE",
M
Mupceet 已提交
167
      "USE_MBEDTLS",
M
Mupceet 已提交
168
    ]
169 170 171 172
    if (target_cpu == "arm64") {
      defines += [ "SUPPORT_64BIT" ]
    }

M
Mupceet 已提交
173
    include_dirs = include_common
X
xionglei6 已提交
174
    deps = [
175
      "//base/customization/config_policy/frameworks/config_policy:configpolicy_util_for_init_static",
M
init  
Mupceet 已提交
176 177 178 179 180 181 182 183
      "//base/startup/init/interfaces/innerkits/control_fd:libcontrolfd",
      "//base/startup/init/interfaces/innerkits/fd_holder:fdholder",
      "//base/startup/init/interfaces/innerkits/file:libfile",
      "//base/startup/init/interfaces/innerkits/socket:libsocket",
      "//base/startup/init/services/log:agent_log",
      "//base/startup/init/services/loopevent:loopevent",
      "//base/startup/init/services/param/linux:param_client",
      "//base/startup/init/services/utils:libinit_utils",
X
xionglei6 已提交
184
      "//third_party/bounds_checking_function:libsec_shared",
M
Mupceet 已提交
185
      "//third_party/mbedtls:mbedtls_shared",
X
xionglei6 已提交
186
    ]
A
an_xinwei 已提交
187 188 189 190 191
    if (use_musl == false) {
      deps += [ "//base/startup/init/services/param/base:parameterbase" ]
    } else {
      deps += [ "//base/startup/init/services/param/base:parameterbase_ext" ]
    }
T
taiyipei 已提交
192
    external_deps = [
H
hongtao 已提交
193
      "c_utils:utils",
T
taiyipei 已提交
194 195
      "hilog_native:libhilog_base",
    ]
X
xionglei6 已提交
196 197
    public_configs = [ ":exported_header_files" ]
    part_name = "init"
198
    subsystem_name = "startup"
X
xionglei6 已提交
199 200 201 202 203
    install_images = [
      "system",
      "updater",
    ]
  }
204

X
xionglei6 已提交
205 206
  # watcher lib must separate compilation avoid interdependence.
  ohos_shared_library("libbeget_proxy") {
M
Mupceet 已提交
207 208 209
    defines = [
      "INIT_AGENT",
      "_GNU_SOURCE",
M
Mupceet 已提交
210
      "USE_MBEDTLS",
M
Mupceet 已提交
211
    ]
X
xionglei6 已提交
212
    sources = [
M
init  
Mupceet 已提交
213
      "//base/startup/init/device_info/device_info.cpp",
X
xionglei6 已提交
214 215
      "service_watcher/service_watcher.c",
    ]
X
xionglei6 已提交
216

M
Mupceet 已提交
217
    include_dirs = include_common
X
xionglei6 已提交
218
    deps = [
M
Mupceet 已提交
219
      ":libbegetutil",
X
xionglei6 已提交
220 221 222
      "//third_party/bounds_checking_function:libsec_shared",
    ]

M
Mupceet 已提交
223
    if (enable_ohos_startup_init_feature_watcher) {
M
Mupceet 已提交
224
      sources += [
M
init  
Mupceet 已提交
225 226 227 228
        "//base/startup/init/services/param/watcher/agent/watcher.cpp",
        "//base/startup/init/services/param/watcher/agent/watcher_manager_kits.cpp",
        "//base/startup/init/services/param/watcher/agent/watcher_manager_proxy.cpp",
        "//base/startup/init/services/param/watcher/agent/watcher_stub.cpp",
M
Mupceet 已提交
229 230
      ]
      include_dirs += [
M
init  
Mupceet 已提交
231 232
        "//base/startup/init/services/param/watcher/include",
        "//base/startup/init/services/log",
M
Mupceet 已提交
233 234 235 236 237
      ]
    } else {
      defines += [ "NO_PARAM_WATCHER" ]
    }

M
Mupceet 已提交
238
    if (enable_ohos_startup_init_feature_deviceinfo) {
M
Mupceet 已提交
239
      sources += [
M
init  
Mupceet 已提交
240 241 242
        "//base/startup/init/device_info/device_info_kits.cpp",
        "//base/startup/init/device_info/device_info_load.cpp",
        "//base/startup/init/device_info/device_info_proxy.cpp",
M
Mupceet 已提交
243 244 245
      ]
      defines += [ "PARAM_FEATURE_DEVICEINFO" ]
    } else {
M
init  
Mupceet 已提交
246 247
      sources +=
          [ "//base/startup/init/interfaces/innerkits/syspara/param_comm.c" ]
M
Mupceet 已提交
248 249
    }

X
xionglei6 已提交
250
    external_deps = [
H
hongtao 已提交
251
      "c_utils:utils",
X
xionglei6 已提交
252
      "hilog_native:libhilog_base",
C
cheng_jinsong 已提交
253
      "ipc:ipc_single",
H
huangxiaolinabc123 已提交
254
      "samgr:samgr_proxy",
X
xionglei6 已提交
255
    ]
M
Mupceet 已提交
256
    public_configs = [ ":exported_header_files" ]
X
xionglei6 已提交
257
    part_name = "init"
258
    subsystem_name = "startup"
X
xionglei6 已提交
259 260 261
    install_images = [ "system" ]
  }

262
  ohos_static_library("libbegetutil_static") {
M
Mupceet 已提交
263
    sources = syspara_sources
264 265 266 267 268
    sources += [ "syspara/param_wrapper.cpp" ]

    defines = [
      "INIT_AGENT",
      "_GNU_SOURCE",
M
Mupceet 已提交
269
      "USE_MBEDTLS",
270 271 272 273 274
    ]
    if (target_cpu == "arm64") {
      defines += [ "SUPPORT_64BIT" ]
    }

M
Mupceet 已提交
275
    include_dirs = include_common
276
    deps = [
M
init  
Mupceet 已提交
277 278 279 280
      "//base/startup/init/services/log:agent_log",
      "//base/startup/init/services/loopevent:loopevent",
      "//base/startup/init/services/param/linux:param_client",
      "//base/startup/init/services/utils:libinit_utils",
281
      "//third_party/bounds_checking_function:libsec_shared",
M
Mupceet 已提交
282
      "//third_party/mbedtls:mbedtls_shared",
283
    ]
A
an_xinwei 已提交
284 285 286 287 288
    if (use_musl == false) {
      deps += [ "//base/startup/init/services/param/base:parameterbase" ]
    } else {
      deps += [ "//base/startup/init/services/param/base:parameterbase_ext" ]
    }
289
    external_deps = [
H
hongtao 已提交
290
      "c_utils:utils",
291 292 293
      "hilog_native:libhilog_base",
    ]
    part_name = "init"
294
    subsystem_name = "startup"
295
  }
296
}
M
Mupceet 已提交
297 298 299

group("innergroup") {
  deps = [ ":libbegetutil" ]
X
<feat>  
xiacong 已提交
300 301 302
  if (build_seccomp) {
    deps += [ "seccomp:seccomp" ]
  }
M
Mupceet 已提交
303 304 305 306 307 308 309 310 311
  if (!defined(ohos_lite)) {
    deps += [
      ":libbeget_proxy",
      "file:libfile",
      "init_module_engine:modulegroup",
      "socket:libsocket",
    ]
  }
}