# Copyright (c) 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/ohos.gni")
import("//build/config/components/idl_tool/idl.gni")
import("//foundation/systemabilitymgr/selectionfwk/selection_service.gni")

idl_gen_interface("selection_listener_interface") {
  src_idl = rebase_path("ISelectionListener.idl")
}

idl_gen_interface("selection_service_interface") {
  src_idl = rebase_path("ISelectionService.idl")
}

config("selection_listener_config") {
  include_dirs = [
    "include",
    "${selection_fwk_root_path}/common",
    "${target_gen_dir}",
  ]
}

config("selection_service_config") {
  include_dirs = [
    "include",
    "${selection_fwk_root_path}/common",
    "${target_gen_dir}",
  ]
}

ohos_source_set("selection_listener_proxy") {
  sanitize = {
    cfi = true
    cfi_cross_dso = true
    cfi_vcall_icall_only = true
    debug = false
  }
  cflags_cc = [
    "-fdata-sections",
    "-ffunction-sections",
    "-Os",
  ]
  ldflags = [
    "-Wl,--as-needed",
    "-Wl,--gc-sections",
  ]
  include_dirs = [
    "${target_gen_dir}",
  ]

  public_configs = [":selection_listener_config"]
  output_values = get_target_outputs(":selection_listener_interface")
  sources = filter_include(output_values, [ "*_proxy.cpp" ])
  deps = [ ":selection_listener_interface" ]
  external_deps = [
    "c_utils:utils",
    "hilog:libhilog",
    "ipc:ipc_single",
  ]
  part_name = "selectionfwk"
  subsystem_name = "systemabilitymgr"
}

ohos_source_set("selection_listener_stub") {
  sanitize = {
    cfi = true
    cfi_cross_dso = true
    cfi_vcall_icall_only = true
    debug = false
  }
  cflags_cc = [
    "-fdata-sections",
    "-ffunction-sections",
    "-Os",
  ]
  ldflags = [
    "-Wl,--as-needed",
    "-Wl,--gc-sections",
  ]
  include_dirs = [
    "${target_gen_dir}",
  ]

  public_configs = [":selection_listener_config"]
  output_values = get_target_outputs(":selection_listener_interface")
  sources = filter_include(output_values, [ "*_stub.cpp" ])
  deps = [ ":selection_listener_interface" ]
  external_deps = [
    "c_utils:utils",
    "hilog:libhilog",
    "ipc:ipc_single",
  ]
  part_name = "selectionfwk"
  subsystem_name = "systemabilitymgr"
}

ohos_source_set("selection_service_proxy") {
  sanitize = {
    cfi = true
    cfi_cross_dso = true
    cfi_vcall_icall_only = true
    debug = false
  }
  cflags_cc = [
    "-fdata-sections",
    "-ffunction-sections",
    "-Os",
  ]
  ldflags = [
    "-Wl,--as-needed",
    "-Wl,--gc-sections",
  ]
  include_dirs = [
    "${target_gen_dir}",
  ]

  public_configs = [":selection_service_config"]
  output_values = get_target_outputs(":selection_service_interface")
  sources = filter_include(output_values, [ "*_proxy.cpp" ])
  deps = [ ":selection_service_interface" ]
  external_deps = [
    "c_utils:utils",
    "hilog:libhilog",
    "ipc:ipc_single",
  ]
  part_name = "selectionfwk"
  subsystem_name = "systemabilitymgr"
}

ohos_source_set("selection_service_stub") {
  sanitize = {
    cfi = true
    cfi_cross_dso = true
    cfi_vcall_icall_only = true
    debug = false
  }
  cflags_cc = [
    "-fdata-sections",
    "-ffunction-sections",
    "-Os",
  ]
  ldflags = [
    "-Wl,--as-needed",
    "-Wl,--gc-sections",
  ]
  include_dirs = [
    "${target_gen_dir}",
  ]

  public_configs = [":selection_service_config"]
  output_values = get_target_outputs(":selection_service_interface")
  sources = filter_include(output_values, [ "*_stub.cpp" ])
  deps = [ ":selection_service_interface" ]
  external_deps = [
    "c_utils:utils",
    "hilog:libhilog",
    "ipc:ipc_single",
  ]
  part_name = "selectionfwk"
  subsystem_name = "systemabilitymgr"
}