# 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("devicemanagerservice_mini") {
      include_dirs = [
        "${devicemanager_path}/interfaces/inner_kits/native_cpp/include",
        "${devicemanager_path}/interfaces/inner_kits/native_cpp/include/notify",
        "${servicesimpl_path}/include",
        "${servicesimpl_path}/include/config",
        "${servicesimpl_path}/include/adapter",
        "${servicesimpl_path}/include/authentication",
        "${servicesimpl_path}/include/authentication/showconfirm/lite",
        "${servicesimpl_path}/include/ability",
        "${servicesimpl_path}/include/credential",
        "${servicesimpl_path}/include/devicestate",
        "${servicesimpl_path}/include/discovery",
        "${servicesimpl_path}/include/dependency/commonevent",
        "${servicesimpl_path}/include/dependency/multipleuser",
        "${servicesimpl_path}/include/dependency/hichain",
        "${servicesimpl_path}/include/dependency/softbus",
        "${servicesimpl_path}/include/dependency/mini",
        "${servicesimpl_path}/include/dependency/timer",
        "${servicesimpl_path}/include/eventbus",
        "${common_path}/include",
        "${common_path}/include/ipc",
        "${common_path}/include/ipc/model",
        "//base/security/device_auth/interfaces/innerkits",
        "//third_party/json/include",
        "${utils_path}/include",
        "${utils_path}/include/dfx",
        "${utils_path}/include/dfx/lite",
        "${utils_path}/include/permission/lite",
        "foundation/multimedia/image_standard/mock/native/include",
        "${servicesimpl_path}/include/dispatch",
        "${ext_path}/pin_auth/include",
        "${ext_path}/pin_auth/include/lite",
      ]

      include_dirs += [
        "//base/security/device_auth/interfaces/innerkits",
        "//base/startup/syspara_lite/interfaces/innerkits/native/syspara/include",
        "//utils/native/lite/include",
        "//utils/system/safwk/native/include",
        "//third_party/json/include",
        "//base/hiviewdfx/hilog_lite/interfaces/native/innerkits/hilog",
        "//third_party/bounds_checking_function/include",
        "//foundation/communication/ipc/interfaces/innerkits/c/ipc/include",
        "//foundation/communication/dsoftbus/interfaces/kits/bus_center",
        "//foundation/communication/dsoftbus/interfaces/kits/common",
        "//foundation/communication/dsoftbus/interfaces/kits/discovery",
        "//foundation/communication/dsoftbus/interfaces/kits/transport",
        "//foundation/communication/dsoftbus/interfaces/inner_kits/transport",
        "//foundation/distributedhardware/device_manager/services/implementation/include/dependency/multipleuser",
        "//foundation/distributedschedule/samgr_lite/interfaces/kits/samgr",
        "//foundation/distributedschedule/samgr/interfaces/innerkits/samgr_proxy/include",
      ]

      sources = [
        "${servicesimpl_path}/src/ability/lite/dm_ability_manager.cpp",
        "${servicesimpl_path}/src/adapter/standard/dm_adapter_manager.cpp",
        "${servicesimpl_path}/src/authentication/auth_message_processor.cpp",
        "${servicesimpl_path}/src/authentication/auth_request_state.cpp",
        "${servicesimpl_path}/src/authentication/auth_response_state.cpp",
        "${servicesimpl_path}/src/authentication/dm_auth_manager.cpp",
        "${servicesimpl_path}/src/authentication/showconfirm/lite/show_confirm.cpp",
        "${servicesimpl_path}/src/config/mini/dm_config_manager.cpp",
        "${servicesimpl_path}/src/config/mini/pin_auth.cpp",
        "${servicesimpl_path}/src/dependency/hichain/hichain_connector.cpp",
        "${servicesimpl_path}/src/dependency/mini/dm_mutex.cpp",
        "${servicesimpl_path}/src/dependency/mini/dm_thread.cpp",
        "${servicesimpl_path}/src/dependency/multipleuser/multiple_user_connector.cpp",
        "${servicesimpl_path}/src/dependency/softbus/softbus_connector.cpp",
        "${servicesimpl_path}/src/dependency/softbus/softbus_session.cpp",
        "${servicesimpl_path}/src/dependency/timer/mini/dm_timer.cpp",
        "${servicesimpl_path}/src/devicestate/dm_device_state_manager.cpp",
        "${servicesimpl_path}/src/discovery/dm_discovery_manager.cpp",
        "${servicesimpl_path}/src/dispatch/command_dispatch.cpp",
        "${servicesimpl_path}/src/dispatch/device_manager_service_listener_mini.cpp",
        "${servicesimpl_path}/src/dispatch/server_stub.cpp",
      ]

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

      if (os_account_part_exists) {
        defines += [ "OS_ACCOUNT_PART_EXISTS" ]
        include_dirs += [ "//base/account/os_account/interfaces/innerkits/osaccount/native/include" ]
      }

      ldflags = dm_ldflags

      deps = [
        "${devicemanager_path}/interfaces/inner_kits/native_cpp:devicemanagersdk_mini",
        "${utils_path}:devicemanagerutils_mini",
        "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_static",
        "//base/security/device_auth/services:deviceauth",
        "//base/startup/syspara_lite/frameworks/parameter/src:sysparam",
        "//foundation/communication/dsoftbus/sdk:softbus_client",
        "//foundation/distributedschedule/samgr_lite/samgr",
        "//third_party/bounds_checking_function:libsec_static",
        "//third_party/mbedtls",
        "//utils/native/lite:utils",
      ]
    }
  }
} else if (!support_jsapi) {
  group("devicemanagerserviceimpl") {
    deps = []
  }
} else {
  config("devicemanagerserviceimpl_config") {
    include_dirs = [
      "include",
      "include/config",
      "include/adapter",
      "include/authentication",
      "include/authentication/showconfirm/standard",
      "include/ability",
      "include/credential",
      "include/devicestate",
      "include/discovery",
      "include/dependency/commonevent",
      "include/dependency/multipleuser",
      "include/dependency/hichain",
      "include/dependency/softbus",
      "include/dependency/timer",
      "${common_path}/include",
      "${common_path}/include/ipc",
      "${common_path}/include/ipc/model",
      "${utils_path}/include",
      "${utils_path}/include/fwkload/standard",
      "${utils_path}/include/dfx",
      "${utils_path}/include/dfx/standard",
      "${utils_path}/include/permission/standard",
      "//base/security/device_auth/interfaces/innerkits",
      "//third_party/json/include",
      "${services_path}/include",
      "${services_path}/include/ipc/standard",
    ]

    if (os_account_part_exists) {
      include_dirs += [ "//base/account/os_account/interfaces/innerkits/osaccount/native/include" ]
    }
  }

  ohos_shared_library("devicemanagerserviceimpl") {
    sources = [
      "src/ability/standard/dm_ability_manager.cpp",
      "src/adapter/standard/dm_adapter_manager.cpp",
      "src/authentication/auth_message_processor.cpp",
      "src/authentication/auth_request_state.cpp",
      "src/authentication/auth_response_state.cpp",
      "src/authentication/dm_auth_manager.cpp",
      "src/authentication/showconfirm/standard/show_confirm.cpp",
      "src/config/dm_config_manager.cpp",
      "src/credential/dm_credential_manager.cpp",
      "src/dependency/commonevent/dm_common_event_manager.cpp",
      "src/dependency/hichain/hichain_connector.cpp",
      "src/dependency/multipleuser/multiple_user_connector.cpp",
      "src/dependency/softbus/softbus_connector.cpp",
      "src/dependency/softbus/softbus_session.cpp",
      "src/dependency/timer/dm_timer.cpp",
      "src/device_manager_service_impl.cpp",
      "src/devicestate/dm_device_state_manager.cpp",
      "src/discovery/dm_discovery_manager.cpp",
    ]

    public_configs = [ ":devicemanagerserviceimpl_config" ]

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

    deps = [
      "${ability_runtime_innerkits_path}/ability_manager:ability_manager",
      "${ability_runtime_services_path}/abilitymgr:abilityms",
      "${innerkits_path}/native_cpp:devicemanagersdk",
      "${utils_path}:devicemanagerutils",
      "//base/security/device_auth/services:deviceauth_sdk",
    ]

    if (os_account_part_exists) {
      defines += [ "OS_ACCOUNT_PART_EXISTS" ]
      deps += [ "//base/account/os_account/frameworks/osaccount/native:os_account_innerkits" ]
    }

    if (!device_manager_no_interaction_auth) {
      deps += [
        "${common_path}/include/show_confirm_dialog/dialog_ui/js:dialog_js_files_etc",
        "//foundation/arkui/ace_engine/interfaces/inner_api/ui_service_manager:ui_service_mgr",
      ]
      defines += [ "SUPPORT_GRAPHICS" ]
    }
    external_deps = [
      "ability_base:want",
      "ability_runtime:app_manager",
      "bundle_framework:appexecfwk_base",
      "bundle_framework:appexecfwk_core",
      "common_event_service:cesfwk_core",
      "common_event_service:cesfwk_innerkits",
      "dsoftbus:softbus_client",
      "eventhandler:libeventhandler",
      "hisysevent_native:libhisysevent",
      "hitrace_native:hitrace_meter",
      "hiviewdfx_hilog_native:libhilog",
      "init:libbeget_proxy",
      "init:libbegetutil",
      "ipc:ipc_core",
      "safwk:system_ability_fwk",
      "samgr_standard:samgr_proxy",
      "utils_base:utils",
    ]

    subsystem_name = "distributedhardware"

    part_name = "device_manager"
  }
}