BUILD.gn 9.4 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 66 67 68 69
      public_configs = [ ":exported_header_files" ]
      deps = [
        "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared",
        "//third_party/bounds_checking_function:libsec_shared",
        "//third_party/mbedtls:mbedtls_shared",
      ]
      deps += [
M
init  
Mupceet 已提交
70 71
        "//base/startup/init/services/log:init_log",
        "//base/startup/init/services/utils:libinit_utils",
M
Mupceet 已提交
72
      ]
M
Mupceet 已提交
73 74 75
      if (enable_ohos_startup_init_feature_begetctl_liteos) {
        sources += syspara_sources
        defines += [ "LITEOS_SUPPORT" ]
M
Mupceet 已提交
76
        deps += [ "$ohos_product_adapter_dir/utils/sys_param:hal_sysparam" ]
M
Mupceet 已提交
77 78 79
      } else {
        sources += [ "syscap/init_syscap.c" ]
      }
M
Mupceet 已提交
80 81
      if (ohos_kernel_type == "liteos_a") {
        defines += [ "__LITEOS_A__" ]
M
init  
Mupceet 已提交
82 83
        deps +=
            [ "//base/startup/init/services/param/liteos:param_client_lite" ]
M
Mupceet 已提交
84
      } else if (ohos_kernel_type == "linux") {
M
Mupceet 已提交
85
        sources += [ "socket/init_socket.c" ]
M
Mupceet 已提交
86
        defines += [ "__LINUX__" ]
M
Mupceet 已提交
87
        deps += [
M
init  
Mupceet 已提交
88 89 90
          "//base/startup/init/services/loopevent:loopevent",
          "//base/startup/init/services/param/base:parameterbase",
          "//base/startup/init/services/param/linux:param_client",
M
Mupceet 已提交
91
        ]
M
Mupceet 已提交
92 93 94 95 96 97 98 99 100
      }
    }
  }
  if (ohos_kernel_type == "liteos_m") {
    static_library("libbegetutil") {
      public_configs = [ ":exported_header_files" ]
      defines = [
        "_GNU_SOURCE",
        "OHOS_LITE",
M
Mupceet 已提交
101
        "__LITEOS_M__",
M
Mupceet 已提交
102
      ]
M
Mupceet 已提交
103

M
Mupceet 已提交
104
      include_dirs = include_common
M
Mupceet 已提交
105 106 107 108 109
      deps = [
        "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_static",
        "//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 = [
M
init  
Mupceet 已提交
175 176 177 178 179 180 181 182 183 184 185
      "//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/base:parameterbase",
      "//base/startup/init/services/param/linux:param_client",
      "//base/startup/init/services/utils:libinit_utils",
X
xionglei6 已提交
186
      "//third_party/bounds_checking_function:libsec_shared",
L
laiguizhong 已提交
187
      "//third_party/cJSON:cjson",
M
Mupceet 已提交
188
      "//third_party/mbedtls:mbedtls_shared",
X
xionglei6 已提交
189
    ]
T
taiyipei 已提交
190
    external_deps = [
H
hongtao 已提交
191
      "c_utils:utils",
T
taiyipei 已提交
192 193
      "hilog_native:libhilog_base",
    ]
X
xionglei6 已提交
194 195 196 197 198 199 200
    public_configs = [ ":exported_header_files" ]
    part_name = "init"
    install_images = [
      "system",
      "updater",
    ]
  }
201

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

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

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

M
Mupceet 已提交
235
    if (enable_ohos_startup_init_feature_deviceinfo) {
M
Mupceet 已提交
236
      sources += [
M
init  
Mupceet 已提交
237 238 239
        "//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 已提交
240 241 242
      ]
      defines += [ "PARAM_FEATURE_DEVICEINFO" ]
    } else {
M
init  
Mupceet 已提交
243 244
      sources +=
          [ "//base/startup/init/interfaces/innerkits/syspara/param_comm.c" ]
M
Mupceet 已提交
245 246
    }

X
xionglei6 已提交
247
    external_deps = [
H
hongtao 已提交
248
      "c_utils:utils",
X
xionglei6 已提交
249 250 251 252
      "hilog_native:libhilog_base",
      "ipc:ipc_core",
      "samgr_standard:samgr_proxy",
    ]
M
Mupceet 已提交
253
    public_configs = [ ":exported_header_files" ]
X
xionglei6 已提交
254 255 256 257
    part_name = "init"
    install_images = [ "system" ]
  }

258
  ohos_static_library("libbegetutil_static") {
M
Mupceet 已提交
259
    sources = syspara_sources
260 261 262 263 264
    sources += [ "syspara/param_wrapper.cpp" ]

    defines = [
      "INIT_AGENT",
      "_GNU_SOURCE",
M
Mupceet 已提交
265
      "USE_MBEDTLS",
266 267 268 269 270
    ]
    if (target_cpu == "arm64") {
      defines += [ "SUPPORT_64BIT" ]
    }

M
Mupceet 已提交
271
    include_dirs = include_common
272
    deps = [
M
init  
Mupceet 已提交
273 274 275 276 277
      "//base/startup/init/services/log:agent_log",
      "//base/startup/init/services/loopevent:loopevent",
      "//base/startup/init/services/param/base:parameterbase",
      "//base/startup/init/services/param/linux:param_client",
      "//base/startup/init/services/utils:libinit_utils",
278
      "//third_party/bounds_checking_function:libsec_shared",
M
Mupceet 已提交
279
      "//third_party/mbedtls:mbedtls_shared",
280 281
    ]
    external_deps = [
H
hongtao 已提交
282
      "c_utils:utils",
283 284 285 286
      "hilog_native:libhilog_base",
    ]
    part_name = "init"
  }
287
}
M
Mupceet 已提交
288 289 290

group("innergroup") {
  deps = [ ":libbegetutil" ]
X
<feat>  
xiacong 已提交
291 292 293
  if (build_seccomp) {
    deps += [ "seccomp:seccomp" ]
  }
M
Mupceet 已提交
294 295 296 297 298 299 300 301 302
  if (!defined(ohos_lite)) {
    deps += [
      ":libbeget_proxy",
      "file:libfile",
      "init_module_engine:modulegroup",
      "socket:libsocket",
    ]
  }
}