1# Copyright 2017 The Chromium Authors. All rights reserved. 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5import("//build_overrides/build.gni") 6import("//testing/libfuzzer/fuzzer_test.gni") 7import("//third_party/libprotobuf-mutator/fuzzable_proto_library.gni") 8 9config("include_config") { 10 include_dirs = [ 11 "src/", 12 "//", 13 ] 14 cflags_cc = [ "-Wno-exit-time-destructors" ] 15} 16 17source_set("libprotobuf-mutator") { 18 testonly = true 19 20 configs += [ ":include_config" ] 21 public_configs = [ ":include_config" ] 22 sources = [ 23 "src/src/binary_format.cc", 24 "src/src/libfuzzer/libfuzzer_macro.cc", 25 "src/src/libfuzzer/libfuzzer_mutator.cc", 26 "src/src/mutator.cc", 27 "src/src/text_format.cc", 28 "src/src/utf8_fix.cc", 29 ] 30 31 # Allow users of LPM to use protobuf reflection and other features from 32 # protobuf_full. 33 public_deps = [ "//third_party/protobuf:protobuf_full" ] 34} 35 36# The CQ will try building this target without "use_libfuzzer" if it is defined. 37# That will cause the build to fail, so don't define it when "use_libfuzzer" is 38# is false. 39if (use_libfuzzer) { 40 # Test that fuzzable_proto_library works. This target contains files that are 41 # optimized for LITE_RUNTIME and which import other files that are also 42 # optimized for LITE_RUNTIME. 43 openscreen_fuzzer_test("lpm_test_fuzzer") { 44 sources = [ "test_fuzzer/test_fuzzer.cc" ] 45 deps = [ 46 ":libprotobuf-mutator", 47 ":lpm_test_fuzzer_proto", 48 ] 49 } 50} 51 52# Proto library for lpm_test_fuzzer 53fuzzable_proto_library("lpm_test_fuzzer_proto") { 54 sources = [ 55 "test_fuzzer/imported.proto", 56 "test_fuzzer/imported_publicly.proto", 57 "test_fuzzer/test_fuzzer_input.proto", 58 ] 59} 60 61# Avoid CQ complaints on platforms we don't care about (ie: iOS). 62# Also prevent people from using this to include protobuf_full into a production 63# build of Chrome. 64if (use_libfuzzer) { 65 # Component that can provide protobuf_full to non-testonly targets 66 static_library("protobuf_full") { 67 public_deps = [ "//third_party/protobuf:protobuf_full" ] 68 sources = [ "dummy.cc" ] 69 } 70} 71