# 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")

ohos_executable("backup_tool") {
  branch_protector_ret = "pac_ret"
  sanitize = {
    integer_overflow = true
    cfi = true
    cfi_cross_dso = true
    debug = false
  }

  include_dirs = []
  deps = []
  defines = []
  sources = [ "src/main.cpp" ]

  if (build_variant == "root") {
    include_dirs += [ "include" ]

    defines += [
      "LOG_DOMAIN=0xD004304",
      "LOG_TAG=\"BackupTool\"",
    ]

    deps += [
      "${path_backup}/interfaces/inner_api/native/backup_kit_inner:backup_kit_inner",
      "${path_backup}/utils/:backup_utils",
      "${path_jsoncpp}:jsoncpp",
    ]

    sources += [
      "src/tools_op.cpp",
      "src/tools_op_backup.cpp",
      "src/tools_op_check_sa.cpp",
      "src/tools_op_help.cpp",
      "src/tools_op_incremental_backup.cpp",
      "src/tools_op_incremental_restore.cpp",
      "src/tools_op_incremental_restore_async.cpp",
      "src/tools_op_restore.cpp",
      "src/tools_op_restore_async.cpp",
    ]

    external_deps = [
      "c_utils:utils",
      "hilog:libhilog",
      "hitrace:hitrace_meter",
      "ipc:ipc_core",
    ]

    defines += [ "BACKUP_TOOL_ENABLE=1" ]
  }

  use_exceptions = true
  install_enable = false
  part_name = "app_file_service"
  subsystem_name = "filemanagement"
}