# Copyright (c) 2023 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_lite/simulator.gni")
import("../gn/config.gni")

config("jsapp_config") {
  cflags = [
    "-std=c++17",
    "-Wall",
    "-Wno-deprecated-declarations",
  ]
  cflags_cc = cflags
}

config("jsapp_config_rich") {
  visibility = [ ":*" ]

  include_dirs = [ "rich" ]
}

ohos_source_set("jsapp_rich") {
  defines = []
  if (platform == "mingw_x86_64" && defined(enable_component_test) &&
      enable_component_test) {
    defines += [ "COMPONENT_TEST_ENABLED" ]
  }
  configs = [ ":jsapp_config" ]
  sources = [
    "JsApp.cpp",
    "rich/JsAppImpl.cpp",
  ]
  include_dirs = [
    ".",
    "rich/",
    "../mock/rich/",
    "../cli/",
    "../util/",
    "../mock/",
    "./external/",
  ]
  include_dirs += os_include_dirs
  deps = [
    "rich/external:ide_extension",
    "//third_party/libwebsockets:websockets_static",
  ]

  external_deps = [
    "ace_engine:libace_compatible",
    "graphic_2d:libglfw_render_context",
    "graphic_2d:librender_service_client",
    "window_manager:previewer_window",
  ]
  if (platform != "linux_x64") {
    external_deps += [ "ability_runtime:ability_simulator" ]
  }
  part_name = "previewer"
  subsystem_name = "ide"
}

ohos_source_set("jsapp_lite") {
  defines = [ "ENABLE_ICU" ]
  if (build_lite_full) {
    defines += [ "LITEWEARABLE_SUPPORTED=1" ]
  }
  configs = [ ":jsapp_config" ]
  configs += [ "//third_party/freetype:freetype_config" ]
  sources = [
    "JsApp.cpp",
    "lite/JsAppImpl.cpp",
    "lite/TimerTaskHandler.cpp",
  ]
  include_dirs = [
    ".",
    "lite/",
    "../mock/lite/",
    "../util/",
    "../mock/",
    "../cli",
    "//foundation/arkui/ui_lite/interfaces/innerkits/",
    "//foundation/arkui/ui_lite/interfaces/kits/",
    "//foundation/graphic/graphic_utils_lite/interfaces/innerkits/",
    "//foundation/graphic/graphic_utils_lite/interfaces/kits/",
    "//foundation/arkui/ui_lite/frameworks/",
    "//foundation/arkui/ui_lite/frameworks/dock/",
    "//foundation/arkui/ui_lite/interfaces/innerkits/dock/",
  ]
  if (build_lite_full) {
    include_dirs += [
      "//base/sensors/sensorjs_lite/sensor_lite/interfaces/js/builtin/sensor/include/",
      "//base/location/interfaces/kits/geo_lite/js/builtin/include/",
    ]
  }
  deps = [
    "//foundation/arkui/ace_engine_lite/frameworks/targets/simulator:ace_lite",
    "//third_party/libwebsockets:websockets_static",
  ]
  part_name = "previewer"
  subsystem_name = "ide"
}