# 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.

import("//build/ohos.gni")
import("//drivers/adapter/uhdf2/uhdf.gni")
config("libhdf_host_pub_config") {
  visibility = [ ":*" ]

  include_dirs = [
    "//utils/native/base/include",
    "$hdf_framework_path/core/manager/include",
    "$hdf_framework_path/core/host/include",
    "$hdf_framework_path/core/shared/include",
    "$hdf_uhdf_path/include/host",
    "$hdf_uhdf_path/shared/include",
    "$hdf_uhdf_path/manager/include",
    "include",
  ]
}
if (defined(ohos_lite)) {
  group("libhdf_host") {
    deps = []
  }
} else {
  ohos_shared_library("libhdf_host") {
    if (target_cpu == "arm64") {
      defines = [ "__ARM64__" ]
    }

    public_configs = [ ":libhdf_host_pub_config" ]
    include_dirs = [
      "$hdf_framework_path/core/manager/include",
      "$hdf_framework_path/core/host/include",
      "$hdf_framework_path/core/shared/include",
      "$hdf_uhdf_path/include/host",
      "$hdf_uhdf_path/shared/include",
      "$hdf_uhdf_path/manager/include",
      "$hdf_uhdf_path/security/include",
      "$hdf_uhdf_path/utils/include",
      "include",
    ]

    sources = [
      "$hdf_framework_path/core/host/src/devhost_service.c",
      "$hdf_framework_path/core/host/src/devmgr_service_clnt.c",
      "$hdf_framework_path/core/host/src/devsvc_manager_clnt.c",
      "$hdf_framework_path/core/host/src/hdf_device.c",
      "$hdf_framework_path/core/host/src/hdf_device_node.c",
      "$hdf_framework_path/core/host/src/hdf_device_object.c",
      "$hdf_framework_path/core/host/src/hdf_device_token.c",
      "$hdf_framework_path/core/host/src/hdf_observer_record.c",
      "$hdf_framework_path/core/host/src/hdf_power_manager.c",
      "$hdf_framework_path/core/host/src/hdf_service_observer.c",
      "$hdf_framework_path/core/host/src/hdf_service_subscriber.c",
      "$hdf_framework_path/core/host/src/power_state_token.c",
      "$hdf_framework_path/core/manager/src/hdf_host_info.c",
      "$hdf_framework_path/core/shared/src/hdf_device_info.c",
      "$hdf_framework_path/core/shared/src/hdf_object_manager.c",
      "$hdf_framework_path/core/shared/src/hdf_service_record.c",
      "$hdf_framework_path/utils/src/hdf_task_queue.c",
      "$hdf_uhdf_path/host/src/devhost_object_config.c",
      "$hdf_uhdf_path/host/src/devhost_service_full.c",
      "$hdf_uhdf_path/host/src/devhost_service_stub.c",
      "$hdf_uhdf_path/host/src/device_service_stub.c",
      "$hdf_uhdf_path/host/src/device_token_stub.c",
      "$hdf_uhdf_path/host/src/devmgr_service_proxy.c",
      "$hdf_uhdf_path/host/src/devsvc_manager_proxy.c",
      "$hdf_uhdf_path/host/src/driver_loader_full.c",
      "$hdf_uhdf_path/host/src/hdf_device_thread.c",
      "$hdf_uhdf_path/host/src/hdf_devsvc_manager_clnt.c",
      "$hdf_uhdf_path/host/src/hdf_pm_reg.c",
      "$hdf_uhdf_path/shared/src/dev_attribute_serialize.c",
      "$hdf_uhdf_path/shared/src/hcb_config_entry.c",
    ]

    deps = [
      "$hdf_uhdf_path/ipc:libhdf_ipc_adapter",
      "$hdf_uhdf_path/utils:libhdf_utils",
    ]

    if (is_standard_system) {
      external_deps = [
        "hiviewdfx_hilog_native:libhilog",
        "utils_base:utils",
      ]
    } else {
      external_deps = [ "hilog:libhilog" ]
    }

    cflags = [
      "-Wall",
      "-Wextra",
      "-Werror",
    ]

    install_images = [ chipset_base_dir ]
    subsystem_name = "hdf"
    part_name = "device_driver_framework"
  }

  ohos_executable("hdf_devhost") {
    include_dirs = [
      "//utils/native/base/include",
      "$hdf_framework_path/core/manager/include",
      "$hdf_framework_path/core/host/include",
      "$hdf_framework_path/core/shared/include",
      "$hdf_uhdf_path/ipc/include",
      "$hdf_uhdf_path/osal/include",
      "$hdf_uhdf_path/include/host",
      "$hdf_uhdf_path/shared/include",
      "$hdf_uhdf_path/manager/include",
      "include",
    ]

    sources = [ "devhost.c" ]

    deps = [
      "$hdf_uhdf_path/host:libhdf_host",
      "$hdf_uhdf_path/ipc:libhdf_ipc_adapter",
      "$hdf_uhdf_path/utils:libhdf_utils",
    ]

    if (is_standard_system) {
      external_deps = [
        "hiviewdfx_hilog_native:libhilog",
        "utils_base:utils",
      ]
    } else {
      external_deps = [ "hilog:libhilog" ]
    }

    cflags = [
      "-Wall",
      "-Wextra",
      "-Werror",
    ]

    install_enable = true
    install_images = [ chipset_base_dir ]
    subsystem_name = "hdf"
    part_name = "device_driver_framework"
  }
}