BUILD.gn 10.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
      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
      if (enable_ohos_startup_init_feature_begetctl_liteos) {
114 115 116 117 118 119 120 121 122 123 124
        PRODUCT_HAL_SYSPARAM_PATH =
            rebase_path("//${ohos_product_adapter_dir}/utils/sys_param")
        cmd = "if [ -f ${PRODUCT_HAL_SYSPARAM_PATH}/BUILD.gn ]; then echo true; else echo false; fi"
        PRODUCT_HAL_SYSPARAM_EXISTS =
            exec_script("//build/lite/run_shell_cmd.py", [ cmd ], "value")
        if (PRODUCT_HAL_SYSPARAM_EXISTS) {
          deps += [ "$ohos_product_adapter_dir/utils/sys_param:hal_sysparam" ]
        }
        deps += [
          "//base/startup/init/interfaces/hals/utils/sys_param:hal_sys_param",
        ]
M
Mupceet 已提交
125 126 127 128 129 130
        defines += [ "LITEOS_SUPPORT" ]
        sources += syspara_sources
      } else {
        sources += [ "syscap/init_syscap.c" ]
      }

M
Mupceet 已提交
131 132 133 134
      if (enable_ohos_startup_init_lite_use_thirdparty_mbedtls) {
        deps += [ "//third_party/mbedtls:mbedtls" ]
        defines += [ "USE_MBEDTLS" ]
      }
M
Mupceet 已提交
135 136
      if (enable_ohos_startup_init_feature_begetctl_liteos) {
        deps += [
137 138 139
          "//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 已提交
140 141
        ]
      }
M
Mupceet 已提交
142
    }
X
xionglei6 已提交
143
  }
144

M
Mupceet 已提交
145 146
  lite_component("parameter") {
    features = [ ":libbegetutil" ]
X
xionglei6 已提交
147
  }
148

M
Mupceet 已提交
149 150 151 152 153
  ndk_lib("parameter_notes") {
    if (ohos_kernel_type != "liteos_m") {
      lib_extension = ".so"
    }
    deps = [ ":libbegetutil" ]
M
init  
Mupceet 已提交
154
    head_files = [ "//base/startup/init/interfaces/innerkits/include/syspara" ]
M
Mupceet 已提交
155
  }
M
Mupceet 已提交
156 157 158

  group("libbeget_proxy") {
  }
M
Mupceet 已提交
159 160
} else {
  import("//build/ohos.gni")
161 162 163 164 165
  modulemgr_sources = [
    "hookmgr/hookmgr.c",
    "modulemgr/modulemgr.c",
  ]

X
xionglei6 已提交
166 167
  ohos_shared_library("libbegetutil") {
    sources = [
L
laiguizhong 已提交
168
      "fd_holder/fd_holder.c",
X
xionglei6 已提交
169 170 171
      "reboot/init_reboot_innerkits.c",
      "service_control/service_control.c",
    ]
M
Mupceet 已提交
172 173
    sources += syspara_sources
    sources += [ "syspara/param_wrapper.cpp" ]
174
    sources += modulemgr_sources
X
xionglei6 已提交
175

M
Mupceet 已提交
176 177 178
    defines = [
      "INIT_AGENT",
      "_GNU_SOURCE",
M
Mupceet 已提交
179
      "USE_MBEDTLS",
M
Mupceet 已提交
180
    ]
181 182 183 184
    if (target_cpu == "arm64") {
      defines += [ "SUPPORT_64BIT" ]
    }

M
Mupceet 已提交
185
    include_dirs = include_common
X
xionglei6 已提交
186
    deps = [
187
      "//base/customization/config_policy/frameworks/config_policy:configpolicy_util_for_init_static",
M
init  
Mupceet 已提交
188 189 190 191 192 193 194 195 196 197
      "//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 已提交
198
      "//third_party/bounds_checking_function:libsec_shared",
L
laiguizhong 已提交
199
      "//third_party/cJSON:cjson",
M
Mupceet 已提交
200
      "//third_party/mbedtls:mbedtls_shared",
X
xionglei6 已提交
201
    ]
A
an_xinwei 已提交
202 203 204 205 206
    if (use_musl == false) {
      deps += [ "//base/startup/init/services/param/base:parameterbase" ]
    } else {
      deps += [ "//base/startup/init/services/param/base:parameterbase_ext" ]
    }
T
taiyipei 已提交
207
    external_deps = [
H
hongtao 已提交
208
      "c_utils:utils",
T
taiyipei 已提交
209 210
      "hilog_native:libhilog_base",
    ]
X
xionglei6 已提交
211 212
    public_configs = [ ":exported_header_files" ]
    part_name = "init"
213
    subsystem_name = "startup"
X
xionglei6 已提交
214 215 216 217 218
    install_images = [
      "system",
      "updater",
    ]
  }
219

X
xionglei6 已提交
220 221
  # watcher lib must separate compilation avoid interdependence.
  ohos_shared_library("libbeget_proxy") {
M
Mupceet 已提交
222 223 224
    defines = [
      "INIT_AGENT",
      "_GNU_SOURCE",
M
Mupceet 已提交
225
      "USE_MBEDTLS",
M
Mupceet 已提交
226
    ]
X
xionglei6 已提交
227
    sources = [
M
init  
Mupceet 已提交
228
      "//base/startup/init/device_info/device_info.cpp",
X
xionglei6 已提交
229 230
      "service_watcher/service_watcher.c",
    ]
X
xionglei6 已提交
231

M
Mupceet 已提交
232
    include_dirs = include_common
X
xionglei6 已提交
233
    deps = [
M
Mupceet 已提交
234
      ":libbegetutil",
X
xionglei6 已提交
235 236 237
      "//third_party/bounds_checking_function:libsec_shared",
    ]

M
Mupceet 已提交
238
    if (enable_ohos_startup_init_feature_watcher) {
M
Mupceet 已提交
239
      sources += [
M
init  
Mupceet 已提交
240 241 242 243
        "//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 已提交
244 245
      ]
      include_dirs += [
M
init  
Mupceet 已提交
246 247
        "//base/startup/init/services/param/watcher/include",
        "//base/startup/init/services/log",
M
Mupceet 已提交
248 249 250 251 252
      ]
    } else {
      defines += [ "NO_PARAM_WATCHER" ]
    }

M
Mupceet 已提交
253
    if (enable_ohos_startup_init_feature_deviceinfo) {
M
Mupceet 已提交
254
      sources += [
M
init  
Mupceet 已提交
255 256 257
        "//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 已提交
258 259 260
      ]
      defines += [ "PARAM_FEATURE_DEVICEINFO" ]
    } else {
M
init  
Mupceet 已提交
261 262
      sources +=
          [ "//base/startup/init/interfaces/innerkits/syspara/param_comm.c" ]
M
Mupceet 已提交
263 264
    }

X
xionglei6 已提交
265
    external_deps = [
H
hongtao 已提交
266
      "c_utils:utils",
X
xionglei6 已提交
267
      "hilog_native:libhilog_base",
C
cheng_jinsong 已提交
268
      "ipc:ipc_single",
H
huangxiaolinabc123 已提交
269
      "samgr:samgr_proxy",
X
xionglei6 已提交
270
    ]
M
Mupceet 已提交
271
    public_configs = [ ":exported_header_files" ]
X
xionglei6 已提交
272
    part_name = "init"
273
    subsystem_name = "startup"
X
xionglei6 已提交
274 275 276
    install_images = [ "system" ]
  }

277
  ohos_static_library("libbegetutil_static") {
M
Mupceet 已提交
278
    sources = syspara_sources
279 280 281 282 283
    sources += [ "syspara/param_wrapper.cpp" ]

    defines = [
      "INIT_AGENT",
      "_GNU_SOURCE",
M
Mupceet 已提交
284
      "USE_MBEDTLS",
285 286 287 288 289
    ]
    if (target_cpu == "arm64") {
      defines += [ "SUPPORT_64BIT" ]
    }

M
Mupceet 已提交
290
    include_dirs = include_common
291
    deps = [
M
init  
Mupceet 已提交
292 293 294 295
      "//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",
296
      "//third_party/bounds_checking_function:libsec_shared",
M
Mupceet 已提交
297
      "//third_party/mbedtls:mbedtls_shared",
298
    ]
A
an_xinwei 已提交
299 300 301 302 303
    if (use_musl == false) {
      deps += [ "//base/startup/init/services/param/base:parameterbase" ]
    } else {
      deps += [ "//base/startup/init/services/param/base:parameterbase_ext" ]
    }
304
    external_deps = [
H
hongtao 已提交
305
      "c_utils:utils",
306 307 308
      "hilog_native:libhilog_base",
    ]
    part_name = "init"
309
    subsystem_name = "startup"
310
  }
311
}
M
Mupceet 已提交
312 313 314

group("innergroup") {
  deps = [ ":libbegetutil" ]
X
<feat>  
xiacong 已提交
315 316 317
  if (build_seccomp) {
    deps += [ "seccomp:seccomp" ]
  }
M
Mupceet 已提交
318 319 320 321 322 323 324 325 326
  if (!defined(ohos_lite)) {
    deps += [
      ":libbeget_proxy",
      "file:libfile",
      "init_module_engine:modulegroup",
      "socket:libsocket",
    ]
  }
}