# Copyright (c) 2021-2021 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("//foundation/multimedia/media_foundation/config.gni")

config("histreamer_foundation_config") {
  include_dirs = [
    "$histreamer_root_dir/interface/foundation",
    "$histreamer_root_dir/foundation",
  ]
  if (hst_is_lite_sys) {
    include_dirs += [
      "$hmultimedia_root_dir/media_utils_lite/interfaces/kits",
      "$hiviewdfx_root_dir/hilog_lite/interfaces/native/innerkits",
    ]
  } else {
    include_dirs +=
        [ "$hiviewdfx_root_dir/hilog/interfaces/native/innerkits/include" ]
  }
}

if (hst_is_lite_sys) {
  source_set("histreamer_foundation") {
    include_dirs = [ "$hiviewdfx_root_dir/hitrace/interfaces/native/innerkits/include/hitrace_meter" ]
    sources = [
      "osal/filesystem/file_system.cpp",
      "osal/thread/condition_variable.cpp",
      "osal/thread/mutex.cpp",
      "osal/thread/scoped_lock.cpp",
      "osal/thread/task.cpp",
      "osal/thread/thread.cpp",
      "osal/utils/util.cpp",
      "utils/constants.cpp",
      "utils/dump_buffer.cpp",
      "utils/hitrace_utils.cpp",
      "utils/steady_clock.cpp",
    ]
    public_configs = [
      ":histreamer_foundation_config",
      "$histreamer_root_dir:histreamer_presets",
    ]
    deps = [ "$multimedia_root_dir/media_utils_lite:media_common" ]
    if (hst_is_mini_sys) {
      deps +=
          [ "$hiviewdfx_root_dir/hilog_lite/frameworks/featured:hilog_static" ]
      public_deps = [ "//third_party/bounds_checking_function:libsec_static" ]
    } else {
      deps +=
          [ "$hiviewdfx_root_dir/hilog_lite/frameworks/featured:hilog_shared" ]
      public_deps = [ "//third_party/bounds_checking_function:libsec_shared" ]
    }

    if (defined(config_ohos_histreamer_stack_size) &&
        config_ohos_histreamer_stack_size > 0) {
      defines = [ "THREAD_STACK_SIZE=$config_ohos_histreamer_stack_size" ]
    }
  }
} else {
  ohos_source_set("histreamer_foundation") {
    subsystem_name = "multimedia"
    part_name = "media_foundation"
    include_dirs = [ "$hiviewdfx_root_dir/hitrace/interfaces/native/innerkits/include/hitrace_meter" ]
    sources = [
      "osal/filesystem/file_system.cpp",
      "osal/thread/condition_variable.cpp",
      "osal/thread/mutex.cpp",
      "osal/thread/scoped_lock.cpp",
      "osal/thread/task.cpp",
      "osal/thread/thread.cpp",
      "osal/utils/util.cpp",
      "utils/constants.cpp",
      "utils/dump_buffer.cpp",
      "utils/hitrace_utils.cpp",
      "utils/steady_clock.cpp",
    ]
    public_configs = [
      ":histreamer_foundation_config",
      "$histreamer_root_dir:histreamer_presets",
    ]
    public_deps = [ "$histreamer_root_dir/plugin:histreamer_plugin_intf" ]
    deps = [ "//third_party/bounds_checking_function:libsec_shared" ]
    external_deps = [
      "graphic_surface:surface",
      "hilog:libhilog",
      "hitrace:hitrace_meter",
    ]

    if (defined(config_ohos_histreamer_stack_size) &&
        config_ohos_histreamer_stack_size > 0) {
      defines = [ "THREAD_STACK_SIZE=$config_ohos_histreamer_stack_size" ]
    }
  }
}