# Copyright (c) 2024-2025 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("//build/ohos.gni")
import("//build/test.gni")
import("../../../multimodalinput_mini.gni")

idl_gen_interface("anco_channel_interface") {
  src_idl = rebase_path("IAncoChannel.idl")
}

config("mmi_anco_channel_config") {
  include_dirs = [
    "include",
    "${mmi_path}/interfaces/native/innerkits/event/include",
    "${mmi_path}/interfaces/native/innerkits/proxy/include",
    "${target_gen_dir}",
    "${mmi_path}/intention/scheduler/component_manager/include",
    "${mmi_path}/service/setting_manager/include"
  ]

  if (input_ext_feature_anco) {
    include_dirs += [ "${mmi_ext_path}/anco_uds_manager/include" ]
  }
}

ohos_source_set("mmi_anco_channel_proxy") {
  branch_protector_ret = "pac_ret"

  defines = input_default_defines

  sources = [
    "${mmi_path}/frameworks/proxy/events/src/i_anco_consumer.cpp",
    "src/anco_channel_death_recipient.cpp",
  ]

  output_values = get_target_outputs(":anco_channel_interface")
  sources += filter_include(output_values, [ "*_proxy.cpp" ])

  branch_protector_ret = "pac_ret"
  sanitize = {
    cfi = true
    cfi_cross_dso = true
    debug = false
  }

  configs = [ ":mmi_anco_channel_config" ]

  public_configs = [ ":mmi_anco_channel_config" ]

  deps = [
    ":anco_channel_interface",
    "${mmi_path}/util:libmmi-util",
  ]

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

  part_name = "${mmi_part_name}"
  subsystem_name = "${mmi_subsystem_name}"
}

ohos_source_set("mmi_anco_channel_stub") {
  branch_protector_ret = "pac_ret"

  defines = input_default_defines

  sources = [
    "${mmi_path}/frameworks/proxy/events/src/i_anco_consumer.cpp",
    "src/anco_channel.cpp",
  ]

  output_values = get_target_outputs(":anco_channel_interface")
  sources += filter_include(output_values, [ "*_stub.cpp" ])

  branch_protector_ret = "pac_ret"
  sanitize = {
    cfi = true
    cfi_cross_dso = true
    debug = false
  }

  configs = [ ":mmi_anco_channel_config" ]

  public_configs = [ ":mmi_anco_channel_config" ]

  deps = [
    ":anco_channel_interface",
    "${mmi_path}/util:libmmi-util",
  ]

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

  part_name = "${mmi_part_name}"
  subsystem_name = "${mmi_subsystem_name}"
}