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

import("//build/config/components/idl_tool/idl.gni")
import("../../batterymgr.gni")

config("batterysrv_public_config") {
  include_dirs = [
    "${battery_inner_api}/native/include",
    "${target_gen_dir}",
  ]
}

idl_gen_interface("batterysrv_interface") {
  sources = [ "IBatterySrv.idl" ]

  log_domainid = "0xD002922"
  log_tag = "BatterySvc"
  subsystem_name = "powermgr"
  part_name = "battery_manager"
}

ohos_source_set("batterysrv_proxy") {
  sanitize = {
    cfi = true
    cfi_cross_dso = true
    debug = false
  }
  output_values = get_target_outputs(":batterysrv_interface")
  sources = filter_include(output_values, [ "*_proxy.cpp" ])
  configs = [
    "${battery_utils}:utils_config",
    ":batterysrv_public_config",
    "${battery_utils}:coverage_flags",
  ]
  deps = [ ":batterysrv_interface" ]
  external_deps = [
    "c_utils:utils",
    "hilog:libhilog",
    "ipc:ipc_single",
    "samgr:samgr_proxy",
  ]
  subsystem_name = "powermgr"
  part_name = "battery_manager"
}

ohos_source_set("batterysrv_stub") {
  sanitize = {
    cfi = true
    cfi_cross_dso = true
    debug = false
  }
  output_values = get_target_outputs(":batterysrv_interface")
  sources = filter_include(output_values, [ "*_stub.cpp" ])

  configs = [
    "${battery_utils}:utils_config",
    ":batterysrv_public_config",
    "${battery_utils}:coverage_flags",
  ]

  deps = [ ":batterysrv_interface" ]
  external_deps = [
    "c_utils:utils",
    "hilog:libhilog",
    "ipc:ipc_core",
    "ipc:ipc_single",
  ]

  subsystem_name = "powermgr"
  part_name = "battery_manager"
}