chromium/skia/tools/fuzzers/BUILD.gn

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

import("//testing/libfuzzer/fuzzer_test.gni")
import("//third_party/skia/gn/shared_sources.gni")

group("fuzzers") {
}

# Build Skia fuzzers from OSS-Fuzz on Windows since Windows is not supported by
# OSS-Fuzz.
if (is_win && use_fuzzing_engine) {
  source_set("skia_fuzzer_sources") {
    testonly = true
    sources =
        [ "//skia/tools/fuzzers/fuzzer_environment.cc" ] + skia_base_fuzzer_srcs

    # Use public_deps and public_configs so each fuzzer_test doesn't need to
    # explicitly depend on "//skia" and "//skia:skia_library_config".
    public_deps = [ "//skia" ]
    public_configs = [ "//skia:skia_library_config" ]
    deps = [ "//base/test:test_support" ]
  }

  static_library("skia_encoder_fuzzer_lib") {
    sources = [ "//third_party/skia/fuzz/FuzzEncoders.cpp" ]
    configs += [ "//skia:skia_library_config" ]
    deps = [ "//skia" ]
  }

  config("skia_test_fonts_includes_config") {
    include_dirs = [
      "//third_party/skia/tools/fonts",
      "//third_party/skia/tools/",
    ]
  }

  static_library("skia_test_fonts") {
    sources = skia_font_tools
    configs += [ "//skia:skia_library_config" ]

    public_configs = [ ":skia_test_fonts_includes_config" ]
    deps = [ "//skia" ]
    check_includes = false  # Builds some private Skia files
  }

  # TODO(metzman): Enable the other fuzzers that cannot yet build in Chromium.
  fuzzer_test("skia_region_deserialize_fuzzer") {
    sources = [ "//third_party/skia/fuzz/oss_fuzz/FuzzRegionDeserialize.cpp" ]
    defines = [ "SK_BUILD_FOR_LIBFUZZER" ]
    deps = [ ":skia_fuzzer_sources" ]
  }

  fuzzer_test("skia_image_filter_deserialize_fuzzer") {
    sources =
        [ "//third_party/skia/fuzz/oss_fuzz/FuzzImageFilterDeserialize.cpp" ]
    defines = [ "SK_BUILD_FOR_LIBFUZZER" ]
    deps = [
      ":skia_fuzzer_sources",
      ":skia_test_fonts",
    ]
  }

  fuzzer_test("skia_region_set_path_fuzzer") {
    sources = [ "//third_party/skia/fuzz/oss_fuzz/FuzzRegionSetPath.cpp" ]
    defines = [ "SK_BUILD_FOR_LIBFUZZER" ]
    deps = [ ":skia_fuzzer_sources" ]
  }

  fuzzer_test("skia_textblob_deserialize_fuzzer") {
    sources = [ "//third_party/skia/fuzz/oss_fuzz/FuzzTextBlobDeserialize.cpp" ]
    defines = [ "SK_BUILD_FOR_LIBFUZZER" ]
    deps = [
      ":skia_fuzzer_sources",
      ":skia_test_fonts",
    ]
  }

  fuzzer_test("skia_path_deserialize_fuzzer") {
    sources = [ "//third_party/skia/fuzz/oss_fuzz/FuzzPathDeserialize.cpp" ]
    defines = [ "SK_BUILD_FOR_LIBFUZZER" ]
    deps = [ ":skia_fuzzer_sources" ]
  }

  fuzzer_test("skia_image_decode_fuzzer") {
    sources = [ "//third_party/skia/fuzz/oss_fuzz/FuzzImage.cpp" ]
    defines = [ "SK_BUILD_FOR_LIBFUZZER" ]
    deps = [ ":skia_fuzzer_sources" ]
  }

  fuzzer_test("skia_png_encoder_fuzzer") {
    sources = [ "//third_party/skia/fuzz/oss_fuzz/FuzzPNGEncoder.cpp" ]
    defines = [ "SK_BUILD_FOR_LIBFUZZER" ]
    deps = [
      ":skia_encoder_fuzzer_lib",
      ":skia_fuzzer_sources",
    ]
  }

  fuzzer_test("skia_jpeg_encoder_fuzzer") {
    sources = [ "//third_party/skia/fuzz/oss_fuzz/FuzzJPEGEncoder.cpp" ]
    defines = [ "SK_BUILD_FOR_LIBFUZZER" ]
    deps = [
      ":skia_encoder_fuzzer_lib",
      ":skia_fuzzer_sources",
    ]
  }

  fuzzer_test("skia_webp_encoder_fuzzer") {
    sources = [ "//third_party/skia/fuzz/oss_fuzz/FuzzWEBPEncoder.cpp" ]
    defines = [ "SK_BUILD_FOR_LIBFUZZER" ]
    deps = [
      ":skia_encoder_fuzzer_lib",
      ":skia_fuzzer_sources",
    ]
  }

  fuzzer_test("skia_skjson_fuzzer") {
    sources = [ "//third_party/skia/fuzz/oss_fuzz/FuzzJSON.cpp" ]
    defines = [ "SK_BUILD_FOR_LIBFUZZER" ]
    deps = [ ":skia_fuzzer_sources" ]
    check_includes = false
  }

  fuzzer_test("skia_image_decode_incremental_fuzzer") {
    sources = [ "//third_party/skia/fuzz/oss_fuzz/FuzzIncrementalImage.cpp" ]
    defines = [ "SK_BUILD_FOR_LIBFUZZER" ]
    deps = [ ":skia_fuzzer_sources" ]
  }
}