chromium/mojo/public/tools/fuzzers/BUILD.gn

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

# Mojo fuzzing tools

import("//build/config/features.gni")
import("//mojo/public/tools/bindings/mojom.gni")
import("//testing/libfuzzer/fuzzer_test.gni")
import("//third_party/protobuf/proto_library.gni")

# mojo/public BUILD depends on this target. Needed for package discovery
group("fuzzers") {
}

mojom("fuzz_mojom") {
  sources = [ "fuzz.mojom" ]
}

fuzzer_test("mojo_parse_message_fuzzer") {
  sources = [
    "fuzz_impl.cc",
    "mojo_parse_message_fuzzer.cc",
  ]
  deps = [
    ":fuzz_mojom",
    "//mojo/core/embedder",
  ]
  seed_corpus = "//mojo/public/tools/fuzzers/message_corpus"
}

# MessageDumper is not meant to work on Windows.
if (!is_win) {
  executable("mojo_fuzzer_message_dump") {
    sources = [
      "fuzz_impl.cc",
      "mojo_fuzzer_message_dump.cc",
    ]
    deps = [
      ":fuzz_mojom",
      "//base",
      "//mojo/core/embedder",
    ]
  }
}

fuzzer_test("mojo_parse_message_proto_fuzzer") {
  sources = [
    "fuzz_impl.cc",
    "mojo_parse_message_proto_fuzzer.cc",
  ]
  deps = [
    ":fuzz_mojom",
    ":mojo_fuzzer_proto",
    "//mojo/core/embedder",
    "//third_party/libprotobuf-mutator",
  ]
  seed_corpus = "//mojo/public/tools/fuzzers/mojo_parse_message_proto_corpus"
}

proto_library("mojo_fuzzer_proto") {
  sources = [ "mojo_fuzzer.proto" ]
}

proto_library("mojolpm_proto") {
  # Work relative to src (//) instead of (by default) the BUILD file.
  proto_in_dir = "//"

  sources = [ "mojolpm.proto" ]
  generate_python = false

  testonly = true
}

static_library("mojolpm") {
  sources = [
    "mojolpm.cc",
    "mojolpm.h",
  ]
  deps = [
    ":mojolpm_proto",
    "//base",
    "//mojo/public/cpp/bindings",
  ]
  testonly = true
}