# Copyright (C) 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("//build/ohos.gni")
import("//foundation/multimedia/media_library/media_library.gni")

ohos_static_library("medialibrary_common_utils") {
  include_dirs = [
    "./include/",
    "${MEDIALIB_INTERFACES_PATH}/inner_api/media_library_helper/include",
    "${MEDIALIB_FACARD_PATH}/include",
    "${MEDIALIB_BUSINESS_PATH}/media_analysis_data_manager/include/dao/table",
  ]

  sources = [ "src/medialibrary_common_utils.cpp" ]

  external_deps = [
    "hilog:libhilog",
    "hitrace:hitrace_meter",
    "openssl:libcrypto_shared",
  ]
  defines = [ "OPENSSL_SUPPRESS_DEPRECATED" ]
  if (!media_library_link_opt) {
    sanitize = {
      cfi = true
      cfi_cross_dso = true
      debug = false
      integer_overflow = true
      ubsan = true
      boundary_sanitize = true
      stack_protector_ret = true
    }
  }
  subsystem_name = "multimedia"
  part_name = "media_library"
}

ohos_static_library("permission_utils") {
  sources = [
    "src/permission_utils.cpp",
    "src/permission_whitelist_utils.cpp",
  ]
  include_dirs = [
    "./include",
    "${MEDIALIB_INNERKITS_PATH}/media_library_helper/include",
    "${MEDIALIB_INTERFACES_PATH}/inner_api/media_library_helper/include",

  ]

  deps = []

  external_deps = [
    "ability_runtime:ability_manager",
    "access_token:el5_filekey_manager_sdk",
    "access_token:libaccesstoken_sdk",
    "access_token:libprivacy_sdk",
    "access_token:libtokenid_sdk",
    "bundle_framework:appexecfwk_core",
    "hilog:libhilog",
    "hitrace:hitrace_meter",
    "init:libbegetutil",
    "ipc:ipc_core",
    "samgr:samgr_proxy",
  ]
  if (!media_library_link_opt) {
    sanitize = {
      cfi = true
      cfi_cross_dso = true
      debug = false
      integer_overflow = true
      ubsan = true
      boundary_sanitize = true
      stack_protector_ret = true
    }
  }
  subsystem_name = "multimedia"
  part_name = "media_library"
}

ohos_static_library("post_event_utils") {
  include_dirs = [
    "./include/",
    "${MEDIALIB_INTERFACES_PATH}/inner_api/media_library_helper/include",
  ]

  sources = [ "src/post_event_utils.cpp" ]

  external_deps = [
    "hilog:libhilog",
    "hisysevent:libhisysevent",
    "ipc:ipc_core",
  ]
  if (!media_library_link_opt) {
    sanitize = {
      cfi = true
      cfi_cross_dso = true
      debug = false
      integer_overflow = true
      ubsan = true
      boundary_sanitize = true
      stack_protector_ret = true
    }
  }
  subsystem_name = "multimedia"
  part_name = "media_library"
}