# 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("//drivers/peripheral/distributed_camera/distributedcamera.gni")

ohos_shared_library("libdistributed_camera_provider_config") {
  sanitize = {
    boundary_sanitize = true
    cfi = true
    cfi_cross_dso = true
    debug = false
    integer_overflow = true
    ubsan = true
  }
  include_dirs =
      [ "${distributedcamera_hdf_path}/hdi_service/include/dcamera_provider" ]
  sources = [ "./src/config/dcamera_provider_config.cpp" ]
  deps = [ "${distributedcamera_hdf_path}/hdi_service:libdistributed_camera_hdf_service_1.1" ]

  ldflags = [
    "-fpie",
    "-Wl,-z,relro",
    "-Wl,-z,now",
  ]

  external_deps = [
    "cJSON:cjson",
    "c_utils:utils",
    "drivers_interface_camera:libbuffer_producer_sequenceable_1.0",
    "drivers_interface_distributed_camera:libdistributed_camera_provider_stub_1.1",
    "graphic_surface:surface",
    "hdf_core:libhdf_host",
    "hdf_core:libhdf_ipc_adapter",
    "hdf_core:libhdf_utils",
    "hdf_core:libhdi",
    "hilog:libhilog",
    "ipc:ipc_single",
  ]

  shlib_type = "hdi"
  install_images = [ chipset_base_dir ]
  subsystem_name = "hdf"
  part_name = "drivers_peripheral_distributed_camera"
}

ohos_shared_library("libdistributed_camera_host_config") {
  sanitize = {
    boundary_sanitize = true
    cfi = true
    cfi_cross_dso = true
    debug = false
    integer_overflow = true
    ubsan = true
  }
  include_dirs = [
    "${distributedcamera_hdf_path}/hdi_service/include/dcamera_device",
    "${distributedcamera_hdf_path}/hdi_service/include/dcamera_host",
    "${distributedcamera_hdf_path}/hdi_service/include/dstream_operator",
    "${distributedcamera_hdf_path}/hdi_service/include/utils",
  ]
  sources = [ "./src/config/dcamera_host_config.cpp" ]
  deps = [ "${distributedcamera_hdf_path}/hdi_service:libdistributed_camera_hdf_service_1.1" ]
  ldflags = [
    "-fpie",
    "-Wl,-z,relro",
    "-Wl,-z,now",
  ]
  external_deps = [
    "cJSON:cjson",
    "c_utils:utils",
    "drivers_interface_camera:libbuffer_producer_sequenceable_1.0",
    "drivers_interface_camera:libcamera_stub_1.3",
    "drivers_interface_camera:metadata",
    "drivers_interface_display:libdisplay_composer_hdi_impl_1.3",
    "drivers_interface_display:libdisplay_composer_proxy_1.0",
    "drivers_interface_distributed_camera:libdistributed_camera_provider_stub_1.1",
    "graphic_surface:buffer_handle",
    "graphic_surface:surface",
    "graphic_surface:sync_fence",
    "hdf_core:libhdf_host",
    "hdf_core:libhdf_ipc_adapter",
    "hdf_core:libhdf_utils",
    "hdf_core:libhdi",
    "hilog:libhilog",
    "ipc:ipc_single",
  ]

  shlib_type = "hdi"
  install_images = [ chipset_base_dir ]
  subsystem_name = "hdf"
  part_name = "drivers_peripheral_distributed_camera"
}

ohos_shared_library("libdistributed_camera_hdf_service_1.1") {
  sanitize = {
    boundary_sanitize = true
    cfi = true
    cfi_cross_dso = true
    debug = false
    integer_overflow = true
    ubsan = true
  }
  include_dirs = [
    "include/dcamera_device",
    "include/dcamera_host",
    "include/dcamera_provider",
    "include/dstream_operator",
    "include/utils",
  ]

  sources = [
    "src/dcamera_device/dcamera_device.cpp",
    "src/dcamera_device/dmetadata_processor.cpp",
    "src/dcamera_host/dcamera_host.cpp",
    "src/dcamera_provider/dcamera_provider.cpp",
    "src/dstream_operator/dbuffer_manager.cpp",
    "src/dstream_operator/dcamera_stream.cpp",
    "src/dstream_operator/dimage_buffer.cpp",
    "src/dstream_operator/doffline_stream_operator.cpp",
    "src/dstream_operator/dstream_operator.cpp",
    "src/utils/anonymous_string.cpp",
    "src/utils/dcamera.cpp",
  ]

  defines = [
    "HI_LOG_ENABLE",
    "DH_LOG_TAG=\"distributedcamerahdf\"",
    "LOG_DOMAIN=0xD004150",
  ]

  ldflags = [
    "-fpie",
    "-Wl,-z,relro",
    "-Wl,-z,now",
  ]

  external_deps = [
    "cJSON:cjson",
    "c_utils:utils",
    "drivers_interface_camera:libbuffer_producer_sequenceable_1.0",
    "drivers_interface_camera:libcamera_stub_1.3",
    "drivers_interface_camera:metadata",
    "drivers_interface_display:libdisplay_composer_hdi_impl_1.3",
    "drivers_interface_display:libdisplay_composer_proxy_1.0",
    "drivers_interface_distributed_camera:libdistributed_camera_provider_stub_1.1",
    "graphic_surface:buffer_handle",
    "graphic_surface:surface",
    "graphic_surface:sync_fence",
    "hdf_core:libhdf_host",
    "hdf_core:libhdf_ipc_adapter",
    "hdf_core:libhdf_utils",
    "hdf_core:libhdi",
    "hilog:libhilog",
    "ipc:ipc_single",
    "samgr:samgr_proxy",
  ]

  install_images = [ chipset_base_dir ]
  subsystem_name = "hdf"
  part_name = "drivers_peripheral_distributed_camera"
}

group("hdf_distributed_camera_service") {
  deps = [
    ":libdistributed_camera_hdf_service_1.1",
    ":libdistributed_camera_host_config",
    ":libdistributed_camera_provider_config",
  ]
}