chromium/third_party/libwebp/BUILD.gn

# Copyright 2014 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//build/config/arm.gni")
import("//build/config/sanitizers/sanitizers.gni")
import("//testing/libfuzzer/fuzzer_test.gni")

# Public configuration exported to users of the libwebp targets.
config("libwebp_public_config") {
  include_dirs = [ "./src/src" ]
  defines = [ "WEBP_EXTERN=extern" ]
}

# Private configuration used in building libwebp.
config("libwebp_config") {
  include_dirs = [ "./src" ]
  defines = [
    "WEBP_NEAR_LOSSLESS=0",
    "WEBP_DISABLE_STATS",
  ]
  if (!is_chromeos) {
    defines += [ "WEBP_REDUCE_SIZE" ]
  }
  if (!is_ios) {
    defines += [ "WEBP_REDUCE_CSP" ]
  }
}

set_opt_level = !is_debug && (is_posix || is_fuchsia || is_win) &&
                (current_cpu == "arm" || current_cpu == "arm64")

# webp's dsp code can be built for all configurations. Skipping it when both
# arm_use_neon and arm_optionally_use_neon are false will result in link errors
# for its dsp init functions.
use_dsp_neon =
    current_cpu == "arm64" || (current_cpu == "arm" && arm_version >= 7)

source_set("libwebp_webp") {
  sources = [
    "src/src/webp/decode.h",
    "src/src/webp/demux.h",
    "src/src/webp/encode.h",
    "src/src/webp/format_constants.h",
    "src/src/webp/mux.h",
    "src/src/webp/mux_types.h",
    "src/src/webp/types.h",
  ]
}

static_library("libwebp_dec") {
  sources = [
    "src/src/dec/alpha_dec.c",
    "src/src/dec/alphai_dec.h",
    "src/src/dec/buffer_dec.c",
    "src/src/dec/common_dec.h",
    "src/src/dec/frame_dec.c",
    "src/src/dec/idec_dec.c",
    "src/src/dec/io_dec.c",
    "src/src/dec/quant_dec.c",
    "src/src/dec/tree_dec.c",
    "src/src/dec/vp8_dec.c",
    "src/src/dec/vp8_dec.h",
    "src/src/dec/vp8i_dec.h",
    "src/src/dec/vp8l_dec.c",
    "src/src/dec/vp8li_dec.h",
    "src/src/dec/webp_dec.c",
    "src/src/dec/webpi_dec.h",
  ]

  configs += [ ":libwebp_config" ]
  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [ "//build/config/compiler:no_chromium_code" ]
  if (set_opt_level) {
    configs -= [ "//build/config/compiler:default_optimization" ]
    configs += [ "//build/config/compiler:optimize_max" ]
  }

  deps = [
    ":libwebp_dsp_headers",
    ":libwebp_utils",
    ":libwebp_webp",
  ]
  public_configs = [ ":libwebp_public_config" ]
  allow_circular_includes_from = [ ":libwebp_dsp_headers" ]
}

static_library("libwebp_demux") {
  sources = [ "src/src/demux/demux.c" ]
  public_configs = [ ":libwebp_public_config" ]
  configs += [ ":libwebp_config" ]
  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [ "//build/config/compiler:no_chromium_code" ]
  deps = [
    ":libwebp_utils",
    ":libwebp_webp",
  ]
}

static_library("libwebp_mux") {
  sources = [
    "src/src/mux/anim_encode.c",
    "src/src/mux/animi.h",
    "src/src/mux/muxedit.c",
    "src/src/mux/muxi.h",
    "src/src/mux/muxinternal.c",
    "src/src/mux/muxread.c",
  ]
  public_configs = [ ":libwebp_public_config" ]
  configs += [ ":libwebp_config" ]
  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [ "//build/config/compiler:no_chromium_code" ]
  deps = [
    ":libwebp_dec",
    ":libwebp_utils",
    ":libwebp_webp",
  ]
}

source_set("libwebp_dsp_headers") {
  public = [
    "src/src/dsp/cpu.h",
    "src/src/dsp/dsp.h",
    "src/src/dsp/lossless.h",
    "src/src/dsp/lossless_common.h",
    "src/src/dsp/mips_macro.h",
    "src/src/dsp/msa_macro.h",
    "src/src/dsp/neon.h",
    "src/src/dsp/quant.h",
    "src/src/dsp/yuv.h",
  ]
}

static_library("libwebp_dsp") {
  sources = [
    "src/src/dsp/alpha_processing.c",
    "src/src/dsp/alpha_processing_mips_dsp_r2.c",
    "src/src/dsp/cost.c",
    "src/src/dsp/cost_mips32.c",
    "src/src/dsp/cost_mips_dsp_r2.c",
    "src/src/dsp/cpu.c",
    "src/src/dsp/dec.c",
    "src/src/dsp/dec_clip_tables.c",
    "src/src/dsp/dec_mips32.c",
    "src/src/dsp/dec_mips_dsp_r2.c",
    "src/src/dsp/dec_msa.c",
    "src/src/dsp/enc.c",
    "src/src/dsp/enc_mips32.c",
    "src/src/dsp/enc_mips_dsp_r2.c",
    "src/src/dsp/enc_msa.c",
    "src/src/dsp/filters.c",
    "src/src/dsp/filters_mips_dsp_r2.c",
    "src/src/dsp/filters_msa.c",
    "src/src/dsp/lossless.c",
    "src/src/dsp/lossless_enc.c",
    "src/src/dsp/lossless_enc_mips32.c",
    "src/src/dsp/lossless_enc_mips_dsp_r2.c",
    "src/src/dsp/lossless_enc_msa.c",
    "src/src/dsp/lossless_mips_dsp_r2.c",
    "src/src/dsp/lossless_msa.c",
    "src/src/dsp/rescaler.c",
    "src/src/dsp/rescaler_mips32.c",
    "src/src/dsp/rescaler_mips_dsp_r2.c",
    "src/src/dsp/rescaler_msa.c",
    "src/src/dsp/ssim.c",
    "src/src/dsp/upsampling.c",
    "src/src/dsp/upsampling_mips_dsp_r2.c",
    "src/src/dsp/upsampling_msa.c",
    "src/src/dsp/yuv.c",
    "src/src/dsp/yuv_mips32.c",
    "src/src/dsp/yuv_mips_dsp_r2.c",
  ]
  configs += [ ":libwebp_config" ]
  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [ "//build/config/compiler:no_chromium_code" ]
  if (set_opt_level) {
    configs -= [ "//build/config/compiler:default_optimization" ]
    configs += [ "//build/config/compiler:optimize_max" ]
  }

  public_configs = [ ":libwebp_public_config" ]
  deps = [
    ":libwebp_dec",
    ":libwebp_dsp_sse2",
    ":libwebp_dsp_sse41",
    ":libwebp_enc",
    ":libwebp_utils",
    ":libwebp_webp",
  ]
  public_deps = [ ":libwebp_dsp_headers" ]
  if (is_android) {
    deps += [ "//third_party/cpu_features:ndk_compat" ]
  }
  if (current_cpu == "x86" || current_cpu == "x64") {
    defines = [
      "WEBP_HAVE_SSE2",
      "WEBP_HAVE_SSE41",
    ]
  }
  allow_circular_includes_from = [
    ":libwebp_dsp_sse2",
    ":libwebp_dsp_sse41",
    ":libwebp_utils",
  ]
}

static_library("libwebp_dsp_sse41") {
  sources = [
    "src/src/dsp/alpha_processing_sse41.c",
    "src/src/dsp/common_sse41.h",
    "src/src/dsp/dec_sse41.c",
    "src/src/dsp/enc_sse41.c",
    "src/src/dsp/lossless_enc_sse41.c",
    "src/src/dsp/lossless_sse41.c",
    "src/src/dsp/upsampling_sse41.c",
    "src/src/dsp/yuv_sse41.c",
  ]
  configs += [ ":libwebp_config" ]
  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [ "//build/config/compiler:no_chromium_code" ]
  if (set_opt_level) {
    configs -= [ "//build/config/compiler:default_optimization" ]
    configs += [ "//build/config/compiler:optimize_max" ]
  }

  public_configs = [ ":libwebp_public_config" ]
  if (!is_msan) {
    if ((current_cpu == "x86" || current_cpu == "x64") &&
        (!is_win || is_clang)) {
      cflags = [ "-msse4.1" ]
    }
  }
  deps = [ ":libwebp_dsp_sse2" ]
}

static_library("libwebp_dsp_sse2") {
  sources = [
    "src/src/dsp/alpha_processing_sse2.c",
    "src/src/dsp/common_sse2.h",
    "src/src/dsp/cost_sse2.c",
    "src/src/dsp/dec_sse2.c",
    "src/src/dsp/enc_sse2.c",
    "src/src/dsp/filters_sse2.c",
    "src/src/dsp/lossless_enc_sse2.c",
    "src/src/dsp/lossless_sse2.c",
    "src/src/dsp/rescaler_sse2.c",
    "src/src/dsp/ssim_sse2.c",
    "src/src/dsp/upsampling_sse2.c",
    "src/src/dsp/yuv_sse2.c",
  ]
  configs += [ ":libwebp_config" ]
  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [ "//build/config/compiler:no_chromium_code" ]
  if (set_opt_level) {
    configs -= [ "//build/config/compiler:default_optimization" ]
    configs += [ "//build/config/compiler:optimize_max" ]
  }

  public_configs = [ ":libwebp_public_config" ]
  if (!is_msan) {
    if ((current_cpu == "x86" || current_cpu == "x64") &&
        (!is_win || is_clang)) {
      cflags = [ "-msse2" ]
    }
  }
  public_deps = [
    ":libwebp_dec",
    ":libwebp_dsp_headers",
    ":libwebp_enc",
    ":libwebp_utils",
  ]
}

if (use_dsp_neon) {
  static_library("libwebp_dsp_neon") {
    sources = [
      "src/src/dsp/alpha_processing_neon.c",
      "src/src/dsp/cost_neon.c",
      "src/src/dsp/dec_neon.c",
      "src/src/dsp/enc_neon.c",
      "src/src/dsp/filters_neon.c",
      "src/src/dsp/lossless_enc_neon.c",
      "src/src/dsp/lossless_neon.c",
      "src/src/dsp/rescaler_neon.c",
      "src/src/dsp/upsampling_neon.c",
      "src/src/dsp/yuv_neon.c",
    ]

    deps = [
      ":libwebp_dec",
      ":libwebp_dsp",
      ":libwebp_enc",
      ":libwebp_utils",
    ]

    configs += [ ":libwebp_config" ]

    if (set_opt_level) {
      configs -= [ "//build/config/compiler:default_optimization" ]
      configs += [ "//build/config/compiler:optimize_max" ]
    }

    if (current_cpu == "arm") {
      # behavior similar to *.c.neon in an Android.mk
      configs -= [ "//build/config/compiler:compiler_arm_fpu" ]
      cflags = [ "-mfpu=neon" ]
    } else if (current_cpu == "arm64" && !is_clang) {
      # avoid an ICE with gcc-4.9: b/15574841
      cflags = [ "-frename-registers" ]
    }
  }
}  # use_dsp_neon

static_library("libwebp_enc") {
  sources = [
    "src/src/enc/alpha_enc.c",
    "src/src/enc/analysis_enc.c",
    "src/src/enc/backward_references_cost_enc.c",
    "src/src/enc/backward_references_enc.c",
    "src/src/enc/backward_references_enc.h",
    "src/src/enc/config_enc.c",
    "src/src/enc/cost_enc.c",
    "src/src/enc/cost_enc.h",
    "src/src/enc/filter_enc.c",
    "src/src/enc/frame_enc.c",
    "src/src/enc/histogram_enc.c",
    "src/src/enc/histogram_enc.h",
    "src/src/enc/iterator_enc.c",
    "src/src/enc/near_lossless_enc.c",
    "src/src/enc/picture_csp_enc.c",
    "src/src/enc/picture_enc.c",
    "src/src/enc/picture_psnr_enc.c",
    "src/src/enc/picture_rescale_enc.c",
    "src/src/enc/picture_tools_enc.c",
    "src/src/enc/predictor_enc.c",
    "src/src/enc/quant_enc.c",
    "src/src/enc/syntax_enc.c",
    "src/src/enc/token_enc.c",
    "src/src/enc/tree_enc.c",
    "src/src/enc/vp8i_enc.h",
    "src/src/enc/vp8l_enc.c",
    "src/src/enc/vp8li_enc.h",
    "src/src/enc/webp_enc.c",
  ]
  configs += [ ":libwebp_config" ]
  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [ "//build/config/compiler:no_chromium_code" ]
  if (set_opt_level) {
    configs -= [ "//build/config/compiler:default_optimization" ]
    configs += [ "//build/config/compiler:optimize_max" ]
  }

  public_configs = [ ":libwebp_public_config" ]

  deps = [
    ":libwebp_dec",
    ":libwebp_dsp_headers",
    ":libwebp_sharpyuv",
    ":libwebp_utils",
    ":libwebp_webp",
  ]

  allow_circular_includes_from = [ ":libwebp_dsp_headers" ]
}

source_set("libwebp_sharpyuv_dsp_headers") {
  public = [ "src/sharpyuv/sharpyuv_dsp.h" ]
}

source_set("libwebp_dsp_cpu_c") {
  public = [ "src/src/dsp/cpu.c" ]
}

config("libwebp_sharpyuv_public_config") {
  include_dirs = [ "src" ]
}

static_library("libwebp_sharpyuv") {
  sources = [
    "src/sharpyuv/sharpyuv.c",
    "src/sharpyuv/sharpyuv.h",
    "src/sharpyuv/sharpyuv_cpu.c",
    "src/sharpyuv/sharpyuv_cpu.h",
    "src/sharpyuv/sharpyuv_csp.c",
    "src/sharpyuv/sharpyuv_csp.h",
    "src/sharpyuv/sharpyuv_gamma.c",
    "src/sharpyuv/sharpyuv_gamma.h",
  ]
  configs += [ ":libwebp_config" ]
  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [ "//build/config/compiler:no_chromium_code" ]
  if (set_opt_level) {
    configs -= [ "//build/config/compiler:default_optimization" ]
    configs += [ "//build/config/compiler:optimize_max" ]
  }

  public_configs = [
    ":libwebp_public_config",
    ":libwebp_sharpyuv_public_config",
  ]

  deps = [
    ":libwebp_dsp_cpu_c",
    ":libwebp_dsp_headers",
    ":libwebp_sharpyuv_dsp",
    ":libwebp_webp",
  ]
}

static_library("libwebp_sharpyuv_dsp") {
  sources = [
    "src/sharpyuv/sharpyuv.h",
    "src/sharpyuv/sharpyuv_cpu.h",
    "src/sharpyuv/sharpyuv_dsp.c",
    "src/sharpyuv/sharpyuv_dsp.h",
  ]
  configs += [ ":libwebp_config" ]
  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [ "//build/config/compiler:no_chromium_code" ]
  if (set_opt_level) {
    configs -= [ "//build/config/compiler:default_optimization" ]
    configs += [ "//build/config/compiler:optimize_max" ]
  }

  public_configs = [ ":libwebp_public_config" ]

  deps = [
    ":libwebp_dsp_headers",
    ":libwebp_sharpyuv_sse2",
    ":libwebp_webp",
  ]
  if (use_dsp_neon) {
    deps += [ ":libwebp_sharpyuv_neon" ]
  }
}

if (use_dsp_neon) {
  static_library("libwebp_sharpyuv_neon") {
    sources = [ "src/sharpyuv/sharpyuv_neon.c" ]

    deps = [
      ":libwebp_dsp_headers",
      ":libwebp_sharpyuv_dsp_headers",
    ]

    configs += [ ":libwebp_config" ]

    if (set_opt_level) {
      configs -= [ "//build/config/compiler:default_optimization" ]
      configs += [ "//build/config/compiler:optimize_max" ]
    }

    if (current_cpu == "arm") {
      # behavior similar to *.c.neon in an Android.mk
      configs -= [ "//build/config/compiler:compiler_arm_fpu" ]
      cflags = [ "-mfpu=neon" ]
    } else if (current_cpu == "arm64" && !is_clang) {
      # avoid an ICE with gcc-4.9: b/15574841
      cflags = [ "-frename-registers" ]
    }
  }
}  # use_dsp_neon

static_library("libwebp_sharpyuv_sse2") {
  sources = [ "src/sharpyuv/sharpyuv_sse2.c" ]
  configs += [ ":libwebp_config" ]
  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [ "//build/config/compiler:no_chromium_code" ]
  if (set_opt_level) {
    configs -= [ "//build/config/compiler:default_optimization" ]
    configs += [ "//build/config/compiler:optimize_max" ]
  }

  public_configs = [ ":libwebp_public_config" ]
  if (!is_msan) {
    if ((current_cpu == "x86" || current_cpu == "x64") &&
        (!is_win || is_clang)) {
      cflags = [ "-msse2" ]
    }
  }
  public_deps = [
    ":libwebp_dsp_headers",
    ":libwebp_sharpyuv_dsp_headers",
  ]
}

static_library("libwebp_utils") {
  sources = [
    "src/src/utils/bit_reader_inl_utils.h",
    "src/src/utils/bit_reader_utils.c",
    "src/src/utils/bit_reader_utils.h",
    "src/src/utils/bit_writer_utils.c",
    "src/src/utils/bit_writer_utils.h",
    "src/src/utils/color_cache_utils.c",
    "src/src/utils/color_cache_utils.h",
    "src/src/utils/endian_inl_utils.h",
    "src/src/utils/filters_utils.c",
    "src/src/utils/filters_utils.h",
    "src/src/utils/huffman_encode_utils.c",
    "src/src/utils/huffman_encode_utils.h",
    "src/src/utils/huffman_utils.c",
    "src/src/utils/huffman_utils.h",
    "src/src/utils/palette.c",
    "src/src/utils/palette.h",
    "src/src/utils/quant_levels_dec_utils.c",
    "src/src/utils/quant_levels_dec_utils.h",
    "src/src/utils/quant_levels_utils.c",
    "src/src/utils/quant_levels_utils.h",
    "src/src/utils/random_utils.c",
    "src/src/utils/random_utils.h",
    "src/src/utils/rescaler_utils.c",
    "src/src/utils/rescaler_utils.h",
    "src/src/utils/thread_utils.c",
    "src/src/utils/thread_utils.h",
    "src/src/utils/utils.c",
    "src/src/utils/utils.h",
  ]
  configs += [ ":libwebp_config" ]
  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [ "//build/config/compiler:no_chromium_code" ]
  if (set_opt_level) {
    configs -= [ "//build/config/compiler:default_optimization" ]
    configs += [ "//build/config/compiler:optimize_max" ]
  }

  public_configs = [ ":libwebp_public_config" ]

  deps = [
    ":libwebp_dsp_headers",
    ":libwebp_webp",
  ]
}

group("libwebp") {
  deps = [
    ":libwebp_dec",
    ":libwebp_demux",
    ":libwebp_dsp",
    ":libwebp_enc",
    ":libwebp_mux",
    ":libwebp_utils",
  ]
  public_deps = [ ":libwebp_webp" ]
  public_configs = [ ":libwebp_public_config" ]
  if (use_dsp_neon) {
    deps += [ ":libwebp_dsp_neon" ]
  }
}

###############################################################################
# Executables

if (current_toolchain == host_toolchain) {
  source_set("example_util") {
    sources = [
      "src/examples/example_util.c",
      "src/examples/example_util.h",
    ]
    configs -= [ "//build/config/compiler:chromium_code" ]
    configs += [ "//build/config/compiler:no_chromium_code" ]
    if (set_opt_level) {
      configs -= [ "//build/config/compiler:default_optimization" ]
      configs += [ "//build/config/compiler:optimize_max" ]
    }

    deps = [
      ":imageio_util",
      ":libwebp_webp",
    ]
    configs += [
      ":libwebp_public_config",
      ":libwebp_config",
    ]
    visibility = [ ":*" ]
  }

  source_set("imageio_util") {
    sources = [
      "src/examples/unicode.h",
      "src/imageio/imageio_util.c",
      "src/imageio/imageio_util.h",
    ]
    configs -= [ "//build/config/compiler:chromium_code" ]
    configs += [ "//build/config/compiler:no_chromium_code" ]
    if (set_opt_level) {
      configs -= [ "//build/config/compiler:default_optimization" ]
      configs += [ "//build/config/compiler:optimize_max" ]
    }

    deps = [ ":libwebp_webp" ]
    configs += [
      ":libwebp_public_config",
      ":libwebp_config",
    ]
    visibility = [ ":*" ]
  }

  source_set("imagedec") {
    sources = [
      "src/examples/unicode.h",
      "src/imageio/image_dec.c",
      "src/imageio/image_dec.h",
      "src/imageio/jpegdec.c",
      "src/imageio/jpegdec.h",
      "src/imageio/metadata.c",
      "src/imageio/metadata.h",
      "src/imageio/pngdec.c",
      "src/imageio/pngdec.h",
      "src/imageio/pnmdec.c",
      "src/imageio/pnmdec.h",
      "src/imageio/tiffdec.c",
      "src/imageio/tiffdec.h",
      "src/imageio/webpdec.c",
      "src/imageio/webpdec.h",
      "src/imageio/wicdec.c",
      "src/imageio/wicdec.h",
    ]
    defines = [ "WEBP_HAVE_PNG" ]
    configs += [ ":libwebp_config" ]
    configs -= [ "//build/config/compiler:chromium_code" ]
    configs += [ "//build/config/compiler:no_chromium_code" ]
    if (set_opt_level) {
      configs -= [ "//build/config/compiler:default_optimization" ]
      configs += [ "//build/config/compiler:optimize_max" ]
    }

    deps = [
      ":imageio_util",
      ":libwebp_webp",
      "//third_party/libpng",
      "//third_party/zlib",
    ]
    configs += [ ":libwebp_public_config" ]
    visibility = [ ":*" ]
  }

  source_set("imageenc") {
    sources = [
      "src/examples/unicode.h",
      "src/imageio/image_enc.c",
      "src/imageio/image_enc.h",
    ]
    configs += [ ":libwebp_config" ]
    configs -= [ "//build/config/compiler:chromium_code" ]
    configs += [ "//build/config/compiler:no_chromium_code" ]
    if (set_opt_level) {
      configs -= [ "//build/config/compiler:default_optimization" ]
      configs += [ "//build/config/compiler:optimize_max" ]
    }

    deps = [
      ":imageio_util",
      ":libwebp_webp",
    ]
    configs += [ ":libwebp_public_config" ]
    visibility = [ ":*" ]
  }

  executable("cwebp") {
    sources = [
      "src/examples/cwebp.c",
      "src/examples/stopwatch.h",
      "src/examples/unicode.h",
    ]

    deps = [
      ":example_util",
      ":imagedec",
      ":imageio_util",
      ":libwebp",
      ":libwebp_sharpyuv",
      ":libwebp_webp",
      "//base",
      "//build/win:default_exe_manifest",
    ]
    configs += [ ":libwebp_config" ]
    configs -= [ "//build/config/compiler:chromium_code" ]
    configs += [ "//build/config/compiler:no_chromium_code" ]
    if (set_opt_level) {
      configs -= [ "//build/config/compiler:default_optimization" ]
      configs += [ "//build/config/compiler:optimize_max" ]
    }
  }

  executable("dwebp") {
    sources = [
      "src/examples/dwebp.c",
      "src/examples/stopwatch.h",
      "src/examples/unicode.h",
    ]

    deps = [
      ":example_util",
      ":imagedec",
      ":imageenc",
      ":imageio_util",
      ":libwebp",
      ":libwebp_webp",
      "//base",
      "//build/win:default_exe_manifest",
    ]
    configs += [ ":libwebp_config" ]
    configs -= [ "//build/config/compiler:chromium_code" ]
    configs += [ "//build/config/compiler:no_chromium_code" ]
    if (set_opt_level) {
      configs -= [ "//build/config/compiler:default_optimization" ]
      configs += [ "//build/config/compiler:optimize_max" ]
    }
  }
}

################################################################################
# Fuzzers

fuzzer_test("libwebp_simple_api_fuzzer") {
  sources = [ "src/tests/fuzzer/simple_api_fuzzer.c" ]
  dict = "src/tests/fuzzer/fuzz.dict"
  seed_corpus = "fuzzing/fuzz_seed_corpus"
  deps = [
    ":libwebp",
    ":libwebp_webp",
  ]
  defines = [ "WEBP_MAX_IMAGE_SIZE=838860800" ]
  additional_configs = [ ":libwebp_config" ]
}

fuzzer_test("libwebp_advanced_api_fuzzer") {
  sources = [ "src/tests/fuzzer/advanced_api_fuzzer.c" ]
  dict = "src/tests/fuzzer/fuzz.dict"
  seed_corpus = "fuzzing/fuzz_seed_corpus"
  deps = [
    ":libwebp",
    ":libwebp_utils",
    ":libwebp_webp",
  ]
  defines = [ "WEBP_MAX_IMAGE_SIZE=838860800" ]
  additional_configs = [ ":libwebp_config" ]
}

fuzzer_test("libwebp_animation_api_fuzzer") {
  sources = [
    "src/src/demux/anim_decode.c",
    "src/tests/fuzzer/animation_api_fuzzer.c",
  ]
  dict = "src/tests/fuzzer/fuzz.dict"
  seed_corpus = "fuzzing/fuzz_seed_corpus"
  deps = [
    ":libwebp",
    ":libwebp_utils",
    ":libwebp_webp",
  ]
  defines = [ "WEBP_MAX_IMAGE_SIZE=838860800" ]
  additional_configs = [ ":libwebp_config" ]
}

fuzzer_test("libwebp_mux_demux_api_fuzzer") {
  sources = [ "src/tests/fuzzer/mux_demux_api_fuzzer.c" ]
  dict = "src/tests/fuzzer/fuzz.dict"
  seed_corpus = "fuzzing/fuzz_seed_corpus"
  deps = [
    ":libwebp",
    ":libwebp_webp",
  ]
  defines = [ "WEBP_MAX_IMAGE_SIZE=838860800" ]
  additional_configs = [ ":libwebp_config" ]
}

fuzzer_test("libwebp_animencoder_fuzzer") {
  sources = [ "src/tests/fuzzer/animencoder_fuzzer.cc" ]
  dict = "src/tests/fuzzer/fuzz.dict"
  seed_corpus = "fuzzing/fuzz_seed_corpus"
  deps = [
    ":libwebp",
    ":libwebp_webp",
  ]
  defines = [ "WEBP_MAX_IMAGE_SIZE=838860800" ]
  additional_configs = [ ":libwebp_config" ]
}

fuzzer_test("libwebp_enc_dec_api_fuzzer") {
  sources = [ "src/tests/fuzzer/enc_dec_fuzzer.cc" ]
  dict = "src/tests/fuzzer/fuzz.dict"
  seed_corpus = "fuzzing/fuzz_seed_corpus"
  deps = [
    ":libwebp",
    ":libwebp_webp",
  ]
  defines = [ "WEBP_MAX_IMAGE_SIZE=838860800" ]
  additional_configs = [ ":libwebp_config" ]
}

fuzzer_test("libwebp_huffman_fuzzer") {
  sources = [ "src/tests/fuzzer/huffman_fuzzer.c" ]
  deps = [
    ":libwebp",
    ":libwebp_dec",
    ":libwebp_utils",
    ":libwebp_webp",
  ]
  additional_configs = [ ":libwebp_config" ]
}