# Copyright (c) 2021 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/test.gni")
import("//foundation/aafwk/standard/aafwk.gni")
TASK_DIR = "//foundation/appexecfwk/standard"
LOG_DIR = "//foundation/aafwk/standard"
NAPI_DIR2 =
    "//foundation/aafwk/standard/interfaces/kits/napi/aafwk/inner/napi_common"
ACE_DIR = "//foundation/ace/napi/interfaces/kits"
PACMAP_DIR = "//foundation/aafwk/standard/interfaces/innerkits/want/include/ohos/aafwk/content"
ABILITY_DIR =
    "//foundation/aafwk/standard/frameworks/kits/ability/native/include"
IREMOTE_DIR =
    "//foundation/communication/ipc/interfaces/innerkits/ipc_core/include"
BUNDLE_MGR_DIR =
    "//foundation/aafwk/standard/interfaces/innerkits/ability_manager/include"
BUNDLE_MGR_DIR2 = "//foundation/appexecfwk/standard/interfaces/innerkits/appexecfwk_core/include/bundlemgr"
APP_DIR = "//foundation/appexecfwk/standard/interfaces/innerkits/appexecfwk_core/include/appmgr"
RESMGR_DIR = "//base/global/resmgr_standard/interfaces/innerkits/include"

config("zip_config") {
  include_dirs = [
    "include",
    "$NAPI_DIR2",
    "$ACE_DIR",
    "$ABILITY_DIR",
    "$PACMAP_DIR",
    "$IREMOTE_DIR",
    "$BUNDLE_MGR_DIR",
    "$BUNDLE_MGR_DIR2",
    "$APP_DIR",
    "$RESMGR_DIR",
    "//third_party/zlib",
    "//utils/native/base/include",
    "$LOG_DIR/services/common/include",
    "$TASK_DIR/common/log/include",
    "$TASK_DIR/interfaces/innerkits/appexecfwk_base/include",
    "$TASK_DIR/interfaces/innerkits/libeventhandler/include",
    "$TASK_DIR/interfaces/innerkits/task_dispatcher/include/dispatcher",
    "$TASK_DIR/interfaces/innerkits/task_dispatcher/include/task",
    "$TASK_DIR/interfaces/innerkits/task_dispatcher/include/threading",
    "$TASK_DIR/kits/appkit/native/app/include/task",
    "$TASK_DIR/kits/appkit/native/app/include",
    "//third_party/libuv/include",
    "//third_party/node/src",
    "//third_party/icu/icu4c/source/common/unicode",
  ]
}

ohos_shared_library("zlib") {
  public_configs = [ ":zip_config" ]

  sources = [
    "kits/napi/napi_zlib.cpp",
    "kits/napi/napi_zlib_common.cpp",
    "kits/napi/native_module.cpp",
    "src/file_path.cpp",
    "src/zip.cpp",
    "src/zip_internal.cpp",
    "src/zip_reader.cpp",
    "src/zip_utils.cpp",
    "src/zip_writer.cpp",
  ]

  cflags = []
  if (target_cpu == "arm") {
    cflags += [ "-DBINDER_IPC_32BIT" ]
  }

  deps = [
    "//foundation/aafwk/standard/interfaces/innerkits/want:want",
    "//foundation/ace/napi:ace_napi",
    "//foundation/appexecfwk/standard/interfaces/innerkits/task_dispatcher:appkit_dispatcher_td",
    "//third_party/libuv:uv_static",
    "//third_party/zlib:libz",
    "//utils/native/base:utils",
  ]

  external_deps = [ "hiviewdfx_hilog_native:libhilog" ]

  install_enable = true
  subsystem_name = "aafwk"
  part_name = "aafwk_standard"
  relative_install_dir = "module"
}

group("tools_zip") {
  deps = [ ":zlib" ]
}
