# Copyright (c) 2022 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.

if (defined(ohos_lite)) {
  import("//build/lite/config/component/lite_component.gni")
} else {
  import("//build/ohos.gni")
}
import("//foundation/distributedhardware/device_manager/device_manager.gni")

if (defined(ohos_lite)) {
  if (ohos_kernel_type == "liteos_m") {
    static_library("devicemanagersdk_mini") {
      include_dirs = [
        "${innerkits_path}/native_cpp/include",
        "${innerkits_path}/native_cpp/include/notify",
        "${utils_path}/include",
        "${utils_path}/include/dfx",
        "${utils_path}/include/dfx/lite",
        "${common_path}/include",
        "${common_path}/include/ipc",
        "${common_path}/include/ipc/model",
        "${servicesimpl_path}/include/dispatch",
      ]
      include_dirs += [
        "//utils/native/lite/include",
        "//base/hiviewdfx/hilog_lite/interfaces/native/innerkits/hilog",
        "//third_party/bounds_checking_function/include",
        "//foundation/distributedschedule/samgr_lite/interfaces/kits/samgr",
        "//third_party/json/include",
      ]

      sources = [
        "${innerkits_path}/native_cpp/src/mini/device_manager.cpp",
        "${innerkits_path}/native_cpp/src/mini/device_manager_impl.cpp",
        "${innerkits_path}/native_cpp/src/mini/device_manager_notify.cpp",
      ]

      defines = [
        "__LITEOS_M__",
        "HI_LOG_ENABLE",
        "DH_LOG_TAG=\"devicemanagerkit\"",
        "LOG_DOMAIN=0xD004100",
      ]

      deps = [
        "${utils_path}:devicemanagerutils_mini",
        "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_static",
        "//foundation/distributedschedule/samgr_lite/samgr",
        "//third_party/bounds_checking_function:libsec_static",
        "//utils/native/lite:utils",
      ]
    }
  } else {
    shared_library("devicemanagersdk") {
      include_dirs = [
        "include",
        "include/ipc",
        "include/ipc/lite",
        "include/notify",
        "${common_path}/include",
        "${common_path}/include/ipc",
        "${common_path}/include/ipc/model",
        "${utils_path}/include",
        "${utils_path}/include/dfx",
        "${utils_path}/include/dfx/lite",
        "${utils_path}/include/ipc/lite",
      ]
      include_dirs += [
        "//utils/native/lite/include",
        "//base/hiviewdfx/hilog_lite/interfaces/native/innerkits/hilog",
        "//third_party/bounds_checking_function/include",
        "//foundation/communication/ipc/interfaces/innerkits/c/ipc/include",
        "//foundation/distributedschedule/samgr_lite/interfaces/kits/samgr",
        "//foundation/distributedschedule/samgr_lite/interfaces/kits/registry",
        "//third_party/json/include",
      ]
      sources = [
        "src/device_manager.cpp",
        "src/device_manager_impl.cpp",
        "src/ipc/ipc_client_proxy.cpp",
        "src/ipc/lite/ipc_client_manager.cpp",
        "src/ipc/lite/ipc_client_server_proxy.cpp",
        "src/ipc/lite/ipc_client_stub.cpp",
        "src/ipc/lite/ipc_cmd_parser.cpp",
        "src/notify/device_manager_notify.cpp",
      ]
      deps = [
        "${utils_path}:devicemanagerutils",
        "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared",
        "//foundation/communication/ipc/interfaces/innerkits/c/ipc:ipc_single",
        "//foundation/distributedschedule/samgr_lite/samgr:samgr",
        "//third_party/bounds_checking_function:libsec_shared",
        "//utils/native/lite:utils",
      ]
      defines = [
        "LITE_DEVICE",
        "HI_LOG_ENABLE",
        "DH_LOG_TAG=\"devicemanagerkit\"",
        "LOG_DOMAIN=0xD004100",
      ]
    }
  }
} else {
  config("devicemanagersdk_config") {
    include_dirs = [
      "include",
      "include/ipc",
      "include/ipc/standard",
      "include/notify",
      "${common_path}/include",
      "${common_path}/include/ipc",
      "${common_path}/include/ipc/model",
      "${utils_path}/include/dfx",
      "${utils_path}/include/dfx/standard",
    ]
  }

  ohos_shared_library("devicemanagersdk") {
    sources = [
      "src/device_manager.cpp",
      "src/device_manager_impl.cpp",
      "src/ipc/ipc_client_proxy.cpp",
      "src/ipc/standard/ipc_client_manager.cpp",
      "src/ipc/standard/ipc_client_server_proxy.cpp",
      "src/ipc/standard/ipc_client_stub.cpp",
      "src/ipc/standard/ipc_cmd_parser.cpp",
      "src/notify/device_manager_notify.cpp",
    ]

    public_configs = [ ":devicemanagersdk_config" ]

    defines = [
      "HI_LOG_ENABLE",
      "DH_LOG_TAG=\"devicemanagerkit\"",
      "LOG_DOMAIN=0xD004100",
    ]

    deps = [ "${utils_path}:devicemanagerutils" ]

    external_deps = [
      "hisysevent_native:libhisysevent",
      "hitrace_native:hitrace_meter",
      "hiviewdfx_hilog_native:libhilog",
      "ipc:ipc_core",
      "samgr_standard:samgr_proxy",
      "utils_base:utils",
    ]

    subsystem_name = "distributedhardware"

    part_name = "device_manager"
  }
}