# 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/arkui/ace_engine/ace_config.gni")

# build core sources
template("ace_core_accessibility_ng_source_set") {
  forward_variables_from(invoker, "*")

  ohos_source_set(target_name) {
    subsystem_name = ace_engine_subsystem
    part_name = ace_engine_part
    if (current_os == "ohos") {
      sanitize = {
        integer_overflow = true
        boundary_sanitize = true
        debug = ace_sanitize_debug
      }
    }
    defines += invoker.defines

    # add common source file needed by all product platform here
    sources = [
      # hidumper
      "hidumper/accessibility_hidumper.cpp",
      # for frameNode property handle
      "node_utils/accessibility_frame_node_utils.cpp",
      # utils
      "utils/accessibility_property_utils.cpp",
    ]

    if (!build_ohos_sdk) {
      sources += [ "utils/accessibility_manager_utils.cpp" ]
    }

    configs = [ "$ace_root:ace_config" ]

    deps = []
    external_deps = [
    ]
    if (use_hilog) {
      external_deps += [ "hilog:libhilog" ]
    }
    cflags_cc = []
    cflags_cc += invoker.cflags_cc
  }
}

foreach(item, ace_platforms) {
  ace_core_accessibility_ng_source_set("ace_core_accessibility_ng_" + item.name) {
    if (defined(item.config)) {
      config = item.config
    } else {
      config = {
      }
    }

    if (defined(config.defines)) {
      defines = config.defines
    } else {
      defines = []
    }

    if (defined(config.cflags_cc)) {
      cflags_cc = config.cflags_cc
    } else {
      cflags_cc = []
    }
  }
}