# Copyright (C) 2021-2022 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_shared_library("media_library_common") {
  install_enable = true

  include_dirs = [
    "${MEDIALIB_COMMON_PATH}/utils/include",
    "${MEDIALIB_ROOT_PATH}/interfaces/inner_api/media_library_helper/include",
    "${MEDIALIB_UTILS_PATH}/include",
  ]

  sources = [
    "${MEDIALIB_COMMON_PATH}/utils/src/media_map_const_utils.cpp",
    "${MEDIALIB_COMMON_PATH}/utils/src/media_string_utils.cpp",
    "${MEDIALIB_COMMON_PATH}/utils/src/media_uri_utils.cpp",
    "${MEDIALIB_COMMON_PATH}/utils/src/media_pure_file_utils.cpp",
    "${MEDIALIB_COMMON_PATH}/utils/src/media_time_utils.cpp",
    "${MEDIALIB_COMMON_PATH}/utils/src/media_path_utils.cpp",
    "${MEDIALIB_COMMON_PATH}/utils/src/madvise_utils.cpp",
  ]

  external_deps = [
    "ability_base:zuri",
    "c_utils:utils",
    "hilog:libhilog",
    "relational_store:native_rdb",
  ]

  defines = []

  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
    }
  }

  cflags = [
    "-Wall",
    "-Werror",
    "-Wno-unused-but-set-variable",
    "-fdata-sections",
    "-ffunction-sections",
    "-Os",
  ]

  cflags_cc = [ "-Os" ]

  part_name = "media_library"
  subsystem_name = "multimedia"
}