1 # Copyright 2017 The Chromium Authors
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
5 import("//build/config/sanitizers/sanitizers.gni")
6 import("//testing/libfuzzer/fuzzer_test.gni")
7 import("//third_party/libprotobuf-mutator/fuzzable_proto_library.gni")
9 config("main_config") {
10 cflags = [ "-Wno-shadow" ]
11 include_dirs = [ "src/" ]
14 source_set("libprotobuf-mutator") {
17 # Remove *San and coverage for a performance boost.
18 configs -= not_fuzzed_remove_configs
19 configs += [ "//build/config/sanitizers:not_fuzzed" ]
21 public_configs = [ ":main_config" ]
23 "src/src/binary_format.cc",
24 "src/src/libfuzzer/libfuzzer_macro.cc",
25 "src/src/libfuzzer/libfuzzer_mutator.cc",
27 "src/src/text_format.cc",
28 "src/src/utf8_fix.cc",
31 # Allow users of LPM to use protobuf reflection and other features from
33 public_deps = [ "//third_party/protobuf:protobuf_full" ]
35 # Let ClusterFuzz builders know to not build targets that depend on
36 # libprotobuf-mutator for AFL or Chrome OS.
37 if (use_afl || current_toolchain == "//build/toolchain/cros:target") {
38 all_dependent_configs = [ "//testing/libfuzzer:no_clusterfuzz" ]
42 # The CQ will try building this target without "use_libfuzzer" if it is defined.
43 # That will cause the build to fail, so don't define it when "use_libfuzzer" is
46 # Test that fuzzable_proto_library works. This target contains files that are
47 # optimized for LITE_RUNTIME and which import other files that are also
48 # optimized for LITE_RUNTIME.
49 fuzzer_test("lpm_test_fuzzer") {
50 sources = [ "test_fuzzer/test_fuzzer.cc" ]
52 ":libprotobuf-mutator",
53 ":lpm_test_fuzzer_proto",
56 # Don't actually run this on CF. It's only a test to ensure builds work.
57 additional_configs = [ "//testing/libfuzzer:no_clusterfuzz" ]
61 # Proto library for lpm_test_fuzzer
62 fuzzable_proto_library("lpm_test_fuzzer_proto") {
64 "test_fuzzer/imported.proto",
65 "test_fuzzer/imported_publicly.proto",
66 "test_fuzzer/test_fuzzer_input.proto",
70 # Avoid CQ complaints on platforms we don't care about (ie: iOS).
71 # Also prevent people from using this to include protobuf_full into a production
74 # Component that can provide protobuf_full to non-testonly targets
75 static_library("protobuf_full") {
76 public_deps = [ "//third_party/protobuf:protobuf_full" ]
77 sources = [ "dummy.cc" ]