BUILD.gn 9.7 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

X
xionglei6 已提交
147 148 149 150 151 152 153 154 155 156 157
  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 已提交
158 159
    sources += syspara_sources
    sources += [ "syspara/param_wrapper.cpp" ]
X
xionglei6 已提交
160

M
Mupceet 已提交
161 162 163 164 165 166
    defines = [
      "INIT_AGENT",
      "INIT_FILE",
      "_GNU_SOURCE",
      "INIT_FILE",
    ]
X
xionglei6 已提交
167 168 169 170 171
    include_dirs = [
      "./include",
      "//third_party/bounds_checking_function/include",
      "//base/startup/init_lite/services/include",
      "//base/startup/init_lite/services/include/param",
M
Mupceet 已提交
172
      "//base/startup/init_lite/services/param/include",
X
xionglei6 已提交
173
      "//base/startup/init_lite/interfaces/innerkits/fd_holder",
M
Mupceet 已提交
174
      "//base/startup/init_lite/interfaces/innerkits/include",
X
xionglei6 已提交
175 176
    ]
    deps = [
M
Mupceet 已提交
177
      "//base/startup/init_lite/interfaces/innerkits/sandbox:libsandbox",
X
xionglei6 已提交
178 179 180 181 182
      "//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 已提交
183
      "//third_party/openssl:libcrypto_shared",
X
xionglei6 已提交
184
    ]
T
taiyipei 已提交
185 186 187 188
    external_deps = [
      "hilog_native:libhilog_base",
      "utils_base:utils",
    ]
X
xionglei6 已提交
189 190 191 192 193 194 195
    public_configs = [ ":exported_header_files" ]
    part_name = "init"
    install_images = [
      "system",
      "updater",
    ]
  }
196

X
xionglei6 已提交
197 198
  # watcher lib must separate compilation avoid interdependence.
  ohos_shared_library("libbeget_proxy") {
M
Mupceet 已提交
199 200 201 202
    defines = [
      "INIT_AGENT",
      "_GNU_SOURCE",
    ]
X
xionglei6 已提交
203
    sources = [
M
Mupceet 已提交
204
      "//base/startup/init_lite/device_info/device_info.cpp",
X
xionglei6 已提交
205 206 207
      "//base/startup/init_lite/services/log/init_log.c",
      "service_watcher/service_watcher.c",
    ]
X
xionglei6 已提交
208

X
xionglei6 已提交
209 210 211 212
    include_dirs = [
      "./include",
      "//base/startup/init_lite/device_info",
      "//base/startup/init_lite/interfaces/innerkits/include",
M
Mupceet 已提交
213
      "//base/startup/init_lite/interfaces/innerkits/syspara",
X
xionglei6 已提交
214 215
      "//base/startup/init_lite/services/include",
      "//base/startup/init_lite/services/include/param",
M
Mupceet 已提交
216
      "//base/startup/init_lite/services/param/include",
X
xionglei6 已提交
217 218
      "//third_party/bounds_checking_function/include",
    ]
219

X
xionglei6 已提交
220 221 222 223 224
    deps = [
      "//base/startup/init_lite/services/utils:libinit_utils",
      "//third_party/bounds_checking_function:libsec_shared",
    ]

M
Mupceet 已提交
225 226 227 228 229 230 231 232 233 234 235
    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 已提交
236 237 238 239 240 241
      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 已提交
242 243 244 245 246 247 248
    } else {
      defines += [ "NO_PARAM_WATCHER" ]
    }

    if (param_feature_deviceinfo) {
      sources += [
        "//base/startup/init_lite/device_info/device_info_kits.cpp",
M
Mupceet 已提交
249
        "//base/startup/init_lite/device_info/device_info_proxy.cpp",
M
Mupceet 已提交
250 251 252
      ]
      defines += [ "PARAM_FEATURE_DEVICEINFO" ]
    } else {
M
Mupceet 已提交
253 254 255
      sources += [
        "//base/startup/init_lite/interfaces/innerkits/syspara/param_comm.c",
      ]
M
Mupceet 已提交
256 257
      deps += [
        "//base/startup/init_lite/services/loopevent:loopevent",
M
Mupceet 已提交
258
        "//base/startup/init_lite/services/param:param_client",
M
Mupceet 已提交
259 260
        "//base/startup/init_lite/services/utils:libinit_tools",
        "//base/startup/init_lite/services/utils:libinit_utils",
M
Mupceet 已提交
261 262
        "//third_party/openssl:libcrypto_shared",
      ]
M
Mupceet 已提交
263 264
    }

X
xionglei6 已提交
265 266 267 268 269
    external_deps = [
      "hilog_native:libhilog_base",
      "ipc:ipc_core",
      "safwk:system_ability_fwk",
      "samgr_standard:samgr_proxy",
T
taiyipei 已提交
270
      "utils_base:utils",
X
xionglei6 已提交
271
    ]
M
Mupceet 已提交
272
    public_configs = [ ":exported_header_files" ]
X
xionglei6 已提交
273 274 275 276 277 278 279 280 281 282 283 284
    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 已提交
285
      "//base/startup/init_lite/services/param/include",
X
xionglei6 已提交
286
    ]
X
fix log  
xionglei6 已提交
287

X
xionglei6 已提交
288 289
    part_name = "init"
  }
290
}