# 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("../windowmanager_aafwk.gni")

config("libdm_private_config") {
  include_dirs = [
    "include",
    "../dm/include",
    "../dmserver/include",
  ]
}

config("libdm_public_config") {
  include_dirs = [
    "../interfaces/innerkits/dm",
    "../interfaces/innerkits/dm_lite",
    "../utils/include",
    "../window_scene/session_manager/include",
    "../wmserver/include",
  ]
}

## Build libdm_lite.so
ohos_shared_library("libdm_lite") {
  branch_protector_ret = "pac_ret"
  sanitize = {
    cfi = true
    cfi_cross_dso = true
    cfi_vcall_icall_only = true
    debug = false
  }
  sources = [
    "../dm/src/zidl/display_manager_agent_stub.cpp",
    "src/display_lite.cpp",
    "src/display_manager_adapter_lite.cpp",
    "src/display_manager_lite.cpp",
    "src/display_manager_lite_proxy.cpp",
    "src/screen_manager_lite.cpp",
  ]

  configs = [
    ":libdm_private_config",
    "../resources/config/build:coverage_flags",
  ]

  public_configs = [ ":libdm_public_config" ]

  deps = [ "${window_base_path}/utils:libwmutil_base" ]

  external_deps = [
    "c_utils:utils",
    "hilog:libhilog",
    "ipc:ipc_single",
    "samgr:samgr_proxy",
  ]

  innerapi_tags = [ "platformsdk" ]
  part_name = "window_manager"
  subsystem_name = "window"

  defines = []
  if (build_variant == "user") {
    defines += [ "IS_RELEASE_VERSION" ]
  }

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

group("test") {
  testonly = true
  if (window_manager_use_sceneboard) {
    deps = [ "test:test" ]
  } else {
    deps = []
  }
}