BUILD.gn 9.9 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
# Copyright (c) 2021 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.
M
Mupceet 已提交
13
import("//base/startup/init_lite/begetd.gni")
M
Mupceet 已提交
14 15 16 17 18 19 20 21
if (!defined(ohos_lite) || ohos_kernel_type != "liteos_m") {
  syspara_sources = [
    "syscap/init_syscap.c",
    "syspara/param_comm.c",
    "syspara/parameter.c",
    "syspara/sysversion.c",
  ]
}
M
Mupceet 已提交
22 23 24 25 26 27 28 29 30

config("exported_header_files") {
  visibility = [ ":*" ]
  include_dirs = [
    "//base/startup/init_lite/interfaces/innerkits/include",
    "//base/startup/init_lite/interfaces/innerkits/include/syspara",
    "//base/startup/init_lite/interfaces/innerkits/include/token",
  ]
}
31

X
xionglei6 已提交
32
if (defined(ohos_lite)) {
M
Mupceet 已提交
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
  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") {
      sources = [ "//base/startup/init_lite/services/log/init_log.c" ]
      sources += syspara_sources

      public_configs = [ ":exported_header_files" ]
      cflags = [ "-fPIC" ]
      defines = [
        "_GNU_SOURCE",
        "INIT_LOG_INIT=3",
        "OHOS_LITE",
      ]
      include_dirs = [
        "./include",
        "//base/hiviewdfx/hilog_lite/interfaces/native/kits",
        "//third_party/bounds_checking_function/include",
        "//base/startup/init_lite/services/include",
        "//base/startup/init_lite/services/include/param",
        "//base/startup/init_lite/interfaces/innerkits/fd_holder",
        "//base/startup/init_lite/services/param/include",
        "//base/startup/init_lite/interfaces/innerkits/include",
      ]
      deps = [
        "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared",
        "//base/startup/init_lite/services/utils:libinit_tools",
        "//third_party/bounds_checking_function:libsec_shared",
        "//third_party/mbedtls:mbedtls",
      ]

      defines += [
        "INCREMENTAL_VERSION=\"${ohos_version}\"",
        "BUILD_TYPE=\"${ohos_build_type}\"",
        "BUILD_USER=\"${ohos_build_user}\"",
        "BUILD_TIME=\"${ohos_build_time}\"",
        "BUILD_HOST=\"${ohos_build_host}\"",
        "BUILD_ROOTHASH=\"${ohos_build_roothash}\"",
        "USE_MBEDTLS",
      ]
      deps += [ "//base/startup/init_lite/services/param:param_client" ]
      if (ohos_kernel_type == "liteos_a") {
        defines += [ "__LITEOS_A__" ]
      } else if (ohos_kernel_type == "linux") {
        defines += [ "__LINUX__" ]
        deps += [ "//base/startup/init_lite/services/loopevent:loopevent" ]
      }
    }
  }
  if (ohos_kernel_type == "liteos_m") {
    static_library("libbegetutil") {
      sources = [ "//base/startup/init_lite/services/log/init_log.c" ]
M
Mupceet 已提交
86
      sources += [ "syscap/init_syscap.c" ]
M
Mupceet 已提交
87 88 89 90 91 92
      public_configs = [ ":exported_header_files" ]

      defines = [
        "_GNU_SOURCE",
        "INIT_LOG_INIT=3",
        "OHOS_LITE",
M
Mupceet 已提交
93
        "__LITEOS_M__",
M
Mupceet 已提交
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
      ]
      include_dirs = [
        "./include",
        "//base/hiviewdfx/hilog_lite/interfaces/native/kits",
        "//third_party/bounds_checking_function/include",
        "//base/startup/init_lite/services/include",
        "//base/startup/init_lite/services/include/param",
        "//base/startup/init_lite/interfaces/innerkits/fd_holder",
        "//base/startup/init_lite/services/param/include",
        "//base/startup/init_lite/interfaces/innerkits/include",
      ]
      deps = [
        "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_static",
        "//base/startup/init_lite/services/utils:libinit_tools",
        "//third_party/bounds_checking_function:libsec_static",
      ]

      defines += [
        "INCREMENTAL_VERSION=\"${ohos_version}\"",
        "BUILD_TYPE=\"${ohos_build_type}\"",
        "BUILD_USER=\"${ohos_build_user}\"",
        "BUILD_TIME=\"${ohos_build_time}\"",
        "BUILD_HOST=\"${ohos_build_host}\"",
        "BUILD_ROOTHASH=\"${ohos_build_roothash}\"",
      ]
      if (enable_ohos_startup_init_lite_use_thirdparty_mbedtls) {
        deps += [ "//third_party/mbedtls:mbedtls" ]
        defines += [ "USE_MBEDTLS" ]
      }
      deps += [ "//base/startup/init_lite/services/param:param_client" ]
    }
X
xionglei6 已提交
125
  }
126

M
Mupceet 已提交
127 128
  lite_component("parameter") {
    features = [ ":libbegetutil" ]
X
xionglei6 已提交
129
  }
130

M
Mupceet 已提交
131 132 133 134 135
  ndk_lib("parameter_notes") {
    if (ohos_kernel_type != "liteos_m") {
      lib_extension = ".so"
    }
    deps = [ ":libbegetutil" ]
M
Mupceet 已提交
136 137
    head_files =
        [ "//base/startup/init_lite/interfaces/innerkits/include/syspara" ]
M
Mupceet 已提交
138 139 140 141
  }
} else {
  import("//build/ohos.gni")

X
xionglei6 已提交
142 143 144
  fs_manager_sources = [
    "fs_manager/fstab.c",
    "fs_manager/fstab_mount.c",
145
  ]
X
xionglei6 已提交
146

147 148 149 150 151
  modulemgr_sources = [
    "hookmgr/hookmgr.c",
    "modulemgr/modulemgr.c",
  ]

X
xionglei6 已提交
152 153 154 155 156 157 158 159 160 161 162
  ohos_shared_library("libbegetutil") {
    sources = [
      "//base/startup/init_lite/services/log/init_log.c",
      "fd_holder/fd_holder.c",
      "fd_holder/fd_holder_internal.c",
      "file/init_file.c",
      "reboot/init_reboot_innerkits.c",
      "service_control/service_control.c",
      "socket/init_socket.c",
    ]
    sources += fs_manager_sources
M
Mupceet 已提交
163 164
    sources += syspara_sources
    sources += [ "syspara/param_wrapper.cpp" ]
165
    sources += modulemgr_sources
X
xionglei6 已提交
166

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

X
xionglei6 已提交
177 178 179 180 181
    include_dirs = [
      "./include",
      "//third_party/bounds_checking_function/include",
      "//base/startup/init_lite/services/include",
      "//base/startup/init_lite/services/include/param",
M
Mupceet 已提交
182
      "//base/startup/init_lite/services/param/include",
X
xionglei6 已提交
183
      "//base/startup/init_lite/interfaces/innerkits/fd_holder",
M
Mupceet 已提交
184
      "//base/startup/init_lite/interfaces/innerkits/include",
X
xionglei6 已提交
185 186
    ]
    deps = [
M
Mupceet 已提交
187
      "//base/startup/init_lite/interfaces/innerkits/sandbox:libsandbox",
X
xionglei6 已提交
188 189 190 191 192
      "//base/startup/init_lite/services/loopevent:loopevent",
      "//base/startup/init_lite/services/param:param_client",
      "//base/startup/init_lite/services/utils:libinit_tools",
      "//base/startup/init_lite/services/utils:libinit_utils",
      "//third_party/bounds_checking_function:libsec_shared",
M
Mupceet 已提交
193
      "//third_party/openssl:libcrypto_shared",
X
xionglei6 已提交
194
    ]
T
taiyipei 已提交
195 196 197 198
    external_deps = [
      "hilog_native:libhilog_base",
      "utils_base:utils",
    ]
X
xionglei6 已提交
199 200 201 202 203 204 205
    public_configs = [ ":exported_header_files" ]
    part_name = "init"
    install_images = [
      "system",
      "updater",
    ]
  }
206

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

X
xionglei6 已提交
219 220 221 222
    include_dirs = [
      "./include",
      "//base/startup/init_lite/device_info",
      "//base/startup/init_lite/interfaces/innerkits/include",
M
Mupceet 已提交
223
      "//base/startup/init_lite/interfaces/innerkits/syspara",
X
xionglei6 已提交
224 225
      "//base/startup/init_lite/services/include",
      "//base/startup/init_lite/services/include/param",
M
Mupceet 已提交
226
      "//base/startup/init_lite/services/param/include",
X
xionglei6 已提交
227 228
      "//third_party/bounds_checking_function/include",
    ]
229

X
xionglei6 已提交
230 231 232 233 234
    deps = [
      "//base/startup/init_lite/services/utils:libinit_utils",
      "//third_party/bounds_checking_function:libsec_shared",
    ]

M
Mupceet 已提交
235 236 237 238 239 240 241 242 243 244 245
    if (param_feature_watcher) {
      sources += [
        "//base/startup/init_lite/services/param/watcher/agent/watcher.cpp",
        "//base/startup/init_lite/services/param/watcher/agent/watcher_manager_kits.cpp",
        "//base/startup/init_lite/services/param/watcher/agent/watcher_manager_proxy.cpp",
        "//base/startup/init_lite/services/param/watcher/agent/watcher_stub.cpp",
      ]
      include_dirs += [
        "//base/startup/init_lite/services/param/watcher/include",
        "//base/startup/init_lite/services/log",
      ]
M
Mupceet 已提交
246 247 248 249 250 251
      deps += [
        "//base/startup/init_lite/services/param:param_client",
        "//base/startup/init_lite/services/utils:libinit_tools",
        "//base/startup/init_lite/services/utils:libinit_utils",
        "//third_party/openssl:libcrypto_shared",
      ]
M
Mupceet 已提交
252 253 254 255 256 257 258
    } else {
      defines += [ "NO_PARAM_WATCHER" ]
    }

    if (param_feature_deviceinfo) {
      sources += [
        "//base/startup/init_lite/device_info/device_info_kits.cpp",
M
Mupceet 已提交
259
        "//base/startup/init_lite/device_info/device_info_proxy.cpp",
M
Mupceet 已提交
260 261 262
      ]
      defines += [ "PARAM_FEATURE_DEVICEINFO" ]
    } else {
M
Mupceet 已提交
263 264 265
      sources += [
        "//base/startup/init_lite/interfaces/innerkits/syspara/param_comm.c",
      ]
M
Mupceet 已提交
266 267
      deps += [
        "//base/startup/init_lite/services/loopevent:loopevent",
M
Mupceet 已提交
268
        "//base/startup/init_lite/services/param:param_client",
M
Mupceet 已提交
269 270
        "//base/startup/init_lite/services/utils:libinit_tools",
        "//base/startup/init_lite/services/utils:libinit_utils",
M
Mupceet 已提交
271 272
        "//third_party/openssl:libcrypto_shared",
      ]
M
Mupceet 已提交
273 274
    }

X
xionglei6 已提交
275 276 277 278 279
    external_deps = [
      "hilog_native:libhilog_base",
      "ipc:ipc_core",
      "safwk:system_ability_fwk",
      "samgr_standard:samgr_proxy",
T
taiyipei 已提交
280
      "utils_base:utils",
X
xionglei6 已提交
281
    ]
M
Mupceet 已提交
282
    public_configs = [ ":exported_header_files" ]
X
xionglei6 已提交
283 284 285 286 287 288 289 290 291 292 293 294
    part_name = "init"
    install_images = [ "system" ]
  }

  # For init only
  ohos_static_library("libfsmanager_static") {
    sources = fs_manager_sources
    include_dirs = [
      "//base/startup/init_lite/interfaces/innerkits/include",
      "//third_party/bounds_checking_function/include",
      "//base/startup/init_lite/services/log",
      "//base/startup/init_lite/services/include",
M
Mupceet 已提交
295
      "//base/startup/init_lite/services/param/include",
X
xionglei6 已提交
296
    ]
X
fix log  
xionglei6 已提交
297

X
xionglei6 已提交
298 299
    part_name = "init"
  }
300
}