11cb0ef41Sopenharmony_ci# Copyright 2013 The Chromium Authors
21cb0ef41Sopenharmony_ci# Use of this source code is governed by a BSD-style license that can be
31cb0ef41Sopenharmony_ci# found in the LICENSE file.
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ciimport("//build/config/compiler/compiler.gni")
61cb0ef41Sopenharmony_ciimport("//build/config/dcheck_always_on.gni")
71cb0ef41Sopenharmony_ci
81cb0ef41Sopenharmony_cideclare_args() {
91cb0ef41Sopenharmony_ci  # Expose zlib's symbols, used by Node.js to provide zlib APIs for its native
101cb0ef41Sopenharmony_ci  # modules.
111cb0ef41Sopenharmony_ci  zlib_symbols_visible = false
121cb0ef41Sopenharmony_ci}
131cb0ef41Sopenharmony_ci
141cb0ef41Sopenharmony_ciif (build_with_chromium) {
151cb0ef41Sopenharmony_ci  import("//testing/test.gni")
161cb0ef41Sopenharmony_ci}
171cb0ef41Sopenharmony_ci
181cb0ef41Sopenharmony_ciif (current_cpu == "arm" || current_cpu == "arm64") {
191cb0ef41Sopenharmony_ci  import("//build/config/arm.gni")
201cb0ef41Sopenharmony_ci}
211cb0ef41Sopenharmony_ci
221cb0ef41Sopenharmony_ciconfig("zlib_config") {
231cb0ef41Sopenharmony_ci  include_dirs = [ "." ]
241cb0ef41Sopenharmony_ci
251cb0ef41Sopenharmony_ci  if (zlib_symbols_visible) {
261cb0ef41Sopenharmony_ci    defines = [ "ZLIB_DLL" ]
271cb0ef41Sopenharmony_ci  }
281cb0ef41Sopenharmony_ci}
291cb0ef41Sopenharmony_ci
301cb0ef41Sopenharmony_ciconfig("zlib_internal_config") {
311cb0ef41Sopenharmony_ci  defines = [ "ZLIB_IMPLEMENTATION" ]
321cb0ef41Sopenharmony_ci
331cb0ef41Sopenharmony_ci  if (!is_debug) {
341cb0ef41Sopenharmony_ci    # Build code using -O3, see: crbug.com/1084371.
351cb0ef41Sopenharmony_ci    configs = [ "//build/config/compiler:optimize_speed" ]
361cb0ef41Sopenharmony_ci  }
371cb0ef41Sopenharmony_ci  if (is_debug || dcheck_always_on || use_fuzzing_engine) {
381cb0ef41Sopenharmony_ci    # Enable zlib's asserts in debug and fuzzer builds.
391cb0ef41Sopenharmony_ci    defines += [ "ZLIB_DEBUG" ]
401cb0ef41Sopenharmony_ci  }
411cb0ef41Sopenharmony_ci
421cb0ef41Sopenharmony_ci  if (is_win && !is_clang) {
431cb0ef41Sopenharmony_ci    # V8 supports building with msvc, these silence some warnings that
441cb0ef41Sopenharmony_ci    # causes compilation to fail (https://crbug.com/1255096).
451cb0ef41Sopenharmony_ci    cflags = [
461cb0ef41Sopenharmony_ci      "/wd4244",
471cb0ef41Sopenharmony_ci      "/wd4100",
481cb0ef41Sopenharmony_ci      "/wd4702",
491cb0ef41Sopenharmony_ci      "/wd4127",
501cb0ef41Sopenharmony_ci    ]
511cb0ef41Sopenharmony_ci  }
521cb0ef41Sopenharmony_ci}
531cb0ef41Sopenharmony_ci
541cb0ef41Sopenharmony_cisource_set("zlib_common_headers") {
551cb0ef41Sopenharmony_ci  visibility = [ ":*" ]
561cb0ef41Sopenharmony_ci
571cb0ef41Sopenharmony_ci  sources = [
581cb0ef41Sopenharmony_ci    "chromeconf.h",
591cb0ef41Sopenharmony_ci    "deflate.h",
601cb0ef41Sopenharmony_ci    "inffast.h",
611cb0ef41Sopenharmony_ci    "inffixed.h",
621cb0ef41Sopenharmony_ci    "inflate.h",
631cb0ef41Sopenharmony_ci    "inftrees.h",
641cb0ef41Sopenharmony_ci    "zconf.h",
651cb0ef41Sopenharmony_ci    "zlib.h",
661cb0ef41Sopenharmony_ci    "zutil.h",
671cb0ef41Sopenharmony_ci  ]
681cb0ef41Sopenharmony_ci}
691cb0ef41Sopenharmony_ci
701cb0ef41Sopenharmony_ciuse_arm_neon_optimizations = false
711cb0ef41Sopenharmony_ciif ((current_cpu == "arm" || current_cpu == "arm64") &&
721cb0ef41Sopenharmony_ci    !(is_win && !is_clang)) {
731cb0ef41Sopenharmony_ci  # TODO(richard.townsend@arm.com): Optimizations temporarily disabled for
741cb0ef41Sopenharmony_ci  # Windows on Arm MSVC builds, see http://crbug.com/v8/10012.
751cb0ef41Sopenharmony_ci  if (arm_use_neon) {
761cb0ef41Sopenharmony_ci    use_arm_neon_optimizations = true
771cb0ef41Sopenharmony_ci  }
781cb0ef41Sopenharmony_ci}
791cb0ef41Sopenharmony_ci
801cb0ef41Sopenharmony_ciuse_x86_x64_optimizations =
811cb0ef41Sopenharmony_ci    (current_cpu == "x86" || current_cpu == "x64") && !is_ios
821cb0ef41Sopenharmony_ci
831cb0ef41Sopenharmony_ciconfig("zlib_adler32_simd_config") {
841cb0ef41Sopenharmony_ci  if (use_x86_x64_optimizations) {
851cb0ef41Sopenharmony_ci    defines = [ "ADLER32_SIMD_SSSE3" ]
861cb0ef41Sopenharmony_ci    if (is_win) {
871cb0ef41Sopenharmony_ci      defines += [ "X86_WINDOWS" ]
881cb0ef41Sopenharmony_ci    } else {
891cb0ef41Sopenharmony_ci      defines += [ "X86_NOT_WINDOWS" ]
901cb0ef41Sopenharmony_ci    }
911cb0ef41Sopenharmony_ci  }
921cb0ef41Sopenharmony_ci
931cb0ef41Sopenharmony_ci  if (use_arm_neon_optimizations) {
941cb0ef41Sopenharmony_ci    defines = [ "ADLER32_SIMD_NEON" ]
951cb0ef41Sopenharmony_ci  }
961cb0ef41Sopenharmony_ci}
971cb0ef41Sopenharmony_ci
981cb0ef41Sopenharmony_cisource_set("zlib_adler32_simd") {
991cb0ef41Sopenharmony_ci  visibility = [ ":*" ]
1001cb0ef41Sopenharmony_ci
1011cb0ef41Sopenharmony_ci  if (use_x86_x64_optimizations) {
1021cb0ef41Sopenharmony_ci    sources = [
1031cb0ef41Sopenharmony_ci      "adler32_simd.c",
1041cb0ef41Sopenharmony_ci      "adler32_simd.h",
1051cb0ef41Sopenharmony_ci    ]
1061cb0ef41Sopenharmony_ci
1071cb0ef41Sopenharmony_ci    if (!is_win || is_clang) {
1081cb0ef41Sopenharmony_ci      cflags = [ "-mssse3" ]
1091cb0ef41Sopenharmony_ci    }
1101cb0ef41Sopenharmony_ci  }
1111cb0ef41Sopenharmony_ci
1121cb0ef41Sopenharmony_ci  if (use_arm_neon_optimizations) {
1131cb0ef41Sopenharmony_ci    sources = [
1141cb0ef41Sopenharmony_ci      "adler32_simd.c",
1151cb0ef41Sopenharmony_ci      "adler32_simd.h",
1161cb0ef41Sopenharmony_ci    ]
1171cb0ef41Sopenharmony_ci  }
1181cb0ef41Sopenharmony_ci
1191cb0ef41Sopenharmony_ci  configs += [ ":zlib_internal_config" ]
1201cb0ef41Sopenharmony_ci
1211cb0ef41Sopenharmony_ci  public_configs = [ ":zlib_adler32_simd_config" ]
1221cb0ef41Sopenharmony_ci
1231cb0ef41Sopenharmony_ci  public_deps = [ ":zlib_common_headers" ]
1241cb0ef41Sopenharmony_ci}
1251cb0ef41Sopenharmony_ci
1261cb0ef41Sopenharmony_ciif (use_arm_neon_optimizations) {
1271cb0ef41Sopenharmony_ci  config("zlib_arm_crc32_config") {
1281cb0ef41Sopenharmony_ci    defines = [ "CRC32_ARMV8_CRC32" ]
1291cb0ef41Sopenharmony_ci    if (is_android) {
1301cb0ef41Sopenharmony_ci      defines += [ "ARMV8_OS_ANDROID" ]
1311cb0ef41Sopenharmony_ci    } else if (is_linux || is_chromeos) {
1321cb0ef41Sopenharmony_ci      defines += [ "ARMV8_OS_LINUX" ]
1331cb0ef41Sopenharmony_ci    } else if (is_mac) {
1341cb0ef41Sopenharmony_ci      defines += [ "ARMV8_OS_MACOS" ]
1351cb0ef41Sopenharmony_ci    } else if (is_ios) {
1361cb0ef41Sopenharmony_ci      defines += [ "ARMV8_OS_IOS" ]
1371cb0ef41Sopenharmony_ci    } else if (is_fuchsia) {
1381cb0ef41Sopenharmony_ci      defines += [ "ARMV8_OS_FUCHSIA" ]
1391cb0ef41Sopenharmony_ci    } else if (is_win) {
1401cb0ef41Sopenharmony_ci      defines += [ "ARMV8_OS_WINDOWS" ]
1411cb0ef41Sopenharmony_ci    } else {
1421cb0ef41Sopenharmony_ci      assert(false, "Unsupported ARM OS")
1431cb0ef41Sopenharmony_ci    }
1441cb0ef41Sopenharmony_ci  }
1451cb0ef41Sopenharmony_ci
1461cb0ef41Sopenharmony_ci  source_set("zlib_arm_crc32") {
1471cb0ef41Sopenharmony_ci    visibility = [ ":*" ]
1481cb0ef41Sopenharmony_ci
1491cb0ef41Sopenharmony_ci    include_dirs = [ "." ]
1501cb0ef41Sopenharmony_ci
1511cb0ef41Sopenharmony_ci    if (!is_win && !is_clang) {
1521cb0ef41Sopenharmony_ci      assert(!use_thin_lto,
1531cb0ef41Sopenharmony_ci             "ThinLTO fails mixing different module-level targets")
1541cb0ef41Sopenharmony_ci      cflags_c = [ "-march=armv8-a+aes+crc" ]
1551cb0ef41Sopenharmony_ci    }
1561cb0ef41Sopenharmony_ci
1571cb0ef41Sopenharmony_ci    sources = [
1581cb0ef41Sopenharmony_ci      "crc32_simd.c",
1591cb0ef41Sopenharmony_ci      "crc32_simd.h",
1601cb0ef41Sopenharmony_ci    ]
1611cb0ef41Sopenharmony_ci
1621cb0ef41Sopenharmony_ci    configs += [ ":zlib_internal_config" ]
1631cb0ef41Sopenharmony_ci
1641cb0ef41Sopenharmony_ci    public_configs = [ ":zlib_arm_crc32_config" ]
1651cb0ef41Sopenharmony_ci
1661cb0ef41Sopenharmony_ci    public_deps = [ ":zlib_common_headers" ]
1671cb0ef41Sopenharmony_ci  }
1681cb0ef41Sopenharmony_ci}
1691cb0ef41Sopenharmony_ci
1701cb0ef41Sopenharmony_ciconfig("zlib_inflate_chunk_simd_config") {
1711cb0ef41Sopenharmony_ci  if (use_x86_x64_optimizations) {
1721cb0ef41Sopenharmony_ci    defines = [ "INFLATE_CHUNK_SIMD_SSE2" ]
1731cb0ef41Sopenharmony_ci
1741cb0ef41Sopenharmony_ci    if (current_cpu == "x64") {
1751cb0ef41Sopenharmony_ci      defines += [ "INFLATE_CHUNK_READ_64LE" ]
1761cb0ef41Sopenharmony_ci    }
1771cb0ef41Sopenharmony_ci  }
1781cb0ef41Sopenharmony_ci
1791cb0ef41Sopenharmony_ci  if (use_arm_neon_optimizations) {
1801cb0ef41Sopenharmony_ci    defines = [ "INFLATE_CHUNK_SIMD_NEON" ]
1811cb0ef41Sopenharmony_ci
1821cb0ef41Sopenharmony_ci    if (current_cpu == "arm64") {
1831cb0ef41Sopenharmony_ci      defines += [ "INFLATE_CHUNK_READ_64LE" ]
1841cb0ef41Sopenharmony_ci    }
1851cb0ef41Sopenharmony_ci  }
1861cb0ef41Sopenharmony_ci}
1871cb0ef41Sopenharmony_ci
1881cb0ef41Sopenharmony_cisource_set("zlib_inflate_chunk_simd") {
1891cb0ef41Sopenharmony_ci  visibility = [ ":*" ]
1901cb0ef41Sopenharmony_ci
1911cb0ef41Sopenharmony_ci  if (use_x86_x64_optimizations || use_arm_neon_optimizations) {
1921cb0ef41Sopenharmony_ci    include_dirs = [ "." ]
1931cb0ef41Sopenharmony_ci
1941cb0ef41Sopenharmony_ci    sources = [
1951cb0ef41Sopenharmony_ci      "contrib/optimizations/chunkcopy.h",
1961cb0ef41Sopenharmony_ci      "contrib/optimizations/inffast_chunk.c",
1971cb0ef41Sopenharmony_ci      "contrib/optimizations/inffast_chunk.h",
1981cb0ef41Sopenharmony_ci      "contrib/optimizations/inflate.c",
1991cb0ef41Sopenharmony_ci    ]
2001cb0ef41Sopenharmony_ci  }
2011cb0ef41Sopenharmony_ci
2021cb0ef41Sopenharmony_ci  configs += [ ":zlib_internal_config" ]
2031cb0ef41Sopenharmony_ci
2041cb0ef41Sopenharmony_ci  # Needed for MSVC, which is still supported by V8 and PDFium. zlib uses K&R C
2051cb0ef41Sopenharmony_ci  # style function declarations, which triggers warning C4131.
2061cb0ef41Sopenharmony_ci  configs -= [ "//build/config/compiler:chromium_code" ]
2071cb0ef41Sopenharmony_ci  configs += [ "//build/config/compiler:no_chromium_code" ]
2081cb0ef41Sopenharmony_ci  configs += [ ":zlib_warnings" ]
2091cb0ef41Sopenharmony_ci
2101cb0ef41Sopenharmony_ci  public_configs = [ ":zlib_inflate_chunk_simd_config" ]
2111cb0ef41Sopenharmony_ci
2121cb0ef41Sopenharmony_ci  public_deps = [ ":zlib_common_headers" ]
2131cb0ef41Sopenharmony_ci}
2141cb0ef41Sopenharmony_ci
2151cb0ef41Sopenharmony_ciconfig("zlib_crc32_simd_config") {
2161cb0ef41Sopenharmony_ci  if (use_x86_x64_optimizations) {
2171cb0ef41Sopenharmony_ci    defines = [ "CRC32_SIMD_SSE42_PCLMUL" ]
2181cb0ef41Sopenharmony_ci  }
2191cb0ef41Sopenharmony_ci}
2201cb0ef41Sopenharmony_ci
2211cb0ef41Sopenharmony_cisource_set("zlib_crc32_simd") {
2221cb0ef41Sopenharmony_ci  visibility = [ ":*" ]
2231cb0ef41Sopenharmony_ci
2241cb0ef41Sopenharmony_ci  if (use_x86_x64_optimizations) {
2251cb0ef41Sopenharmony_ci    sources = [
2261cb0ef41Sopenharmony_ci      "crc32_simd.c",
2271cb0ef41Sopenharmony_ci      "crc32_simd.h",
2281cb0ef41Sopenharmony_ci      "crc_folding.c",
2291cb0ef41Sopenharmony_ci    ]
2301cb0ef41Sopenharmony_ci
2311cb0ef41Sopenharmony_ci    if (!is_win || is_clang) {
2321cb0ef41Sopenharmony_ci      cflags = [
2331cb0ef41Sopenharmony_ci        "-msse4.2",
2341cb0ef41Sopenharmony_ci        "-mpclmul",
2351cb0ef41Sopenharmony_ci      ]
2361cb0ef41Sopenharmony_ci    }
2371cb0ef41Sopenharmony_ci  }
2381cb0ef41Sopenharmony_ci
2391cb0ef41Sopenharmony_ci  configs += [ ":zlib_internal_config" ]
2401cb0ef41Sopenharmony_ci
2411cb0ef41Sopenharmony_ci  public_configs = [ ":zlib_crc32_simd_config" ]
2421cb0ef41Sopenharmony_ci
2431cb0ef41Sopenharmony_ci  public_deps = [ ":zlib_common_headers" ]
2441cb0ef41Sopenharmony_ci}
2451cb0ef41Sopenharmony_ci
2461cb0ef41Sopenharmony_ciconfig("zlib_slide_hash_simd_config") {
2471cb0ef41Sopenharmony_ci  if (use_x86_x64_optimizations) {
2481cb0ef41Sopenharmony_ci    defines = [ "DEFLATE_SLIDE_HASH_SSE2" ]
2491cb0ef41Sopenharmony_ci  }
2501cb0ef41Sopenharmony_ci
2511cb0ef41Sopenharmony_ci  if (use_arm_neon_optimizations) {
2521cb0ef41Sopenharmony_ci    defines = [ "DEFLATE_SLIDE_HASH_NEON" ]
2531cb0ef41Sopenharmony_ci  }
2541cb0ef41Sopenharmony_ci}
2551cb0ef41Sopenharmony_ci
2561cb0ef41Sopenharmony_cisource_set("zlib_slide_hash_simd") {
2571cb0ef41Sopenharmony_ci  visibility = [ ":*" ]
2581cb0ef41Sopenharmony_ci
2591cb0ef41Sopenharmony_ci  if (use_x86_x64_optimizations) {
2601cb0ef41Sopenharmony_ci    sources = [ "slide_hash_simd.h" ]
2611cb0ef41Sopenharmony_ci  }
2621cb0ef41Sopenharmony_ci
2631cb0ef41Sopenharmony_ci  if (use_arm_neon_optimizations) {
2641cb0ef41Sopenharmony_ci    sources = [ "slide_hash_simd.h" ]
2651cb0ef41Sopenharmony_ci  }
2661cb0ef41Sopenharmony_ci
2671cb0ef41Sopenharmony_ci  configs += [ ":zlib_internal_config" ]
2681cb0ef41Sopenharmony_ci
2691cb0ef41Sopenharmony_ci  public_configs = [ ":zlib_slide_hash_simd_config" ]
2701cb0ef41Sopenharmony_ci
2711cb0ef41Sopenharmony_ci  public_deps = [ ":zlib_common_headers" ]
2721cb0ef41Sopenharmony_ci}
2731cb0ef41Sopenharmony_ci
2741cb0ef41Sopenharmony_ciconfig("zlib_warnings") {
2751cb0ef41Sopenharmony_ci  if (is_clang) {
2761cb0ef41Sopenharmony_ci    cflags = [
2771cb0ef41Sopenharmony_ci      "-Wno-deprecated-non-prototype",
2781cb0ef41Sopenharmony_ci      "-Wno-incompatible-pointer-types",
2791cb0ef41Sopenharmony_ci      "-Wunused-variable",
2801cb0ef41Sopenharmony_ci    ]
2811cb0ef41Sopenharmony_ci  }
2821cb0ef41Sopenharmony_ci}
2831cb0ef41Sopenharmony_ci
2841cb0ef41Sopenharmony_cicomponent("zlib") {
2851cb0ef41Sopenharmony_ci  if (!is_win) {
2861cb0ef41Sopenharmony_ci    # Don't stomp on "libzlib" on other platforms.
2871cb0ef41Sopenharmony_ci    output_name = "chrome_zlib"
2881cb0ef41Sopenharmony_ci  }
2891cb0ef41Sopenharmony_ci
2901cb0ef41Sopenharmony_ci  sources = [
2911cb0ef41Sopenharmony_ci    "adler32.c",
2921cb0ef41Sopenharmony_ci    "chromeconf.h",
2931cb0ef41Sopenharmony_ci    "compress.c",
2941cb0ef41Sopenharmony_ci    "contrib/optimizations/insert_string.h",
2951cb0ef41Sopenharmony_ci    "cpu_features.c",
2961cb0ef41Sopenharmony_ci    "cpu_features.h",
2971cb0ef41Sopenharmony_ci    "crc32.c",
2981cb0ef41Sopenharmony_ci    "crc32.h",
2991cb0ef41Sopenharmony_ci    "deflate.c",
3001cb0ef41Sopenharmony_ci    "deflate.h",
3011cb0ef41Sopenharmony_ci    "gzclose.c",
3021cb0ef41Sopenharmony_ci    "gzguts.h",
3031cb0ef41Sopenharmony_ci    "gzlib.c",
3041cb0ef41Sopenharmony_ci    "gzread.c",
3051cb0ef41Sopenharmony_ci    "gzwrite.c",
3061cb0ef41Sopenharmony_ci    "infback.c",
3071cb0ef41Sopenharmony_ci    "inffast.c",
3081cb0ef41Sopenharmony_ci    "inffast.h",
3091cb0ef41Sopenharmony_ci    "inffixed.h",
3101cb0ef41Sopenharmony_ci    "inflate.h",
3111cb0ef41Sopenharmony_ci    "inftrees.c",
3121cb0ef41Sopenharmony_ci    "inftrees.h",
3131cb0ef41Sopenharmony_ci    "trees.c",
3141cb0ef41Sopenharmony_ci    "trees.h",
3151cb0ef41Sopenharmony_ci    "uncompr.c",
3161cb0ef41Sopenharmony_ci    "zconf.h",
3171cb0ef41Sopenharmony_ci    "zlib.h",
3181cb0ef41Sopenharmony_ci    "zutil.c",
3191cb0ef41Sopenharmony_ci    "zutil.h",
3201cb0ef41Sopenharmony_ci  ]
3211cb0ef41Sopenharmony_ci
3221cb0ef41Sopenharmony_ci  defines = []
3231cb0ef41Sopenharmony_ci  deps = []
3241cb0ef41Sopenharmony_ci
3251cb0ef41Sopenharmony_ci  if (!use_x86_x64_optimizations && !use_arm_neon_optimizations) {
3261cb0ef41Sopenharmony_ci    # Apparently android_cronet bot builds with NEON disabled and
3271cb0ef41Sopenharmony_ci    # we also should disable optimizations for iOS@x86 (a.k.a. simulator).
3281cb0ef41Sopenharmony_ci    defines += [ "CPU_NO_SIMD" ]
3291cb0ef41Sopenharmony_ci  }
3301cb0ef41Sopenharmony_ci
3311cb0ef41Sopenharmony_ci  if (use_x86_x64_optimizations || use_arm_neon_optimizations) {
3321cb0ef41Sopenharmony_ci    deps += [
3331cb0ef41Sopenharmony_ci      ":zlib_adler32_simd",
3341cb0ef41Sopenharmony_ci      ":zlib_inflate_chunk_simd",
3351cb0ef41Sopenharmony_ci      ":zlib_slide_hash_simd",
3361cb0ef41Sopenharmony_ci    ]
3371cb0ef41Sopenharmony_ci
3381cb0ef41Sopenharmony_ci    if (use_x86_x64_optimizations) {
3391cb0ef41Sopenharmony_ci      deps += [ ":zlib_crc32_simd" ]
3401cb0ef41Sopenharmony_ci    } else if (use_arm_neon_optimizations) {
3411cb0ef41Sopenharmony_ci      deps += [ ":zlib_arm_crc32" ]
3421cb0ef41Sopenharmony_ci    }
3431cb0ef41Sopenharmony_ci  } else {
3441cb0ef41Sopenharmony_ci    sources += [ "inflate.c" ]
3451cb0ef41Sopenharmony_ci  }
3461cb0ef41Sopenharmony_ci
3471cb0ef41Sopenharmony_ci  if (is_android) {
3481cb0ef41Sopenharmony_ci    import("//build/config/android/config.gni")
3491cb0ef41Sopenharmony_ci    if (defined(android_ndk_root) && android_ndk_root != "") {
3501cb0ef41Sopenharmony_ci      deps += [ "//third_party/cpu_features:ndk_compat" ]
3511cb0ef41Sopenharmony_ci    } else {
3521cb0ef41Sopenharmony_ci      assert(false, "CPU detection requires the Android NDK")
3531cb0ef41Sopenharmony_ci    }
3541cb0ef41Sopenharmony_ci  }
3551cb0ef41Sopenharmony_ci
3561cb0ef41Sopenharmony_ci  configs -= [ "//build/config/compiler:chromium_code" ]
3571cb0ef41Sopenharmony_ci  configs += [ "//build/config/compiler:no_chromium_code" ]
3581cb0ef41Sopenharmony_ci
3591cb0ef41Sopenharmony_ci  if (zlib_symbols_visible) {
3601cb0ef41Sopenharmony_ci    configs -= [ "//build/config/gcc:symbol_visibility_hidden" ]
3611cb0ef41Sopenharmony_ci    configs += [ "//build/config/gcc:symbol_visibility_default" ]
3621cb0ef41Sopenharmony_ci  }
3631cb0ef41Sopenharmony_ci
3641cb0ef41Sopenharmony_ci  public_configs = [ ":zlib_config" ]
3651cb0ef41Sopenharmony_ci
3661cb0ef41Sopenharmony_ci  configs += [
3671cb0ef41Sopenharmony_ci    ":zlib_internal_config",
3681cb0ef41Sopenharmony_ci
3691cb0ef41Sopenharmony_ci    # Must be after no_chromium_code for warning flags to be ordered correctly.
3701cb0ef41Sopenharmony_ci    ":zlib_warnings",
3711cb0ef41Sopenharmony_ci  ]
3721cb0ef41Sopenharmony_ci
3731cb0ef41Sopenharmony_ci  allow_circular_includes_from = deps
3741cb0ef41Sopenharmony_ci}
3751cb0ef41Sopenharmony_ci
3761cb0ef41Sopenharmony_ciconfig("minizip_warnings") {
3771cb0ef41Sopenharmony_ci  visibility = [ ":*" ]
3781cb0ef41Sopenharmony_ci
3791cb0ef41Sopenharmony_ci  if (is_clang) {
3801cb0ef41Sopenharmony_ci    cflags = [
3811cb0ef41Sopenharmony_ci      # zlib uses `if ((a == b))` for some reason.
3821cb0ef41Sopenharmony_ci      "-Wno-parentheses-equality",
3831cb0ef41Sopenharmony_ci      "-Wno-deprecated-non-prototype",
3841cb0ef41Sopenharmony_ci    ]
3851cb0ef41Sopenharmony_ci  }
3861cb0ef41Sopenharmony_ci}
3871cb0ef41Sopenharmony_ci
3881cb0ef41Sopenharmony_cistatic_library("minizip") {
3891cb0ef41Sopenharmony_ci  include_dirs = [
3901cb0ef41Sopenharmony_ci    ".",
3911cb0ef41Sopenharmony_ci    "//third_party/zlib",
3921cb0ef41Sopenharmony_ci  ]
3931cb0ef41Sopenharmony_ci
3941cb0ef41Sopenharmony_ci  sources = [
3951cb0ef41Sopenharmony_ci    "contrib/minizip/ioapi.c",
3961cb0ef41Sopenharmony_ci    "contrib/minizip/ioapi.h",
3971cb0ef41Sopenharmony_ci    "contrib/minizip/iowin32.c",
3981cb0ef41Sopenharmony_ci    "contrib/minizip/iowin32.h",
3991cb0ef41Sopenharmony_ci    "contrib/minizip/unzip.c",
4001cb0ef41Sopenharmony_ci    "contrib/minizip/unzip.h",
4011cb0ef41Sopenharmony_ci    "contrib/minizip/zip.c",
4021cb0ef41Sopenharmony_ci    "contrib/minizip/zip.h",
4031cb0ef41Sopenharmony_ci  ]
4041cb0ef41Sopenharmony_ci
4051cb0ef41Sopenharmony_ci  if (!is_win) {
4061cb0ef41Sopenharmony_ci    sources -= [
4071cb0ef41Sopenharmony_ci      "contrib/minizip/iowin32.c",
4081cb0ef41Sopenharmony_ci      "contrib/minizip/iowin32.h",
4091cb0ef41Sopenharmony_ci    ]
4101cb0ef41Sopenharmony_ci  }
4111cb0ef41Sopenharmony_ci
4121cb0ef41Sopenharmony_ci  if (is_apple || is_android || is_nacl) {
4131cb0ef41Sopenharmony_ci    # Mac, Android and the BSDs don't have fopen64, ftello64, or fseeko64. We
4141cb0ef41Sopenharmony_ci    # use fopen, ftell, and fseek instead on these systems.
4151cb0ef41Sopenharmony_ci    defines = [ "USE_FILE32API" ]
4161cb0ef41Sopenharmony_ci  }
4171cb0ef41Sopenharmony_ci
4181cb0ef41Sopenharmony_ci  deps = [ ":zlib" ]
4191cb0ef41Sopenharmony_ci
4201cb0ef41Sopenharmony_ci  configs -= [ "//build/config/compiler:chromium_code" ]
4211cb0ef41Sopenharmony_ci  configs += [ "//build/config/compiler:no_chromium_code" ]
4221cb0ef41Sopenharmony_ci
4231cb0ef41Sopenharmony_ci  public_configs = [ ":zlib_config" ]
4241cb0ef41Sopenharmony_ci
4251cb0ef41Sopenharmony_ci  configs += [
4261cb0ef41Sopenharmony_ci    # Must be after no_chromium_code for warning flags to be ordered correctly.
4271cb0ef41Sopenharmony_ci    ":minizip_warnings",
4281cb0ef41Sopenharmony_ci  ]
4291cb0ef41Sopenharmony_ci}
4301cb0ef41Sopenharmony_ci
4311cb0ef41Sopenharmony_ciexecutable("zlib_bench") {
4321cb0ef41Sopenharmony_ci  include_dirs = [ "." ]
4331cb0ef41Sopenharmony_ci
4341cb0ef41Sopenharmony_ci  sources = [ "contrib/bench/zlib_bench.cc" ]
4351cb0ef41Sopenharmony_ci  if (!is_debug) {
4361cb0ef41Sopenharmony_ci    configs -= [ "//build/config/compiler:default_optimization" ]
4371cb0ef41Sopenharmony_ci    configs += [ "//build/config/compiler:optimize_speed" ]
4381cb0ef41Sopenharmony_ci  }
4391cb0ef41Sopenharmony_ci
4401cb0ef41Sopenharmony_ci  deps = [ ":zlib" ]
4411cb0ef41Sopenharmony_ci
4421cb0ef41Sopenharmony_ci  configs -= [ "//build/config/compiler:chromium_code" ]
4431cb0ef41Sopenharmony_ci  configs += [ "//build/config/compiler:no_chromium_code" ]
4441cb0ef41Sopenharmony_ci}
4451cb0ef41Sopenharmony_ci
4461cb0ef41Sopenharmony_ciif (!is_win || target_os != "winuwp") {
4471cb0ef41Sopenharmony_ci  executable("minizip_bin") {
4481cb0ef41Sopenharmony_ci    include_dirs = [ "." ]
4491cb0ef41Sopenharmony_ci
4501cb0ef41Sopenharmony_ci    sources = [ "contrib/minizip/minizip.c" ]
4511cb0ef41Sopenharmony_ci
4521cb0ef41Sopenharmony_ci    if (is_clang) {
4531cb0ef41Sopenharmony_ci      cflags = [
4541cb0ef41Sopenharmony_ci        "-Wno-incompatible-pointer-types-discards-qualifiers",
4551cb0ef41Sopenharmony_ci
4561cb0ef41Sopenharmony_ci        "-Wno-deprecated-non-prototype",
4571cb0ef41Sopenharmony_ci      ]
4581cb0ef41Sopenharmony_ci    }
4591cb0ef41Sopenharmony_ci
4601cb0ef41Sopenharmony_ci    if (!is_debug) {
4611cb0ef41Sopenharmony_ci      configs -= [ "//build/config/compiler:default_optimization" ]
4621cb0ef41Sopenharmony_ci      configs += [ "//build/config/compiler:optimize_speed" ]
4631cb0ef41Sopenharmony_ci    }
4641cb0ef41Sopenharmony_ci
4651cb0ef41Sopenharmony_ci    deps = [ ":minizip" ]
4661cb0ef41Sopenharmony_ci
4671cb0ef41Sopenharmony_ci    configs -= [ "//build/config/compiler:chromium_code" ]
4681cb0ef41Sopenharmony_ci    configs += [ "//build/config/compiler:no_chromium_code" ]
4691cb0ef41Sopenharmony_ci  }
4701cb0ef41Sopenharmony_ci
4711cb0ef41Sopenharmony_ci  executable("miniunz_bin") {
4721cb0ef41Sopenharmony_ci    include_dirs = [ "." ]
4731cb0ef41Sopenharmony_ci
4741cb0ef41Sopenharmony_ci    sources = [ "contrib/minizip/miniunz.c" ]
4751cb0ef41Sopenharmony_ci
4761cb0ef41Sopenharmony_ci    if (is_clang) {
4771cb0ef41Sopenharmony_ci      cflags = [
4781cb0ef41Sopenharmony_ci        "-Wno-incompatible-pointer-types-discards-qualifiers",
4791cb0ef41Sopenharmony_ci        "-Wno-deprecated-non-prototype",
4801cb0ef41Sopenharmony_ci      ]
4811cb0ef41Sopenharmony_ci    }
4821cb0ef41Sopenharmony_ci
4831cb0ef41Sopenharmony_ci    if (!is_debug) {
4841cb0ef41Sopenharmony_ci      configs -= [ "//build/config/compiler:default_optimization" ]
4851cb0ef41Sopenharmony_ci      configs += [ "//build/config/compiler:optimize_speed" ]
4861cb0ef41Sopenharmony_ci    }
4871cb0ef41Sopenharmony_ci
4881cb0ef41Sopenharmony_ci    deps = [ ":minizip" ]
4891cb0ef41Sopenharmony_ci
4901cb0ef41Sopenharmony_ci    configs -= [ "//build/config/compiler:chromium_code" ]
4911cb0ef41Sopenharmony_ci    configs += [ "//build/config/compiler:no_chromium_code" ]
4921cb0ef41Sopenharmony_ci  }
4931cb0ef41Sopenharmony_ci}
4941cb0ef41Sopenharmony_ci
4951cb0ef41Sopenharmony_ciif (build_with_chromium) {
4961cb0ef41Sopenharmony_ci  test("zlib_unittests") {
4971cb0ef41Sopenharmony_ci    testonly = true
4981cb0ef41Sopenharmony_ci
4991cb0ef41Sopenharmony_ci    sources = [
5001cb0ef41Sopenharmony_ci      "contrib/tests/infcover.cc",
5011cb0ef41Sopenharmony_ci      "contrib/tests/infcover.h",
5021cb0ef41Sopenharmony_ci      "contrib/tests/run_all_unittests.cc",
5031cb0ef41Sopenharmony_ci      "contrib/tests/utils_unittest.cc",
5041cb0ef41Sopenharmony_ci      "google/compression_utils_unittest.cc",
5051cb0ef41Sopenharmony_ci      "google/zip_reader_unittest.cc",
5061cb0ef41Sopenharmony_ci      "google/zip_unittest.cc",
5071cb0ef41Sopenharmony_ci    ]
5081cb0ef41Sopenharmony_ci
5091cb0ef41Sopenharmony_ci    data = [ "google/test/data/" ]
5101cb0ef41Sopenharmony_ci
5111cb0ef41Sopenharmony_ci    if (is_ios) {
5121cb0ef41Sopenharmony_ci      bundle_deps = [ "google:zlib_pak_bundle_data" ]
5131cb0ef41Sopenharmony_ci    }
5141cb0ef41Sopenharmony_ci
5151cb0ef41Sopenharmony_ci    deps = [
5161cb0ef41Sopenharmony_ci      ":minizip",
5171cb0ef41Sopenharmony_ci      ":zlib",
5181cb0ef41Sopenharmony_ci      "google:compression_utils",
5191cb0ef41Sopenharmony_ci      "google:zip",
5201cb0ef41Sopenharmony_ci      "//base/test:test_support",
5211cb0ef41Sopenharmony_ci      "//testing/gtest",
5221cb0ef41Sopenharmony_ci    ]
5231cb0ef41Sopenharmony_ci
5241cb0ef41Sopenharmony_ci    configs -= [ "//build/config/compiler:chromium_code" ]
5251cb0ef41Sopenharmony_ci    configs += [ "//build/config/compiler:no_chromium_code" ]
5261cb0ef41Sopenharmony_ci
5271cb0ef41Sopenharmony_ci    include_dirs = [
5281cb0ef41Sopenharmony_ci      "//third_party/googletest/src/googletest/include/gtest",
5291cb0ef41Sopenharmony_ci      ".",
5301cb0ef41Sopenharmony_ci      "google",
5311cb0ef41Sopenharmony_ci    ]
5321cb0ef41Sopenharmony_ci  }
5331cb0ef41Sopenharmony_ci}
534