# Copyright (c) 2022-2024 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/filemanagement/app_file_service/backup.gni")

config("utils_private_config") {
  defines = [
    "LOG_DOMAIN=0xD004305",
    "LOG_TAG=\"BackupUtils\"",
  ]
}

config("utils_public_config") {
  include_dirs = [
    "include",
    "include/b_hilog",
    "${path_base}/include",
  ]
}

ohos_static_library("backup_cxx_cppdeps") {
  branch_protector_ret = "pac_ret"

  sanitize = {
    integer_overflow = true
    ubsan = true
    boundary_sanitize = true
    cfi = true
    cfi_cross_dso = true
    debug = false
  }

  part_name = "app_file_service"
  subsystem_name = "filemanagement"
}

ohos_shared_library("backup_utils") {
  branch_protector_ret = "pac_ret"

  sanitize = {
    integer_overflow = true
    ubsan = true
    boundary_sanitize = true
    cfi = true
    cfi_cross_dso = true
    debug = false
  }

  sources = [
    "src/b_anony/b_anony.cpp",
    "src/b_encryption/b_encryption.cpp",
    "src/b_error/b_error.cpp",
    "src/b_error/b_excep_utils.cpp",
    "src/b_filesystem/b_dir.cpp",
    "src/b_filesystem/b_file.cpp",
    "src/b_filesystem/b_file_hash.cpp",
    "src/b_json/b_json_clear_data_config.cpp",
    "src/b_json/b_json_entity_ext_manage.cpp",
    "src/b_json/b_json_entity_extension_config.cpp",
    "src/b_json/b_json_service_disposal_config.cpp",
    "src/b_json/b_report_entity.cpp",
    "src/b_jsonutil/b_jsonutil.cpp",
    "src/b_ohos/startup/backup_para.cpp",
    "src/b_process/b_guard_cwd.cpp",
    "src/b_process/b_guard_signal.cpp",
    "src/b_process/b_process.cpp",
    "src/b_radar/b_radar.cpp",
    "src/b_sa/b_sa_utils.cpp",
    "src/b_tarball/b_tarball_cmdline.cpp",
    "src/b_tarball/b_tarball_factory.cpp",
    "src/b_utils/b_time.cpp",
  ]

  configs = [ ":utils_private_config" ]
  public_configs = [ ":utils_public_config" ]

  external_deps = [
    "access_token:libaccesstoken_sdk",
    "access_token:libtokenid_sdk",
    "cJSON:cjson",
    "c_utils:utils",
    "faultloggerd:libdfx_dumpcatcher",
    "hilog:libhilog",
    "hisysevent:libhisysevent",
    "hitrace:hitrace_meter",
    "init:libbegetutil",
    "ipc:ipc_core",
  ]

  include_dirs = [
    "${path_init}/interfaces/innerkits/include/syspara",
    "${path_backup}/interfaces/inner_api/native/backup_kit_inner/impl",
    "${path_backup}/utils/include",
  ]

  deps = [
    ":backup_cxx_cppdeps",
    "${path_backup}/interfaces/innerkits/native:sandbox_helper_native",
    "${path_jsoncpp}:jsoncpp",
    "//third_party/openssl:libcrypto_shared",
  ]

  use_exceptions = true
  innerapi_tags = [ "platformsdk" ]
  part_name = "app_file_service"
  subsystem_name = "filemanagement"
}