# 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("//base/update/updater/updater_default_cfg.gni")
import("//build/ohos.gni")

updater_path = rebase_path("${updater_absolutely_path}", ".")
config("updater_ui_support_cfg") {
  include_dirs = [
    "${updater_path}/interfaces/kits/include",
    "${updater_path}/services/ui",
    "${updater_path}/services/ui/include",
    "${updater_path}/services/ui/control",
    "${updater_path}/services/ui/driver",
    "${updater_path}/services/ui/view",
    "${updater_path}/services/ui/language",
  ]
  defines = [
    "ENABLE_BITMAP_FONT = 0",
    "ENABLE_ICU = 1",
    "ENABLE_MULTI_FONT = 0",
    "ENABLE_SHAPING = 0",
    "ENABLE_STATIC_FONT = 0",
    "ENABLE_VECTOR_FONT = 1",
  ]
  if (updater_ui_support) {
    defines += [ "UPDATER_UI_SUPPORT" ]
  }
}

ohos_static_library("libui_driver") {
  public_configs = [ ":updater_ui_support_cfg" ]

  sources = [
    "driver/drm_driver.cpp",
    "driver/fbdev_driver.cpp",
    "driver/graphic_engine.cpp",
    "driver/input_event.cpp",
    "driver/keys_input_device.cpp",
    "driver/pointers_input_device.cpp",
    "driver/surface_dev.cpp",
    "driver/ui_rotation.cpp",
  ]

  include_dirs = [
    "${updater_path}/services/common",
    "${updater_path}/services/include/log",
    "${updater_path}/services/include",
    "${updater_path}/utils/include",
    "${updater_path}/services",
    "${updater_path}/interfaces/kits/include",
    "${updater_path}/services/ui",
    "${updater_path}/services/ui/include",
    "${updater_path}/services/ui/driver",
  ]

  deps = [
    "${updater_path}/services/log:libupdaterlog",
    "${updater_path}/utils:libutils",
  ]

  external_deps = [
    "bounds_checking_function:libsec_static",
    "c_utils:utils",
    "libdrm:libdrm",
    "libpng:libpng",
  ]

  if (!updater_ui_support) {
    sources = []
  } else {
    external_deps += [
      "drivers_interface_input:libinput_proxy_1.0",
      "ui_lite:libupdater_layout",
      "graphic_utils_lite:utils_lite",
    ]
  }

  subsystem_name = "updater"
  part_name = "updater"
}

ohos_static_library("libui") {
  public_configs = [ ":updater_ui_support_cfg" ]

  sources = [
    "control/callback_manager.cpp",
    "control/event_listener.cpp",
    "control/event_manager.cpp",
    "language/language_ui.cpp",
    "strategy/background_strategy.cpp",
    "strategy/logo_strategy.cpp",
    "strategy/progress_strategy.cpp",
    "strategy/ui_strategy.cpp",
    "updater_ui_config.cpp",
    "updater_ui_env.cpp",
    "updater_ui_facade.cpp",
    "updater_ui_tools.cpp",
    "view/component/box_progress_adapter.cpp",
    "view/component/img_view_adapter.cpp",
    "view/component/label_btn_adapter.cpp",
    "view/component/text_label_adapter.cpp",
    "view/component/component_register.cpp",
    "view/layout/auto_layout.cpp",
    "view/layout/layout_parser.cpp",
    "view/page/base_page.cpp",
    "view/page/page.cpp",
    "view/page/page_manager.cpp",
    "view/page/sub_page.cpp",
    "view/view_api.cpp",
  ]

  include_dirs = [
    "${updater_path}/services/common",
    "${updater_path}/services/include/log",
    "${updater_path}/services/include",
    "${updater_path}/utils/include",
    "${updater_path}/utils/json",
    "${updater_path}/services",
    "${updater_path}/interfaces/kits/include",
    "${updater_path}/services/ui",
    "${updater_path}/services/ui/include",
    "${updater_path}/services/ui/control",
    "${updater_path}/services/ui/driver",
    "${updater_path}/services/ui/view",
    "${updater_path}/services/ui/language",
  ]

  deps = [
    "${updater_path}/interfaces/kits/packages:libpackageExt",
    "${updater_path}/services/log:libupdaterlog",
    "${updater_path}/utils:libutils",
  ]

  external_deps = [
    "bounds_checking_function:libsec_static",
    "cJSON:cjson",
    "c_utils:utils",
    "libdrm:libdrm",
    "libpng:libpng",
  ]

  if (!updater_ui_support) {
    sources = []
  } else {
    external_deps += [
      "drivers_interface_input:libinput_proxy_1.0",
      "ui_lite:libupdater_layout",
      "graphic_utils_lite:utils_lite",
    ]
  }

  subsystem_name = "updater"
  part_name = "updater"
}