#
# Copyright (c) 2020 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/lite/config/component/lite_component.gni")

config("zlib_config") {
  include_dirs = [ "//third_party/zlib" ]
}

zlib_source = [
  "//third_party/zlib/adler32.c",
  "//third_party/zlib/compress.c",
  "//third_party/zlib/crc32.c",
  "//third_party/zlib/crc32.h",
  "//third_party/zlib/deflate.c",
  "//third_party/zlib/deflate.h",
  "//third_party/zlib/gzclose.c",
  "//third_party/zlib/gzguts.h",
  "//third_party/zlib/gzlib.c",
  "//third_party/zlib/gzread.c",
  "//third_party/zlib/gzwrite.c",
  "//third_party/zlib/infback.c",
  "//third_party/zlib/inffast.c",
  "//third_party/zlib/inffast.h",
  "//third_party/zlib/inffixed.h",
  "//third_party/zlib/inflate.h",
  "//third_party/zlib/inflate.c",
  "//third_party/zlib/inftrees.c",
  "//third_party/zlib/inftrees.h",
  "//third_party/zlib/trees.c",
  "//third_party/zlib/trees.h",
  "//third_party/zlib/uncompr.c",
  "//third_party/zlib/zconf.h",
  "//third_party/zlib/zlib.h",
  "//third_party/zlib/zutil.c",
  "//third_party/zlib/zutil.h",
  "//third_party/zlib/contrib/minizip/ioapi.c",
  "//third_party/zlib/contrib/minizip/unzip.c",
  "//third_party/zlib/contrib/minizip/zip.c",
]

lite_library("zlib_shared") {
  target_type = "shared_library"
  sources = zlib_source

  public_configs = [ ":zlib_config" ]
}

lite_library("zlib_static") {
  target_type = "static_library"
  sources = zlib_source

  public_configs = [ ":zlib_config" ]
  if (board_toolchain_type == "iccarm") {
    cflags = [
      "--diag_suppress",
      "Pe111,Pe147,Pe223",
    ]
    defines = [ "IOAPI_NO_64" ]
  }
}