# Copyright (C) 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("//base/update/updater/updater_default_cfg.gni")
import("//build/ohos.gni")

updater_path = rebase_path("${updater_absolutely_path}", ".")

config("libupdater_patch_config") {
  visibility = [ ":*" ]
  include_dirs = [ "//base/update/updater/services/diffpatch/patch_shared" ]
}

ohos_shared_library("libupdater_patch_shared") {
  defines = [ "UPDATE_PATCH_SHARED" ]
  sources = [
    "${updater_path}/services/diffpatch/patch_shared/patch_shared.cpp",
    "${updater_path}/services/updater_binary/update_image_block.cpp",
    "${updater_path}/services/updater_binary/update_image_patch.cpp",
    "${updater_path}/services/updater_binary/update_partitions.cpp",
    "${updater_path}/services/updater_binary/update_processor.cpp",
  ]
  include_dirs = [
    "${updater_path}/services",
    "${updater_path}/services/common",
    "${updater_path}/services/flow_update",
    "${updater_path}/services/include/applypatch",
  ]

  ldflags = [ "-Wl -std=c++11" ]
  deps = [
    "${updater_path}/interfaces/kits/misc_info:libmiscinfo",
    "${updater_path}/interfaces/kits/slot_info:libslotinfo",
    "${updater_path}/services/flow_update/update_bin:libBinFlowUpdate",
    "${updater_path}/services/fs_manager:libfsmanager",
    "${updater_path}/services/log:libupdaterlog",
    "${updater_path}/services/package:libupdaterpackage",
    "${updater_path}/services/script:libupdaterscript",
  ]

  external_deps = [
    "bounds_checking_function:libsec_shared",
    "cJSON:cjson_static",
    "init:libbegetutil_static",
    "init:libfsmanager_static_real",
    "openssl:libssl_static",
  ]

  output_extension = "so"
  install_enable = false
  subsystem_name = "updater"
  part_name = "updater"
}

ohos_static_library("libupdater_patch_static") {
  defines = [ "UPDATE_PATCH_STATIC" ]
  sources = [
    "${updater_path}/services/diffpatch/patch_shared/patch_shared.cpp",
    "${updater_path}/services/updater_binary/update_image_block.cpp",
    "${updater_path}/services/updater_binary/update_image_patch.cpp",
    "${updater_path}/services/updater_binary/update_partitions.cpp",
    "${updater_path}/services/updater_binary/update_processor.cpp",
  ]
  include_dirs = [
    "${updater_path}/services",
    "${updater_path}/services/common",
    "${updater_path}/services/flow_update",
    "${updater_path}/services/include/applypatch",
  ]

  ldflags = [ "-Wl -std=c++11" ]
  deps = [
    "${updater_path}/interfaces/kits/misc_info:libmiscinfo",
    "${updater_path}/interfaces/kits/slot_info:libslotinfo",
    "${updater_path}/services/flow_update/update_bin:libBinFlowUpdate",
    "${updater_path}/services/fs_manager:libfsmanager",
    "${updater_path}/services/log:libupdaterlog",
    "${updater_path}/services/package:libupdaterpackage",
    "${updater_path}/services/script:libupdaterscript",
  ]

  external_deps = [
    "bounds_checking_function:libsec_shared",
    "cJSON:cjson",
    "hilog:libhilog",
    "init:libbegetutil_static",
    "init:libfsmanager_static_real",
    "openssl:libcrypto_static",
  ]

  public_configs = [ ":libupdater_patch_config" ]
  subsystem_name = "updater"
  part_name = "updater"
}