# Copyright (c) 2021-2026 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")
import(
    "//foundation/arkui/ace_engine/adapter/ohos/services/uiservice/uiservicems.gni")
import("//foundation/arkui/ace_engine/build/ace_ext.gni")

config("container_scope_config") {
  visibility = [ ":*" ]
  include_dirs = [
    "$ace_root/frameworks",
    "$ace_root/interfaces/inner_api/ace_kit/include",
  ]
  if (ace_engine_feature_enable_container_scope_tracking) {
    defines = [ "ENABLE_CONTAINER_SCOPE_TRACKING" ]
  }
}

ohos_shared_library("ace_container_scope") {
  public_configs = [ ":container_scope_config" ]

  configs = [ "$ace_root:ace_config" ]
  if (!build_ohos_sdk) {
    defines = [ "NAPI_SCOPE_ERROR_HIVEW_REPORT" ]
  }

  sources = [ "$ace_root/frameworks/core/common/container_scope.cpp" ]

  subsystem_name = ace_engine_subsystem
  innerapi_tags = [ "platformsdk_indirect" ]
  part_name = ace_engine_part

  if (is_ohos && is_clang && target_cpu == "arm64" && defined(build_ext_path)) {
    ldflags = [
      "-Wl,--emit-relocs",
      "-Wl,--no-relax",
      "-mno-fix-cortex-a53-843419",
    ]
  }
  if (ace_engine_feature_enable_container_scope_tracking) {
    external_deps = [ "bounds_checking_function:libsec_static" ]
  }
}

ohos_static_library("ace_container_scope_static") {
  public_configs = [ ":container_scope_config" ]

  configs = [ "$ace_root:ace_config" ]

  sources = [ "$ace_root/frameworks/core/common/container_scope.cpp" ]

  if (ace_engine_feature_enable_container_scope_tracking) {
    external_deps = [ "bounds_checking_function:libsec_static" ]
  }
}

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

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

    if (ace_engine_feature_enable_nav_split_mode &&
        defined(
            vendor_configs.ace_engine_advanced_navigation_split_mode_dirs)) {
      include_dirs +=
          vendor_configs.ace_engine_advanced_navigation_split_mode_dirs
    }

    if (ace_engine_enable_circle_feature &&
        defined(
            vendor_configs.ace_engine_advanced_navigation_circle_mode_dirs)) {
      include_dirs +=
          vendor_configs.ace_engine_advanced_navigation_circle_mode_dirs
    }

    if (ace_engine_enable_circle_feature &&
        defined(vendor_configs.ace_engine_advanced_router_circle_mode_dirs)) {
      include_dirs += vendor_configs.ace_engine_advanced_router_circle_mode_dirs
    }

    # add common source file needed by all product platform here
    sources = [
      # accessibility
      "accessibility/accessibility_manager_ng.cpp",
      "accessibility/accessibility_node.cpp",
      "accessibility/accessibility_session_adapter.cpp",
      "accessibility/accessibility_utils.cpp",
      "accessibility/native_interface_accessibility_impl.cpp",
      "accessibility/native_interface_accessibility_provider.cpp",
      "accessibility/static/accessibility_static_utils.cpp",

      # animation
      "animation/animatable_data.cpp",
      "animation/animatable_properties.cpp",
      "animation/animation_pub.cpp",
      "animation/animation_util.cpp",
      "animation/animator.cpp",
      "animation/animator_group.cpp",
      "animation/anticipate_curve.cpp",
      "animation/bilateral_spring_adapter.cpp",
      "animation/bilateral_spring_node.cpp",
      "animation/card_transition_controller.cpp",
      "animation/chain_animation.cpp",
      "animation/cubic_curve.cpp",
      "animation/curves.cpp",
      "animation/friction_motion.cpp",
      "animation/property_animation.cpp",
      "animation/scheduler.cpp",
      "animation/scroll_motion.cpp",
      "animation/shared_transition_controller.cpp",
      "animation/shared_transition_effect.cpp",
      "animation/simple_spring_adapter.cpp",
      "animation/simple_spring_chain.cpp",
      "animation/simple_spring_node.cpp",
      "animation/spring_animation.cpp",
      "animation/spring_curve.cpp",
      "animation/spring_model.cpp",
      "animation/spring_motion.cpp",
      "animation/svg_animate.cpp",

      # common
      "common/ace_application_info.cpp",
      "common/ace_engine.cpp",
      "common/ace_engine_ext.cpp",
      "common/agingadapation/aging_adapation_dialog_util.cpp",
      "common/anr_thread.cpp",
      "common/asset_manager_impl.cpp",
      "common/back_press_handler_manager.cpp",
      "common/builder_util.cpp",
      "common/card_scope.cpp",
      "common/clipboard/clipboard_proxy.cpp",
      "common/color_inverter.cpp",
      "common/container.cpp",
      "common/container_scope.cpp",
      "common/environment/environment_proxy.cpp",
      "common/event_dump.cpp",
      "common/event_manager.cpp",
      "common/event_manager_pen.cpp",
      "common/focus_animation_manager.cpp",
      "common/font_loader.cpp",
      "common/font_manager.cpp",
      "common/frontend.cpp",
      "common/input_event_monitor_manager.cpp",
      "common/interaction/interaction_data.cpp",
      "common/key_event_manager.cpp",
      "common/multi_thread_build_manager.cpp",
      "common/platform_bridge.cpp",
      "common/platform_res_register.cpp",
      "common/premake_scope.cpp",
      "common/render_boundary_manager.cpp",
      "common/resource/pattern_resource_manager.cpp",
      "common/resource/resource_manager.cpp",
      "common/resource/resource_parse_utils.cpp",
      "common/resource/resource_wrapper.cpp",
      "common/sharedata/share_data.cpp",
      "common/statistic_event_reporter.cpp",
      "common/storage/storage_proxy.cpp",
      "common/task_executor_impl.cpp",
      "common/task_runner_adapter_factory.cpp",
      "common/task_runner_adapter_impl.cpp",
      "common/task_runners.cpp",
      "common/text_field_manager.cpp",
      "common/thread_checker.cpp",
      "common/thread_container.cpp",
      "common/thread_model_impl.cpp",
      "common/vibrator/vibrator_proxy.cpp",
      "common/visual_effect/transparency_utils.cpp",
      "common/visual_effect/component_material_interaction.cpp",
      "common/watch_dog.cpp",
      "common/window.cpp",

      # declaration
      "components/declaration/button/button_declaration.cpp",
      "components/declaration/common/declaration.cpp",
      "components/declaration/common/declaration_constants.cpp",
      "components/declaration/common/declaration_creator_manager.cpp",
      "components/declaration/common/event.cpp",
      "components/declaration/div/div_declaration.cpp",
      "components/declaration/richtext/rich_text_declaration.cpp",
      "components/declaration/side_bar/side_bar_declaration.cpp",
      "components/declaration/span/span_declaration.cpp",
      "components/declaration/text/text_declaration.cpp",
      "components/declaration/texttimer/texttimer_declaration.cpp",
      "components/declaration/web/web_declaration.cpp",
      "components/declaration/xcomponent/xcomponent_declaration.cpp",

      # gestures
      "gestures/click_recognizer.cpp",
      "gestures/drag_event.cpp",
      "gestures/drag_recognizer.cpp",
      "gestures/exclusive_recognizer.cpp",
      "gestures/gesture_recognizer.cpp",
      "gestures/gesture_referee.cpp",
      "gestures/long_press_recognizer.cpp",
      "gestures/multi_fingers_recognizer.cpp",
      "gestures/pan_recognizer.cpp",
      "gestures/parallel_recognizer.cpp",
      "gestures/pinch_recognizer.cpp",
      "gestures/press_recognizer.cpp",
      "gestures/raw_recognizer.cpp",
      "gestures/rotation_recognizer.cpp",
      "gestures/sequenced_recognizer.cpp",
      "gestures/single_child_gesture.cpp",
      "gestures/slide_recognizer.cpp",
      "gestures/swipe_recognizer.cpp",
      "gestures/timeout_recognizer.cpp",
      "gestures/velocity_tracker.cpp",

      # declarative
      "gestures/gesture_group.cpp",
      "gestures/gesture_event.cpp",
      "gestures/long_press_gesture.cpp",
      "gestures/pan_gesture.cpp",
      "gestures/pinch_gesture.cpp",
      "gestures/rotation_gesture.cpp",
      "gestures/slide_gesture.cpp",
      "gestures/tap_gesture.cpp",
      "gestures/timeout_gesture.cpp",

      # event
      "event/axis_event.cpp",
      "event/back_end_event_manager.cpp",
      "event/coasting_axis_event_generator.cpp",
      "event/key_event.cpp",
      "event/key_event_recognizer.cpp",
      "event/mouse_event.cpp",
      "event/mouse_raw_recognizer.cpp",
      "event/resample_algo.cpp",
      "event/touch_event.cpp",

      # focus
      "focus/focus_node.cpp",

      # image
      "image/animated_image_player.cpp",
      "image/image_cache.cpp",
      "image/image_compressor.cpp",
      "image/image_file_cache.cpp",
      "image/image_loader.cpp",
      "image/image_object.cpp",
      "image/image_object_animated.cpp",
      "image/image_object_svg.cpp",
      "image/image_provider.cpp",
      "image/image_source_info.cpp",

      # textfield
      "common/ime/text_editing_value.cpp",
      "common/ime/text_input_action.cpp",
      "common/ime/text_input_client.cpp",
      "common/ime/text_input_configuration.cpp",
      "common/ime/text_input_connection.cpp",
      "common/ime/text_input_formatter.cpp",
      "common/ime/text_input_proxy.cpp",
      "common/ime/text_input_type.cpp",

      # recorder
      "common/recorder/event_config.cpp",
      "common/recorder/event_controller.cpp",
      "common/recorder/event_recorder.cpp",
      "common/recorder/exposure_processor.cpp",
      "common/recorder/inspector_tree_collector.cpp",
      "common/recorder/node_data_cache.cpp",

      # text
      "text/text_emoji_processor.cpp",

      # force split
      "common/force_split/force_split_utils.cpp",

      # drawable
      "drawable/animated_drawable_descriptor.cpp",
      "drawable/drawable_descriptor.cpp",
      "drawable/drawable_descriptor_info.cpp",
      "drawable/drawable_descriptor_loader.cpp",
      "drawable/layered_drawable_descriptor.cpp",
      "drawable/picture_drawable_descriptor.cpp",
      "drawable/pixel_map_drawable_descriptor.cpp",

      # list
      "components/list/list_compatible_modifier_helper.cpp",

      # refresh
      "components/refresh/render_refresh_target.cpp",
    ]

    if (defined(config.relaxed_interaction_support) &&
        config.relaxed_interaction_support) {
      sources += [
        # relaxed interaction
        "components_ng/relaxed_interaction/base_executor.cpp",
        "components_ng/relaxed_interaction/executor_choreographer.cpp",
        "components_ng/relaxed_interaction/executor_generator.cpp",
        "components_ng/relaxed_interaction/executors/backpress_executor.cpp",
        "components_ng/relaxed_interaction/executors/fallback_executor.cpp",
        "components_ng/relaxed_interaction/executors/scroll_simulating_executor.cpp",
        "components_ng/relaxed_interaction/executors/scroll_touch_executor.cpp",
        "components_ng/relaxed_interaction/executors/simulate_touch_executor.cpp",
        "components_ng/relaxed_interaction/executors/smart_gesture_executor.cpp",
        "components_ng/relaxed_interaction/executors/strict_click_executor.cpp",
        "components_ng/relaxed_interaction/executors/strict_content_switch_executor.cpp",
        "components_ng/relaxed_interaction/frame_node_finder.cpp",
        "components_ng/relaxed_interaction/parsers/backpress_command_parser.cpp",
        "components_ng/relaxed_interaction/parsers/click_command_parser.cpp",
        "components_ng/relaxed_interaction/parsers/content_switch_command_parser.cpp",
        "components_ng/relaxed_interaction/parsers/fallback_command_parser.cpp",
        "components_ng/relaxed_interaction/parsers/scroll_command_parser.cpp",
        "components_ng/relaxed_interaction/parsers/slide_command_parser.cpp",
        "components_ng/relaxed_interaction/parsers/tap_command_parser.cpp",
        "components_ng/relaxed_interaction/relaxed_interaction_manager.cpp",
        "components_ng/relaxed_interaction/utils/json_utils.cpp",
        "components_ng/relaxed_interaction/utils/relaxed_event_factory.cpp",
        "components_ng/relaxed_interaction/utils/workflow_dumper.cpp",
      ]
    }

    if (platform == "ohos" || platform == "ohos_ng") {
      sources -= [ "common/anr_thread.cpp" ]
    }

    # add sources needed by phone and TV. wearable like watch do not need them
    if (!is_wearable_product) {
      sources += [
        "event/multimodal/multimodal_manager.cpp",
        "event/multimodal/multimodal_scene.cpp",
      ]
    }

    # add sources needed by phone, tv and wearable. previews do not need them
    if (defined(config.connect_server_support) &&
        config.connect_server_support) {
      if (use_ios) {
        include_dirs += [ "$ark_toolchain_path" ]
      }
      sources += [ "common/connect_server_manager.cpp" ]
    }

    if (defined(config.hdc_register_support) && config.hdc_register_support) {
      sources += [ "common/hdc_register.cpp" ]
    }

    if (ohos_indep_compiler_enable) {
      include_dirs += indep_compile_includes
    }

    configs = [ "$ace_root:ace_config" ]

    deps = [
      "pipeline:ace_core_pipeline_$platform",
      "pipeline_ng:ace_core_pipeline_ng_$platform",
    ]

    external_deps = []
    if (!ace_engine_feature_enable_event_extra_handling) {
      sources += [ "event/event_info_convertor.cpp" ]
    }

    if (ace_engine_feature_enable_long_press_gesture_extra_handling && defined(
            vendor_configs.ace_engine_advanced_enable_long_press_gesture_extra_handling)) {
      sources += vendor_configs.ace_engine_advanced_enable_long_press_gesture_extra_handling
      external_deps += vendor_configs.ace_engine_advanced_enable_long_press_gesture_extra_handling_deps
    } else {
      sources +=
          [ "components_ng/gestures/recognizers/gestures_extra_handler.cpp" ]
    }

    if (use_hilog) {
      external_deps += [ "hilog:libhilog" ]
    }
    if (defined(config.build_for_preview) && config.build_for_preview) {
      sources -= [ "common/task_runner_adapter_impl.cpp" ]
    }

    deps += [
      "$ace_root/frameworks/core/components/ability_component:ace_core_components_ability_$platform",
      "$ace_root/frameworks/core/components/align:ace_core_components_align_$platform",
      "$ace_root/frameworks/core/components/arc:ace_core_components_arc_$platform",
      "$ace_root/frameworks/core/components/box:ace_core_components_box_$platform",
      "$ace_root/frameworks/core/components/bubble:ace_core_components_bubble_$platform",
      "$ace_root/frameworks/core/components/button:ace_core_components_button_$platform",
      "$ace_root/frameworks/core/components/calendar:ace_core_components_calendar_$platform",
      "$ace_root/frameworks/core/components/checkable:ace_core_components_checkable_$platform",
      "$ace_root/frameworks/core/components/clip:ace_core_components_clip_$platform",
      "$ace_root/frameworks/core/components/common:ace_core_components_common_$platform",
      "$ace_root/frameworks/core/components/container_modal:ace_core_components_container_modal_$platform",
      "$ace_root/frameworks/core/components/counter:ace_core_components_counter_$platform",
      "$ace_root/frameworks/core/components/coverage:ace_core_components_coverage_$platform",
      "$ace_root/frameworks/core/components/custom_dialog:ace_core_components_custom_dialog_$platform",
      "$ace_root/frameworks/core/components/data_panel:ace_core_components_data_panel_$platform",
      "$ace_root/frameworks/core/components/dialog:ace_core_components_dialog_$platform",
      "$ace_root/frameworks/core/components/dialog_modal:ace_core_components_dialog_modal_$platform",
      "$ace_root/frameworks/core/components/dialog_tween:ace_core_components_dialog_tween_$platform",
      "$ace_root/frameworks/core/components/display:ace_core_components_display_$platform",
      "$ace_root/frameworks/core/components/divider:ace_core_components_divider_$platform",
      "$ace_root/frameworks/core/components/drag_bar:ace_core_components_drag_bar_$platform",
      "$ace_root/frameworks/core/components/drop_filter:ace_core_components_drop_filter_$platform",
      "$ace_root/frameworks/core/components/flex:ace_core_components_flex_$platform",
      "$ace_root/frameworks/core/components/focus_animation:ace_core_components_focus_animation_$platform",
      "$ace_root/frameworks/core/components/focus_collaboration:ace_core_components_focus_collaboration_$platform",
      "$ace_root/frameworks/core/components/focusable:ace_core_components_focusable_$platform",
      "$ace_root/frameworks/core/components/font:ace_core_components_font_$platform",
      "$ace_root/frameworks/core/components/foreach:ace_core_components_foreach_$platform",
      "$ace_root/frameworks/core/components/gesture_listener:ace_core_components_gesture_listener_$platform",
      "$ace_root/frameworks/core/components/grid:ace_core_components_grid_$platform",
      "$ace_root/frameworks/core/components/grid_layout:ace_core_components_grid_layout_$platform",
      "$ace_root/frameworks/core/components/hyperlink:ace_core_components_hyperlink_$platform",
      "$ace_root/frameworks/core/components/ifelse:ace_core_components_ifelse_$platform",
      "$ace_root/frameworks/core/components/image:ace_core_components_image_$platform",
      "$ace_root/frameworks/core/components/indexer:ace_core_components_indexer_$platform",
      "$ace_root/frameworks/core/components/menu:ace_core_components_menu_$platform",
      "$ace_root/frameworks/core/components/mouse_listener:ace_core_components_mouse_listener_$platform",
      "$ace_root/frameworks/core/components/navigation_bar:ace_core_components_navigation_bar_$platform",
      "$ace_root/frameworks/core/components/swiper:ace_core_components_swiper_$platform",
      "$ace_root/frameworks/core/components/tab_bar:ace_core_components_tab_bar_$platform",
      "$ace_root/frameworks/core/components/navigator:ace_core_components_navigator_$platform",
      "$ace_root/frameworks/core/components/option:ace_core_components_option_$platform",
      "$ace_root/frameworks/core/components/overlay:ace_core_components_overlay_$platform",
      "$ace_root/frameworks/core/components/padding:ace_core_components_padding_$platform",
      "$ace_root/frameworks/core/components/page:ace_core_components_page_$platform",
      "$ace_root/frameworks/core/components/page_transition:ace_core_components_page_transition_$platform",
      "$ace_root/frameworks/core/components/panel:ace_core_components_panel_$platform",
      "$ace_root/frameworks/core/components/positioned:ace_core_components_positioned_$platform",
      "$ace_root/frameworks/core/components/progress:ace_core_components_progress_$platform",
      "$ace_root/frameworks/core/components/proxy:ace_core_components_proxy_$platform",
      "$ace_root/frameworks/core/components/relative_container:ace_core_components_relative_container_$platform",
      "$ace_root/frameworks/core/components/root:ace_core_components_root_$platform",
      "$ace_root/frameworks/core/components/scoring:ace_core_components_scoring_$platform",
      "$ace_root/frameworks/core/components/scroll:ace_core_components_scroll_$platform",
      "$ace_root/frameworks/core/components/scroll_bar:ace_core_components_scroll_bar_$platform",
      "$ace_root/frameworks/core/components/select_popup:ace_core_components_select_popup_$platform",
      "$ace_root/frameworks/core/components/semi_modal:ace_core_components_semi_modal_$platform",
      "$ace_root/frameworks/core/components/shadow:ace_core_components_shadow_$platform",
      "$ace_root/frameworks/core/components/shape:ace_core_components_shape_$platform",
      "$ace_root/frameworks/core/components/shared_transition:ace_core_components_shared_transition_$platform",
      "$ace_root/frameworks/core/components/sheet:ace_core_components_sheet_$platform",
      "$ace_root/frameworks/core/components/side_bar:ace_core_components_side_bar_$platform",
      "$ace_root/frameworks/core/components/slider:ace_core_components_slider_$platform",
      "$ace_root/frameworks/core/components/split_container:ace_core_components_split_container_$platform",
      "$ace_root/frameworks/core/components/stack:ace_core_components_stack_$platform",
      "$ace_root/frameworks/core/components/stage:ace_core_components_stage_$platform",
      "$ace_root/frameworks/core/components/text:ace_core_components_text_$platform",
      "$ace_root/frameworks/core/components/text_clock:ace_core_components_text_clock_$platform",
      "$ace_root/frameworks/core/components/text_span:ace_core_components_text_span_$platform",
      "$ace_root/frameworks/core/components/texttimer:ace_core_components_texttimer_$platform",
      "$ace_root/frameworks/core/components/theme:ace_core_components_theme_$platform",
      "$ace_root/frameworks/core/components/tip:ace_core_components_tip_$platform",
      "$ace_root/frameworks/core/components/toast:ace_core_components_toast_$platform",
      "$ace_root/frameworks/core/components/touch_listener:ace_core_components_touch_listener_$platform",
      "$ace_root/frameworks/core/components/track:ace_core_components_track_$platform",
      "$ace_root/frameworks/core/components/transform:ace_core_components_transform_$platform",
      "$ace_root/frameworks/core/components/transition:ace_core_components_transition_$platform",
      "$ace_root/frameworks/core/components/triangle:ace_core_components_triangle_$platform",
      "$ace_root/frameworks/core/components/tween:ace_core_components_tween_$platform",
      "$ace_root/frameworks/core/components/watch_slider:ace_core_components_watch_slider_$platform",
      "$ace_root/frameworks/core/components/wrap:ace_core_components_wrap_$platform",
    ]

    deps += [
      "$ace_root/frameworks/core/components_v2/common:ace_core_components_common_v2_$platform",
      "$ace_root/frameworks/core/components_v2/foreach:ace_core_components_foreach_v2_$platform",
      "$ace_root/frameworks/core/components_v2/grid:ace_core_components_grid_v2_$platform",
      "$ace_root/frameworks/core/components_v2/grid_layout:ace_core_components_grid_layout_v2_$platform",
      "$ace_root/frameworks/core/components_v2/indexer:ace_core_components_indexer_v2_$platform",
      "$ace_root/frameworks/core/components_v2/inspector:ace_core_components_inspector_v2_$platform",
      "$ace_root/frameworks/core/components_v2/pattern_lock:ace_core_components_pattern_lock_$platform",
      "$ace_root/frameworks/core/components_v2/water_flow:ace_core_components_water_flow_v2_$platform",
    ]

    deps += [ "$ace_root/frameworks/core/components_part_upd/foreach:ace_core_components_foreach_part_upd_$platform" ]

    deps += [
      "$ace_root/frameworks/core/components_ng/animation:ace_core_components_animation_ng_$platform",
      "$ace_root/frameworks/core/components_ng/base:ace_core_components_base_ng_$platform",
      "$ace_root/frameworks/core/components_ng/event:ace_core_components_event_ng_$platform",
      "$ace_root/frameworks/core/components_ng/gestures:ace_core_components_gestures_ng_$platform",
      "$ace_root/frameworks/core/components_ng/image_provider:ace_core_components_image_provider_ng_$platform",
      "$ace_root/frameworks/core/components_ng/layout:ace_core_components_layout_ng_$platform",
      "$ace_root/frameworks/core/components_ng/manager:ace_core_components_manager_ng_$platform",
      "$ace_root/frameworks/core/components_ng/pattern:ace_core_components_pattern_ng_$platform",
      "$ace_root/frameworks/core/components_ng/property:ace_core_components_property_ng_$platform",
      "$ace_root/frameworks/core/components_ng/render:ace_core_components_render_ng_$platform",
      "$ace_root/frameworks/core/components_ng/svg:ace_core_components_svg_ng_$platform",
      "$ace_root/frameworks/core/components_ng/syntax:ace_core_components_syntax_ng_$platform",
      "$ace_root/frameworks/core/components_ng/token_theme:ace_core_components_token_theme_ng_$platform",
    ]

    deps += [
      "$ace_root/frameworks/core/components_ng/pattern/rich_editor:ace_core_components_rich_editor_pattern_ng_$platform",
      "$ace_root/frameworks/core/components_ng/pattern/security_component:ace_core_components_security_component_pattern_ng_$platform",
      "$ace_root/frameworks/core/components_ng/pattern/text_field:ace_core_components_text_field_pattern_ng_$platform",
    ]

    deps += [ "$ace_root/frameworks/core/accessibility:ace_core_accessibility_ng_$platform" ]

    if (qrcodegen_support) {
      deps += [ "$ace_root/frameworks/core/components_ng/pattern/qrcode:ace_core_components_qrcode_pattern_ng_$platform" ]
    }

    if (defined(config.model_component_support) &&
        config.model_component_support) {
      deps += [ "$ace_root/frameworks/core/components_ng/pattern/model:ace_core_components_model_pattern_ng_$platform" ]
    }

    if (defined(config.enable_ability_component) &&
        config.enable_ability_component) {
      deps += [ "$ace_root/frameworks/core/components_ng/pattern/ability_component:ace_core_components_ability_component_pattern_ng_$platform" ]
    }
    if (defined(config.enable_image_compression) &&
        config.enable_image_compression) {
      external_deps += [ "opencl-headers:libcl" ]
      defines += [ "ENABLE_OPENCL" ]
    }

    if (ace_engine_feature_enable_upgrade_skia) {
      defines += [ "USE_NEW_SKIA" ]
    }

    if (current_os == "mingw" || current_os == "mac") {
      sources -= [ "common/watch_dog.cpp" ]
      sources += [ "common/watch_dog_mingw.cpp" ]
    }

    if (defined(config.enable_rosen_backend) && config.enable_rosen_backend) {
      sources += [
        "animation/native_curve_helper.cpp",
        "common/rosen/rosen_convert_helper.cpp",
      ]
      if (is_ohos) {
        defines += [ "TEXGINE_SUPPORT_FOR_OHOS" ]
      }
      if (is_arkui_x) {
        deps += [ "//foundation/graphic/graphic_2d/rosen/modules/render_service_client:librender_service_client_static" ]
        include_dirs += [
          "//foundation/graphic/graphic_2d/utils/color_manager/export",
          "//foundation/multimedia/image_framework/interfaces/innerkits/include",
        ]
      } else {
        if (ace_use_rosen_drawing) {
          external_deps += [ "graphic_2d:2d_graphics" ]
        }
        external_deps += [
          "graphic_2d:librender_service_client",
          "graphic_2d:rosen_text",
        ]
      }
    }

    if (!use_mingw_win && !use_mac && !is_wearable_product &&
        !is_ohos_standard_system && !use_linux) {
      deps += [ "$ace_root/frameworks/core/components/rich_text:ace_core_components_rich_text_$platform" ]
    }

    if (defined(config.web_components_support) &&
        config.web_components_support && !is_arkui_x) {
      deps += [
        "$ace_root/frameworks/core/components/text_overlay:ace_core_components_text_overlay_for_web_$platform",
        "$ace_root/frameworks/core/components/web:ace_core_components_web_$platform",
        "$ace_root/frameworks/core/components_ng/pattern/web:ace_core_components_web_pattern_ng_$platform",
      ]
    } else {
      deps += [ "$ace_root/frameworks/core/components/text_overlay:ace_core_components_text_overlay_$platform" ]
    }

    # xcomponent components supports phone, TV and wearable except PC Preview
    if (defined(config.xcomponent_components_support) &&
        config.xcomponent_components_support) {
      deps += [ "$ace_root/frameworks/core/components/xcomponent:ace_core_components_xcomponent_$platform" ]
      deps += [ "$ace_root/frameworks/core/components_ng/pattern/xcomponent:ace_core_components_xcomponent_pattern_ng_$platform" ]
    }

    if (defined(config.enable_ability_component) &&
        config.enable_ability_component) {
      deps += [ "$ace_root/frameworks/core/components_v2/ability_component:ace_core_components_ability_v2_$platform" ]
    }

    if (defined(config.form_components_support) &&
        config.form_components_support) {
      if (!use_mingw_win && !use_mac && !use_linux) {
        sources += [ "common/form_manager.cpp" ]
        deps += [
          "$ace_root/frameworks/core/components/form:ace_core_components_form_$platform",
          "$ace_root/frameworks/core/components_ng/pattern/form:ace_core_components_form_pattern_ng_$platform",
        ]
        external_deps += [
          "ability_base:base",
          "ability_base:want",
          "form_fwk:form_common_info",
          "form_fwk:form_render_info",
          "form_fwk:form_utils",
        ]
      }
    }

    if (defined(config.remote_window_support) && config.remote_window_support) {
      if (!use_mingw_win && !use_mac && !use_linux) {
        deps += [
          "$ace_root/frameworks/core/components/remote_window:ace_core_components_remote_window_$platform",
          "$ace_root/frameworks/core/components_ng/pattern/remote_window:ace_core_components_remote_window_pattern_ng_$platform",
        ]
      }
    }

    if (defined(config.build_container_scope_lib) &&
        config.build_container_scope_lib) {
      sources -= [ "common/container_scope.cpp" ]
      if (is_arkui_x) {
        deps += [ ":ace_container_scope_static" ]
      } else {
        deps += [ ":ace_container_scope" ]
      }
    }

    if (defined(config.plugin_components_support) &&
        config.plugin_components_support) {
      deps += [
        "$ace_root/frameworks/core/components/plugin:ace_core_components_plugin_$platform",
        "$ace_root/frameworks/core/components_ng/pattern/plugin:ace_core_components_plugin_pattern_ng_$platform",
      ]
      sources += [ "common/plugin_manager.cpp" ]
      external_deps += [ "c_utils:utils" ]
    }

    if (defined(config.preview_support) && config.preview_support) {
      deps += [ "$ace_root/frameworks/core/components_ng/pattern/preview_mock:ace_core_components_preview_mock_pattern_ng_$platform" ]
    }

    if (is_arkui_x) {
      include_dirs += [
        "//foundation/appframework/ability/ability_runtime/cross_platform/frameworks/native/base/event_handler/include",
        "//foundation/appframework/ability/ability_runtime/cross_platform/interfaces/inner_api/error",
        "//foundation/graphic/graphic_2d/utils/color_manager/export",
        "//foundation/multimedia/image_framework/interfaces/innerkits/include",
      ]
    }
    if (!is_wearable_product) {
      deps += [
        "$ace_root/frameworks/core/components/multimodal:ace_core_components_multimodal_$platform",
        "$ace_root/frameworks/core/components/popup:ace_core_components_popup_$platform",
        "$ace_root/frameworks/core/components/select:ace_core_components_select_$platform",
      ]
    }

    if ((current_os == "mingw" || current_os == "mac" ||
         current_os == "linux") && defined(config.enable_rosen_backend) &&
        config.enable_rosen_backend) {
      sources += [
        # rs impl
        "common/rosen/rosen_asset_manager.cpp",
        "common/rosen/rosen_window.cpp",
      ]
      include_dirs +=
          [ "//foundation/window/window_manager/interfaces/innerkits/wm" ]
      external_deps += [ "libuv:uv" ]
    }

    if (defined(config.window_scene_support) && config.window_scene_support) {
      defines += [ "WINDOW_SCENE_SUPPORTED" ]
      deps += [
        "$ace_root/frameworks/core/components_ng/pattern/ui_extension:ace_core_components_ui_extension_pattern_ng_$platform",
        "$ace_root/frameworks/core/components_ng/pattern/window_scene:ace_core_components_window_scene_$platform",
      ]
    }

    if (defined(config.use_platform_font) && config.use_platform_font) {
      defines += [ "USE_PLATFORM_FONT" ]
      sources += [ "common/font/font_platform_proxy.cpp" ]
    }

    if (defined(ffrt_support) && ffrt_support) {
      defines += [ "FFRT_SUPPORT" ]
      external_deps += [ "ffrt:libffrt" ]
    }

    if (defined(global_parts_info) && defined(global_parts_info.hiviewdfx_api_metrics)) {
      external_deps += [ "api_metrics:histogrammanager" ]
      defines += [ "ACE_ENGINE_API_METRICS_EXT_ENABLE" ]
    }

    # arkoala C interface
    deps += [ "$ace_root/frameworks/core/interfaces/native:ace_core_interfaces_native_node_$platform" ]
    deps += [ "$ace_root/frameworks/core/interfaces/native/common:ace_core_interfaces_native_$platform" ]

    cflags_cc = []
    cflags_cc += invoker.cflags_cc
  }
}

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

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

    # add common source file needed by all product platform here
    sources = [
      # accessibility
      "accessibility/accessibility_manager_ng.cpp",
      "accessibility/accessibility_node.cpp",
      "accessibility/accessibility_session_adapter.cpp",
      "accessibility/accessibility_utils.cpp",
      "accessibility/native_interface_accessibility_impl.cpp",
      "accessibility/native_interface_accessibility_provider.cpp",
      "accessibility/static/accessibility_static_utils.cpp",

      # animation
      "animation/animatable_data.cpp",
      "animation/animatable_properties.cpp",
      "animation/animation_pub.cpp",
      "animation/animation_util.cpp",
      "animation/animator.cpp",
      "animation/animator_group.cpp",
      "animation/anticipate_curve.cpp",
      "animation/bilateral_spring_adapter.cpp",
      "animation/bilateral_spring_node.cpp",
      "animation/chain_animation.cpp",
      "animation/cubic_curve.cpp",
      "animation/curves.cpp",
      "animation/friction_motion.cpp",
      "animation/property_animation.cpp",
      "animation/scheduler.cpp",
      "animation/scroll_motion.cpp",
      "animation/simple_spring_adapter.cpp",
      "animation/simple_spring_chain.cpp",
      "animation/simple_spring_node.cpp",
      "animation/spring_animation.cpp",
      "animation/spring_curve.cpp",
      "animation/spring_model.cpp",
      "animation/spring_motion.cpp",
      "animation/svg_animate.cpp",

      # common
      "common/ace_application_info.cpp",
      "common/ace_engine.cpp",
      "common/ace_engine_ext.cpp",
      "common/agingadapation/aging_adapation_dialog_util.cpp",
      "common/anr_thread.cpp",
      "common/asset_manager_impl.cpp",
      "common/back_press_handler_manager.cpp",
      "common/builder_util.cpp",
      "common/card_scope.cpp",
      "common/clipboard/clipboard_proxy.cpp",
      "common/color_inverter.cpp",
      "common/container.cpp",
      "common/container_scope.cpp",
      "common/environment/environment_proxy.cpp",
      "common/event_dump.cpp",
      "common/event_manager.cpp",
      "common/event_manager_pen.cpp",
      "common/focus_animation_manager.cpp",
      "common/font_loader.cpp",
      "common/font_manager.cpp",
      "common/frontend.cpp",
      "common/input_event_monitor_manager.cpp",
      "common/interaction/interaction_data.cpp",
      "common/key_event_manager.cpp",
      "common/multi_thread_build_manager.cpp",
      "common/platform_bridge.cpp",
      "common/platform_res_register.cpp",
      "common/premake_scope.cpp",
      "common/render_boundary_manager.cpp",
      "common/resource/pattern_resource_manager.cpp",
      "common/resource/resource_manager.cpp",
      "common/resource/resource_parse_utils.cpp",
      "common/resource/resource_wrapper.cpp",
      "common/sharedata/share_data.cpp",
      "common/statistic_event_reporter.cpp",
      "common/storage/storage_proxy.cpp",
      "common/task_executor_impl.cpp",
      "common/task_runner_adapter_factory.cpp",
      "common/task_runner_adapter_impl.cpp",
      "common/task_runners.cpp",
      "common/text_field_manager.cpp",
      "common/thread_checker.cpp",
      "common/thread_container.cpp",
      "common/thread_model_impl.cpp",
      "common/vibrator/vibrator_proxy.cpp",
      "common/visual_effect/transparency_utils.cpp",
      "common/visual_effect/component_material_interaction.cpp",
      "common/watch_dog.cpp",
      "common/window.cpp",

      # event
      "event/axis_event.cpp",
      "event/back_end_event_manager.cpp",
      "event/coasting_axis_event_generator.cpp",
      "event/key_event.cpp",
      "event/key_event_recognizer.cpp",
      "event/mouse_event.cpp",
      "event/mouse_raw_recognizer.cpp",
      "event/resample_algo.cpp",
      "event/touch_event.cpp",

      # gestures
      "gestures/click_recognizer.cpp",
      "gestures/drag_event.cpp",
      "gestures/drag_recognizer.cpp",
      "gestures/exclusive_recognizer.cpp",
      "gestures/gesture_recognizer.cpp",
      "gestures/gesture_referee.cpp",
      "gestures/long_press_recognizer.cpp",
      "gestures/multi_fingers_recognizer.cpp",
      "gestures/pan_recognizer.cpp",
      "gestures/parallel_recognizer.cpp",
      "gestures/pinch_recognizer.cpp",
      "gestures/press_recognizer.cpp",
      "gestures/raw_recognizer.cpp",
      "gestures/rotation_recognizer.cpp",
      "gestures/sequenced_recognizer.cpp",
      "gestures/single_child_gesture.cpp",
      "gestures/slide_recognizer.cpp",
      "gestures/swipe_recognizer.cpp",
      "gestures/timeout_recognizer.cpp",
      "gestures/velocity_tracker.cpp",

      # declarative gestures
      "gestures/gesture_group.cpp",
      "gestures/gesture_event.cpp",
      "gestures/long_press_gesture.cpp",
      "gestures/pan_gesture.cpp",
      "gestures/pinch_gesture.cpp",
      "gestures/rotation_gesture.cpp",
      "gestures/slide_gesture.cpp",
      "gestures/tap_gesture.cpp",
      "gestures/timeout_gesture.cpp",

      # pipeline
      "pipeline/base/constants.cpp",
      "pipeline/base/element_register.cpp",
      "pipeline/base/element_register_multi_thread.cpp",
      "pipeline/base/related_node.cpp",
      "pipeline/base/rosen_render_context.cpp",
      "pipeline/container_window_manager.cpp",
      "pipeline/pipeline_base.cpp",

      # image
      "image/animated_image_player.cpp",
      "image/image_cache.cpp",
      "image/image_compressor.cpp",
      "image/image_file_cache.cpp",
      "image/image_loader.cpp",
      "image/image_object.cpp",
      "image/image_object_animated.cpp",
      "image/image_object_svg.cpp",
      "image/image_provider.cpp",
      "image/image_source_info.cpp",

      # textfield
      "common/ime/text_editing_value.cpp",
      "common/ime/text_input_action.cpp",
      "common/ime/text_input_client.cpp",
      "common/ime/text_input_configuration.cpp",
      "common/ime/text_input_connection.cpp",
      "common/ime/text_input_formatter.cpp",
      "common/ime/text_input_proxy.cpp",
      "common/ime/text_input_type.cpp",

      # properties
      "components/common/painter/border_image_painter.cpp",
      "components/common/painter/rosen_decoration_painter.cpp",
      "components/common/properties/alignment.cpp",
      "components/common/properties/animatable_color.cpp",
      "components/common/properties/border.cpp",
      "components/common/properties/border_edge.cpp",
      "components/common/properties/border_image.cpp",
      "components/common/properties/clip_path.cpp",
      "components/common/properties/color.cpp",
      "components/common/properties/decoration.cpp",
      "components/common/properties/edge.cpp",
      "components/common/properties/motion_path_evaluator.cpp",
      "components/common/properties/os_content.cpp",
      "components/common/properties/shadow.cpp",
      "components/common/properties/shadow_config.cpp",
      "components/common/properties/text_enums.cpp",
      "components/common/properties/text_style.cpp",
      "components/common/properties/text_style_gradient.cpp",
      "components/common/properties/text_style_parser.cpp",
      "components/common/properties/ui_material.cpp",

      # layout
      "components/common/layout/common_text_constants.cpp",
      "components/common/layout/grid_column_info.cpp",
      "components/common/layout/grid_container_info.cpp",
      "components/common/layout/grid_system_manager.cpp",
      "components/common/layout/layout_constants_string_utils.cpp",
      "components/common/layout/screen_system_manager.cpp",

      # v1 deps
      "$root_out_dir/arkui/framework/core/components/theme/theme_constants_default.cpp",
      "$root_out_dir/arkui/framework/core/components/theme/theme_constants_tv.cpp",
      "components/button/button_theme.cpp",
      "components/checkable/checkable_theme.cpp",
      "components/common/painter/rosen_svg_painter.cpp",
      "components/dialog/dialog_theme.cpp",
      "components/font/constants_converter.cpp",
      "components/navigation_bar/navigation_bar_theme.cpp",
      "components/swiper/swiper_indicator_theme.cpp",
      "components/tab_bar/tab_theme.cpp",
      "components/font/font_loader_creator.cpp",
      "components/font/font_manager_creator.cpp",
      "components/font/rosen_font_collection.cpp",
      "components/font/rosen_font_loader.cpp",
      "components/font/rosen_font_manager.cpp",
      "components/panel/sliding_events.cpp",
      "components/rating/rating_theme.cpp",
      "components/scroll/scrollable.cpp",
      "components/slider/slider_theme.cpp",
      "components/theme/app_theme.cpp",
      "components/theme/blur_style_theme.cpp",
      "components/theme/icon_theme.cpp",
      "components/theme/shadow_theme.cpp",
      "components/theme/theme_attributes.cpp",
      "components/theme/theme_constants.cpp",
      "components/theme/theme_manager_impl.cpp",
      "components/theme/theme_manager_multi_thread.cpp",
      "components/theme/theme_utils.cpp",
      "components/theme/ui_material_theme.cpp",
      "components/toggle/toggle_theme.cpp",
      "components/text/text_theme.cpp",

      # v2 inspector
      "components_v2/grid/grid_event.cpp",
      "components_v2/grid_layout/grid_container_utils.cpp",
      "components_v2/inspector/inspector_constants.cpp",
      "components_v2/inspector/utils.cpp",

      #declaration
      "components/declaration/common/declaration.cpp",

      # recorder
      "common/recorder/event_config.cpp",
      "common/recorder/event_controller.cpp",
      "common/recorder/event_recorder.cpp",
      "common/recorder/exposure_processor.cpp",
      "common/recorder/inspector_tree_collector.cpp",
      "common/recorder/node_data_cache.cpp",

      # text
      "text/text_emoji_processor.cpp",

      # force split
      "common/force_split/force_split_utils.cpp",

      # drawable
      "drawable/animated_drawable_descriptor.cpp",
      "drawable/drawable_descriptor.cpp",
      "drawable/drawable_descriptor_info.cpp",
      "drawable/drawable_descriptor_loader.cpp",
      "drawable/layered_drawable_descriptor.cpp",
      "drawable/picture_drawable_descriptor.cpp",
      "drawable/pixel_map_drawable_descriptor.cpp",
    ]

    if (defined(config.relaxed_interaction_support) &&
        config.relaxed_interaction_support) {
      sources += [
        # relaxed interaction
        "components_ng/relaxed_interaction/base_executor.cpp",
        "components_ng/relaxed_interaction/executor_choreographer.cpp",
        "components_ng/relaxed_interaction/executor_generator.cpp",
        "components_ng/relaxed_interaction/executors/backpress_executor.cpp",
        "components_ng/relaxed_interaction/executors/fallback_executor.cpp",
        "components_ng/relaxed_interaction/executors/scroll_simulating_executor.cpp",
        "components_ng/relaxed_interaction/executors/scroll_touch_executor.cpp",
        "components_ng/relaxed_interaction/executors/simulate_touch_executor.cpp",
        "components_ng/relaxed_interaction/executors/smart_gesture_executor.cpp",
        "components_ng/relaxed_interaction/executors/strict_click_executor.cpp",
        "components_ng/relaxed_interaction/executors/strict_content_switch_executor.cpp",
        "components_ng/relaxed_interaction/frame_node_finder.cpp",
        "components_ng/relaxed_interaction/parsers/backpress_command_parser.cpp",
        "components_ng/relaxed_interaction/parsers/click_command_parser.cpp",
        "components_ng/relaxed_interaction/parsers/content_switch_command_parser.cpp",
        "components_ng/relaxed_interaction/parsers/fallback_command_parser.cpp",
        "components_ng/relaxed_interaction/parsers/scroll_command_parser.cpp",
        "components_ng/relaxed_interaction/parsers/slide_command_parser.cpp",
        "components_ng/relaxed_interaction/parsers/tap_command_parser.cpp",
        "components_ng/relaxed_interaction/relaxed_interaction_manager.cpp",
        "components_ng/relaxed_interaction/utils/json_utils.cpp",
        "components_ng/relaxed_interaction/utils/relaxed_event_factory.cpp",
        "components_ng/relaxed_interaction/utils/workflow_dumper.cpp",
      ]
    }

    include_dirs = [ "$ace_root" ]
    if (is_arkui_x) {
      include_dirs += [
        "//foundation/appframework/ability/ability_runtime/cross_platform/frameworks/native/base/event_handler/include",
        "//foundation/appframework/ability/ability_runtime/cross_platform/interfaces/inner_api/error",
        "//foundation/graphic/graphic_2d/utils/color_manager/export",
        "//foundation/multimedia/image_framework/interfaces/innerkits/include",
      ]
      sources -= [ "components/declaration/common/declaration.cpp" ]
      sources += [
        "animation/card_transition_controller.cpp",
        "components/common/properties/animatable_path.cpp",
        "components/common/properties/border_image_edge.cpp",
        "components/common/properties/color_factory.cpp",
        "components/common/properties/page_transition_option.cpp",
        "components/common/properties/scroll_bar.cpp",
        "components/declaration/common/event.cpp",
      ]
    }

    if (platform == "ohos" || platform == "ohos_ng") {
      sources -= [ "common/anr_thread.cpp" ]
    }

    configs = [ "$ace_root:ace_config" ]

    deps = [
      "$ace_root/frameworks/core/components/theme:build_theme_code",
      "pipeline_ng:ace_core_pipeline_ng_$platform",
    ]

    if (defined(config.build_for_preview) && config.build_for_preview) {
      sources -= [ "common/task_runner_adapter_impl.cpp" ]
    }

    external_deps = []
    if (defined(ffrt_support) && ffrt_support) {
      defines += [ "FFRT_SUPPORT" ]
      external_deps += [ "ffrt:libffrt" ]
    }

    if (!ace_engine_feature_enable_event_extra_handling) {
      sources += [ "event/event_info_convertor.cpp" ]
    }

    if (ace_engine_feature_enable_long_press_gesture_extra_handling && defined(
            vendor_configs.ace_engine_advanced_enable_long_press_gesture_extra_handling)) {
      sources += vendor_configs.ace_engine_advanced_enable_long_press_gesture_extra_handling
      external_deps += vendor_configs.ace_engine_advanced_enable_long_press_gesture_extra_handling_deps
    } else {
      sources +=
          [ "components_ng/gestures/recognizers/gestures_extra_handler.cpp" ]
    }
    if (use_hilog) {
      external_deps += [ "hilog:libhilog" ]
    }
    if (defined(config.remote_window_support) && config.remote_window_support) {
      if (!use_mingw_win && !use_mac && !use_linux) {
        deps += [ "$ace_root/frameworks/core/components_ng/pattern/remote_window:ace_core_components_remote_window_pattern_ng_$platform" ]
      }
    }

    if (defined(config.build_container_scope_lib) &&
        config.build_container_scope_lib) {
      sources -= [ "common/container_scope.cpp" ]
      if (is_arkui_x) {
        deps += [ ":ace_container_scope_static" ]
      } else {
        deps += [ ":ace_container_scope" ]
      }
    }
    deps += [
      "$ace_root/frameworks/core/components_ng/animation:ace_core_components_animation_ng_$platform",
      "$ace_root/frameworks/core/components_ng/base:ace_core_components_base_ng_$platform",
      "$ace_root/frameworks/core/components_ng/event:ace_core_components_event_ng_$platform",
      "$ace_root/frameworks/core/components_ng/gestures:ace_core_components_gestures_ng_$platform",
      "$ace_root/frameworks/core/components_ng/image_provider:ace_core_components_image_provider_ng_$platform",
      "$ace_root/frameworks/core/components_ng/layout:ace_core_components_layout_ng_$platform",
      "$ace_root/frameworks/core/components_ng/manager:ace_core_components_manager_ng_$platform",
      "$ace_root/frameworks/core/components_ng/pattern:ace_core_components_pattern_ng_$platform",
      "$ace_root/frameworks/core/components_ng/pattern/rich_editor:ace_core_components_rich_editor_pattern_ng_$platform",
      "$ace_root/frameworks/core/components_ng/pattern/text_field:ace_core_components_text_field_pattern_ng_$platform",
      "$ace_root/frameworks/core/components_ng/property:ace_core_components_property_ng_$platform",
      "$ace_root/frameworks/core/components_ng/render:ace_core_components_render_ng_$platform",
      "$ace_root/frameworks/core/components_ng/svg:ace_core_components_svg_ng_$platform",
      "$ace_root/frameworks/core/components_ng/syntax:ace_core_components_syntax_ng_$platform",
      "$ace_root/frameworks/core/components_ng/token_theme:ace_core_components_token_theme_ng_$platform",
    ]

    deps += [ "$ace_root/frameworks/core/accessibility:ace_core_accessibility_ng_$platform" ]

    if (defined(config.use_components_lib) && config.use_components_lib) {
      deps += [ "$ace_root/frameworks/core/components_ng/common_napi_utils:ace_core_components_common_napi_utils_$platform" ]
    } else {
      if (qrcodegen_support) {
        deps += [ "$ace_root/frameworks/core/components_ng/pattern/qrcode:ace_core_components_qrcode_pattern_ng_$platform" ]
      }
    }

    if (defined(config.enable_ability_component) &&
        config.enable_ability_component) {
      deps += [ "$ace_root/frameworks/core/components_ng/pattern/ability_component:ace_core_components_ability_component_pattern_ng_$platform" ]
    }
    if (defined(config.window_scene_support) && config.window_scene_support) {
      deps += [ "$ace_root/frameworks/core/components_ng/pattern/ui_extension:ace_core_components_ui_extension_pattern_ng_$platform" ]
    }
    if (defined(config.web_components_support) &&
        config.web_components_support) {
      if (!is_arkui_x) {
        deps += [ "$ace_root/frameworks/core/components_ng/pattern/web:ace_core_components_web_pattern_ng_$platform" ]
        sources += [
          "components/web/resource/web_client_impl.cpp",
          "components/web/resource/web_configuration_observer.cpp",
          "components/web/resource/web_delegate.cpp",
          "components/web/resource/web_javascript_execute_callback.cpp",
          "components/web/resource/web_javascript_result_callback.cpp",
          "components/web/resource/web_resource.cpp",
          "components/web/web_component.cpp",
        ]

        external_deps += [
          "ability_runtime:abilitykit_native",
          "ability_runtime:app_context",
          "ability_runtime:app_manager",
          "c_utils:utils",
          "init:libbegetutil",
          "ipc:ipc_core",
          "napi:ace_napi",
          "webview:cj_webview_ffi",
          "webview:libnweb",
          "webview:ohos_base_glue_source",
          "window_manager:libwm",
        ]
        if (defined(global_parts_info) &&
            defined(global_parts_info.web_webview)) {
          external_deps += [ "webview:libarkweb_utils" ]
        }
      } else {
        deps += [ "$ace_root/frameworks/core/components_ng/pattern/web:ace_core_components_web_pattern_ng_$platform" ]
      }
    }
    if (defined(config.window_scene_support) && config.window_scene_support) {
      deps += [ "$ace_root/frameworks/core/components_ng/pattern/ui_extension:ace_core_components_ui_extension_pattern_ng_$platform" ]
    }

    if (defined(config.form_components_support) &&
        config.form_components_support) {
      if (!use_mingw_win && !use_mac && !use_linux) {
        deps += [ "$ace_root/frameworks/core/components_ng/pattern/form:ace_core_components_form_pattern_ng_$platform" ]
      }
    }
    if (defined(config.enable_rosen_backend) && config.enable_rosen_backend) {
      sources += [
        "animation/native_curve_helper.cpp",
        "common/rosen/rosen_convert_helper.cpp",
      ]
      if (is_ohos) {
        defines += [ "TEXGINE_SUPPORT_FOR_OHOS" ]
      }
      if (is_arkui_x) {
        deps += [
          "//foundation/graphic/graphic_2d/frameworks/text:rosen_text",
          "//foundation/graphic/graphic_2d/rosen/modules/2d_graphics:2d_graphics_source_$platform",
          "//foundation/graphic/graphic_2d/rosen/modules/render_service_client:librender_service_client_static",
        ]
      } else {
        external_deps += [ "graphic_2d:librender_service_client" ]
        if (ace_use_rosen_drawing) {
          external_deps += [ "graphic_2d:2d_graphics" ]
        }
      }
    }
    if (defined(config.window_scene_support) && config.window_scene_support) {
      defines += [ "WINDOW_SCENE_SUPPORTED" ]
      deps += [
        "$ace_root/frameworks/core/components_ng/pattern/ui_extension:ace_core_components_ui_extension_pattern_ng_$platform",
        "$ace_root/frameworks/core/components_ng/pattern/window_scene:ace_core_components_window_scene_$platform",
      ]
    }

    if (defined(config.xcomponent_components_support) &&
        config.xcomponent_components_support) {
      deps += [ "$ace_root/frameworks/core/components_ng/pattern/xcomponent:ace_core_components_xcomponent_pattern_ng_$platform" ]
    }

    # add sources needed by phone, tv and wearable. previews do not need them
    if (defined(config.connect_server_support) &&
        config.connect_server_support) {
      if (use_ios) {
        include_dirs += [ "$ark_toolchain_path" ]
      }
      sources += [ "common/connect_server_manager.cpp" ]
    }

    if (defined(config.hdc_register_support) && config.hdc_register_support) {
      sources += [ "common/hdc_register.cpp" ]
    }

    if (defined(config.plugin_components_support) &&
        config.plugin_components_support) {
      deps += [ "$ace_root/frameworks/core/components_ng/pattern/plugin:ace_core_components_plugin_pattern_ng_$platform" ]
      sources += [ "common/plugin_manager.cpp" ]
      external_deps += [ "c_utils:utils" ]
    }

    deps += [ "$ace_root/frameworks/core/components_ng/pattern/security_component:ace_core_components_security_component_pattern_ng_$platform" ]

    if (defined(config.model_component_support) &&
        config.model_component_support) {
      deps += [ "$ace_root/frameworks/core/components_ng/pattern/model:ace_core_components_model_pattern_ng_$platform" ]
    }

    if (defined(config.enable_image_compression) &&
        config.enable_image_compression) {
      external_deps += [ "opencl-headers:libcl" ]
      defines += [ "ENABLE_OPENCL" ]
    }

    if (ace_engine_feature_enable_upgrade_skia) {
      defines += [ "USE_NEW_SKIA" ]
    }

    if (defined(config.use_platform_font) && config.use_platform_font) {
      defines += [ "USE_PLATFORM_FONT" ]
      sources += [ "common/font/font_platform_proxy.cpp" ]
    }

    if (defined(global_parts_info) && defined(global_parts_info.hiviewdfx_api_metrics)) {
      external_deps += [ "api_metrics:histogrammanager" ]
      defines += [ "ACE_ENGINE_API_METRICS_EXT_ENABLE" ]
    }

    cflags_cc = []
    cflags_cc += invoker.cflags_cc
  }
}

foreach(item, ace_platforms) {
  ace_core_source_set("ace_core_" + item.name) {
    platform = 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 = []
    }
  }

  ace_core_ng_source_set("ace_core_ng_" + item.name) {
    platform = 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 = []
    }
  }
}