# Copyright (c) 2024-2026 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")

ohos_shared_library("cj_request_ffi") {
  sanitize = {
    integer_overflow = true
    ubsan = true
    boundary_sanitize = true
    cfi = true
    cfi_cross_dso = true
    debug = false
  }
  branch_protector_ret = "pac_ret"

  cflags_cc = [ "-fno-exceptions" ]
  cflags = [
    "-Os",
    "-fdata-sections",
    "-ffunction-sections",
    "-fvisibility=hidden",
  ]
  ldflags = [
    "-Wl,--gc-sections",
  ]

  include_dirs = [
    "include",
    "../../../common/include",
    "../../native/request/include",
    "../../js/napi/request/include",
    "../../../common/sys_event/include",
  ]

  deps = [
    "../../native/request:request_native",
    "../../../common/sys_event:request_sysevent"
  ]

  external_deps = [
    "ability_base:zuri",
    "ability_runtime:abilitykit_native",
    "ability_runtime:app_context",
    "ability_runtime:cj_ability_ffi",
    "ability_runtime:data_ability_helper",
    "ability_runtime:napi_base_context",
    "c_utils:utils",
    "ffrt:libffrt",
    "hilog:libhilog",
    "init:libbegetutil",
    "ipc:ipc_single",
    "napi:ace_napi",
    "napi:cj_bind_ffi",
    "napi:cj_bind_native",
    "netmanager_base:net_conn_manager_if",
    "netmanager_base:net_security_config_if",
    "openssl:libcrypto_shared",
    "openssl:libssl_shared",
    "storage_service:storage_manager_acl",
    "hisysevent:libhisysevent",
    "app_file_service:fileuri_native",
    "node:node_header_notice",
  ]

  sources = [
    "src/cj_app_state_callback.cpp",
    "src/cj_failed_listener.cpp",
    "src/cj_initialize.cpp",
    "src/cj_listener_list.cpp",
    "src/cj_notify_data_listener.cpp",
    "src/cj_request_common.cpp",
    "src/cj_request_event.cpp",
    "src/cj_request_ffi.cpp",
    "src/cj_request_impl.cpp",
    "src/cj_request_task.cpp",
    "src/cj_response_listener.cpp",
  ]

  innerapi_tags = [ "platformsdk" ]
  subsystem_name = "request"
  part_name = "request"
}