# Copyright (c) 2022-2025 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")

common_plugin_libs = [
  "ability_access_ctrl",
  "accessibility",
  "arkui/advanced/dialog",
  "arkui/advanced/segmentbutton",
  "arkui/advanced/subheader",
  "arkui/advanced/toolbar",
  "arkui/advanced/counter",
  "arkui/advanced/filter",
  "arkui/advanced/progressbutton",
  "arkui/advanced/splitlayout",
  "arkui/advanced/popup",
  "arkui/advanced/treeview",
  "arkui/advanced/chip",
  "arkui/advanced/editabletitlebar",
  "arkui/advanced/tabtitlebar",
  "arkui/advanced/foldsplitcontainer",
  "arkui/advanced/exceptionprompt",
  "arkui/advanced/gridobjectsortcomponent",
  "arkui/advanced/chipgroup",
  "arkui/mock",
  "arkui/modifier",
  "bluetooth/access",
  "bluetooth/baseprofile",
  "bluetooth/ble",
  "bluetooth/connection",
  "bluetooth/a2dp",
  "bridge",
  "file/fs",
  "file/hash",
  "file/streamhash",
  "file/statvfs",
  "file/photo_access_helper",
  "file/picker",
  "file/streamrw",
  "common_event_manager",
  "data/datasharepredicates",
  "data/distributedkvstore",
  "data/preferences",
  "pasteboard",
  "data/relationalstore",
  "data/unifieddatachannel",
  "data/uniformtypedescriptor",
  "device_info",
  "display",
  "hitrace_meter",
  "i18n",
  "intl",
  "multimedia/media",
  "multimedia/audio",
  "net/connection",
  "net/http",
  "net/socket",
  "net/websocket",
  "worker",
  "request",
  "buffer",
  "fastbuffer",
  "geo_location_manager",
  "convertxml",
  "process",
  "system_date_time",
  "uitest",
  "uri",
  "url",
  "xml",
  "util",
  "util/arraylist",
  "util/deque",
  "util/hashmap",
  "util/hashset",
  "util/lightweightmap",
  "util/lightweightset",
  "util/linkedlist",
  "util/list",
  "util/plainarray",
  "util/queue",
  "util/stack",
  "util/treemap",
  "util/treeset",
  "util/json",
  "util/stream",
  "hilog",
  "taskpool",
  "test_plugin",
  "timer",
  "console",
  "web/webview",
  "zlib",
  "security/cryptoframework",
  "security/cert",
  "events/emitter",
  "wifi_manager",
  "notification_manager",
  "effectkit",
  "arkui/node",
  "arkui/shape",
  "multimodalinput/keycode",
  "arkts/collections",
  "arkts/utils",
  "arkts/math/decimal",
  "hiviewdfx/hiappevent",
  "arkui/advanced/swiperefresher",
  "arkui/advanced/composelistitem",
  "arkui/advanced/composetitlebar",
  "arkui/advanced/selecttitlebar",
  "arkui/advanced/selectionmenu",
  "vibrator",
  "graphics/text",
]

template("plugin_lib") {
  forward_variables_from(invoker, "*")

  plugin_name = target_name
  target_name_tmp = string_replace(target_name, "_", "")
  target_name_ext = string_replace(target_name_tmp, "/", "_")
  plugin_name_ext = string_replace(plugin_name, "/", "_")

  if (platform == "ios") {
    ohos_source_set(target_name_ext) {
      deps = [ "//plugins/$plugin_name:${plugin_name_ext}_static_${platform}" ]

      part_names = string_split(plugin_name, "/")
      part_name = part_names[0]
      subsystem_name = "plugins"
    }
  } else {
    ohos_shared_library(target_name_ext) {
      deps = [ "//plugins/$plugin_name:${plugin_name_ext}_static_${platform}" ]

      relative_install_dir = "module"
      part_names = string_split(plugin_name, "/")
      part_name = part_names[0]
      subsystem_name = "plugins"
    }
  }
}