# 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("//foundation/systemabilitymgr/selectionfwk/selection_service.gni")

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

ohos_shared_library("selection_ability") {
  branch_protector_ret = "pac_ret"
  sanitize = {
    boundary_sanitize = true
    cfi = true
    cfi_cross_dso = true
    cfi_vcall_icall_only = true
    debug = false
    integer_overflow = true
    ubsan = true
  }
  cflags_cc = [
    "-fdata-sections",
    "-ffunction-sections",
    "-Os",
    "-fvisibility-inlines-hidden",
  ]
  ldflags = [
    "-Wl,--as-needed",
    "-Wl,--gc-sections",
    "-Wl,--exclude-libs,ALL",
  ]
  configs = [ ":selection_listener_config", ]

  include_dirs = [
    "${selection_fwk_root_path}/interfaces/inner_kits/selection_client/include",
  ]

  sources = [
    "src/selection_ability.cpp",
    "src/selection_listener_impl.cpp",
    "src/selection_panel.cpp",
    "src/selection_app_validator.cpp",
    "src/selection_system_ability_utils.cpp",
    "${selection_fwk_root_path}/hiappevent_agent/selection_api_event_reporter.cpp",
    "${selection_fwk_root_path}/sysevent/hisysevent_adapter.cpp",
    "${selection_fwk_root_path}/utils/src/selection_timer.cpp",
  ]
  deps = [
    "${selection_fwk_root_path}/common:selection_common",
    "${selection_fwk_root_path}/interfaces/idl:selection_listener_interface",
    "${selection_fwk_root_path}/interfaces/idl:selection_listener_stub",
    "${selection_fwk_root_path}/interfaces/inner_kits/selection_client:selection_client",
  ]

  external_deps = [
    "c_utils:utils",
    "ipc:ipc_single",
    "hilog:libhilog",
    "ability_base:configuration",
    "ability_base:want",
    "ability_runtime:ability_context_native",
    "ability_runtime:app_context",
    "bundle_framework:appexecfwk_base",
    "config_policy:configpolicy_util",
    "eventhandler:libeventhandler",
    "graphic_2d:librender_service_base",
    "graphic_2d:librender_service_client",
    "graphic_2d:window_animation",
    "icu:shared_icuuc",
    "input:libmmi-client",
    "safwk:system_ability_fwk",
    "samgr:samgr_proxy",
    "window_manager:libdm",
    "window_manager:libwsutils",
    "ability_runtime:ability_manager",
    "hiappevent:hiappevent_innerapi",
    "hitrace:hitrace_meter",
    "hitrace:libhitracechain",
    "hisysevent:libhisysevent",
  ]

  defines = []

  if (selectionfwk_support_pass_windowId) {
    defines += [ "SELECTIONFWK_SUPPORT_PASS_WINDOWID" ]
  }

  if (window_manager_use_sceneboard) {
    defines += [ "SCENE_BOARD_ENABLE" ]
  }

  public_external_deps = [ "window_manager:libwm" ]

  part_name = "selectionfwk"
  subsystem_name = "systemabilitymgr"
}