# 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")

ohos_executable("hdf_devmgr") {
  defines = [ "__USER__" ]
  include_dirs = [
    "//utils/native/base/include",
    "$hdf_framework_path/core/manager/include",
    "$hdf_framework_path/core/common/include/manager/",
    "$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/osal",
    "$hdf_uhdf_path/include/host",
    "$hdf_uhdf_path/shared/include",
    "$hdf_uhdf_path/manager/include",
    "$hdf_uhdf_path/host/include",
    "$hdf_uhdf_path/security/include",
    "$hdf_uhdf_path/utils/include",
    "include",
  ]

  sources = [
    "$hdf_framework_path/core/common/src/hdf_attribute.c",
    "$hdf_framework_path/core/manager/src/devhost_service_clnt.c",
    "$hdf_framework_path/core/manager/src/device_token_clnt.c",
    "$hdf_framework_path/core/manager/src/devmgr_service.c",
    "$hdf_framework_path/core/manager/src/devsvc_manager.c",
    "$hdf_framework_path/core/manager/src/hdf_driver_installer.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_uhdf_path/shared/src/dev_attribute_serialize.c",
    "$hdf_uhdf_path/shared/src/hcb_config_entry.c",
    "device_manager.c",
    "src/devhost_service_proxy.c",
    "src/device_token_proxy.c",
    "src/devmgr_object_config.c",
    "src/devmgr_query_device.c",
    "src/devmgr_service_full.c",
    "src/devmgr_service_stub.c",
    "src/devsvc_manager_stub.c",
    "src/driver_installer_full.c",
    "src/servstat_listener_holder.c",
  ]

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

  external_deps = [
    "hiviewdfx_hilog_native:libhilog",
    "init:libbegetutil",
    "utils_base:utils",
  ]

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

  if (build_selinux) {
    external_deps += [ "selinux:libservice_checker" ]
    cflags += [ "-DWITH_SELINUX" ]
  }

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

ohos_prebuilt_etc("hdf_devmgr.cfg") {
  source = "hdf_devmgr.cfg"
  relative_install_dir = "init"
  install_images = [ chipset_base_dir ]
  subsystem_name = "hdf"
  part_name = "device_driver_framework"
}