BUILD.gn 9.8 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 30 31
    "//base/startup/init/interfaces/innerkits/include",
    "//base/startup/init/interfaces/innerkits/include/syspara",
    "//base/startup/init/interfaces/innerkits/include/fs_manager",
    "//base/startup/init/interfaces/innerkits/include/token",
    "//base/startup/init/interfaces/innerkits/include/sandbox/include",
    "//base/startup/init/services/include",
M
Mupceet 已提交
32 33
  ]
}
34

M
Mupceet 已提交
35 36 37 38
include_common = [
  "./include",
  "//base/hiviewdfx/hilog_lite/interfaces/native/kits",
  "//third_party/bounds_checking_function/include",
M
init  
Mupceet 已提交
39 40 41 42 43 44 45 46
  "//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 已提交
47 48
]

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

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

L
laiguizhong 已提交
112
      sources = []
M
Mupceet 已提交
113 114 115 116 117 118 119 120
      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 已提交
121 122 123 124
      if (enable_ohos_startup_init_lite_use_thirdparty_mbedtls) {
        deps += [ "//third_party/mbedtls:mbedtls" ]
        defines += [ "USE_MBEDTLS" ]
      }
M
Mupceet 已提交
125 126
      if (enable_ohos_startup_init_feature_begetctl_liteos) {
        deps += [
127 128 129
          "//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 已提交
130 131
        ]
      }
M
Mupceet 已提交
132
    }
X
xionglei6 已提交
133
  }
134

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

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

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

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

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

M
Mupceet 已提交
175
    include_dirs = include_common
X
xionglei6 已提交
176
    deps = [
M
init  
Mupceet 已提交
177 178 179 180 181 182 183 184 185 186
      "//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/fs_manager:libfsmanager_static",
      "//base/startup/init/interfaces/innerkits/sandbox:sandbox",
      "//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 已提交
187
      "//third_party/bounds_checking_function:libsec_shared",
L
laiguizhong 已提交
188
      "//third_party/cJSON:cjson",
M
Mupceet 已提交
189
      "//third_party/mbedtls:mbedtls_shared",
X
xionglei6 已提交
190
    ]
A
an_xinwei 已提交
191 192 193 194 195
    if (use_musl == false) {
      deps += [ "//base/startup/init/services/param/base:parameterbase" ]
    } else {
      deps += [ "//base/startup/init/services/param/base:parameterbase_ext" ]
    }
T
taiyipei 已提交
196
    external_deps = [
H
hongtao 已提交
197
      "c_utils:utils",
T
taiyipei 已提交
198 199
      "hilog_native:libhilog_base",
    ]
X
xionglei6 已提交
200 201 202 203 204 205 206
    public_configs = [ ":exported_header_files" ]
    part_name = "init"
    install_images = [
      "system",
      "updater",
    ]
  }
207

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

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

M
Mupceet 已提交
226
    if (enable_ohos_startup_init_feature_watcher) {
M
Mupceet 已提交
227
      sources += [
M
init  
Mupceet 已提交
228 229 230 231
        "//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 已提交
232 233
      ]
      include_dirs += [
M
init  
Mupceet 已提交
234 235
        "//base/startup/init/services/param/watcher/include",
        "//base/startup/init/services/log",
M
Mupceet 已提交
236 237 238 239 240
      ]
    } else {
      defines += [ "NO_PARAM_WATCHER" ]
    }

M
Mupceet 已提交
241
    if (enable_ohos_startup_init_feature_deviceinfo) {
M
Mupceet 已提交
242
      sources += [
M
init  
Mupceet 已提交
243 244 245
        "//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 已提交
246 247 248
      ]
      defines += [ "PARAM_FEATURE_DEVICEINFO" ]
    } else {
M
init  
Mupceet 已提交
249 250
      sources +=
          [ "//base/startup/init/interfaces/innerkits/syspara/param_comm.c" ]
M
Mupceet 已提交
251 252
    }

X
xionglei6 已提交
253
    external_deps = [
H
hongtao 已提交
254
      "c_utils:utils",
X
xionglei6 已提交
255 256
      "hilog_native:libhilog_base",
      "ipc:ipc_core",
H
huangxiaolinabc123 已提交
257
      "samgr:samgr_proxy",
X
xionglei6 已提交
258
    ]
M
Mupceet 已提交
259
    public_configs = [ ":exported_header_files" ]
X
xionglei6 已提交
260 261 262 263
    part_name = "init"
    install_images = [ "system" ]
  }

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

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

M
Mupceet 已提交
277
    include_dirs = include_common
278
    deps = [
M
init  
Mupceet 已提交
279 280 281 282
      "//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",
283
      "//third_party/bounds_checking_function:libsec_shared",
M
Mupceet 已提交
284
      "//third_party/mbedtls:mbedtls_shared",
285
    ]
A
an_xinwei 已提交
286 287 288 289 290
    if (use_musl == false) {
      deps += [ "//base/startup/init/services/param/base:parameterbase" ]
    } else {
      deps += [ "//base/startup/init/services/param/base:parameterbase_ext" ]
    }
291
    external_deps = [
H
hongtao 已提交
292
      "c_utils:utils",
293 294 295 296
      "hilog_native:libhilog_base",
    ]
    part_name = "init"
  }
297
}
M
Mupceet 已提交
298 299 300

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