# Copyright (C) 2023 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/arkui/ace_engine/ace_config.gni")
import("//plugins/request/request.gni")

config("task_ios_config") {
  visibility = [ ":*" ]
  include_dirs = [
    "include",
    "$third_party_path/curl/include",
    "$third_party_path/openssl/include",
  ]

  cflags_cc = [ "-fvisibility=default" ]
  cflags = [ "-DOPENSSL_ARM64_PLATFORM" ]

  cflags_objc = [
    "-fvisibility=default",
    "-fobjc-arc",
    "-fobjc-weak",
    "-O0",
    "-w",
  ]
  cflags_objcc = cflags_objc
}

config("task_ios_public_config") {
  visibility = [ ":*" ]
  include_dirs = [
    "$ace_napi",
    "$ace_napi/interfaces/kits",
    "include",
    "$third_party_path/curl/include",
    "$third_party_path/openssl/include",
    "$third_party_path/node/src",
    "$rq_root_path",
    "$rq_utils_path",
    "$plugin_interfaces_path",
    "$rq_task_path/frameworks/native/include",
    "$rq_task_path/frameworks/lib/include",
    "$rq_task_path/utils/include",
  ]
}

ohos_source_set("task_ios") {
  defines = [ "IOS_PLATFORM" ]

  sources = [
    "src/download_proxy.mm",
    "src/ios_adapter.mm",
    "src/ios_net_monitor.mm",
    "src/json_utils.mm",
    "src/upload_proxy.mm",
  ]
  include_dirs = [
    "ohnetworkkit",
    "dbkit",
  ]
  
  frameworks = [
    "UserNotifications.framework",
  ]

  configs = [
    ":task_ios_config",
    "$ace_root:ace_config",
  ]

  deps = [
    "$plugin_interfaces_path/native:plugin_log",
    "$rq_task_path/frameworks/ios/dbkit:ios_dbkit",
    "$rq_task_path/frameworks/ios/ohnetworkkit:ios_ohnetworkkit",
    "//plugins/interfaces/native:ace_plugin_util_ios",
  ]

  defines += [
    "REQUEST_LOG_DOMAIN = 0xD001C00",
    "REQUEST_LOG_TAG = \"RequestNative\"",
  ]

  external_deps = [ "c_utils:utils" ]

  public_configs = [ ":task_ios_public_config" ]
  subsystem_name = "plugins"
  part_name = "request"
}