aboutsummaryrefslogtreecommitdiff
path: root/third_party
diff options
context:
space:
mode:
authorJordan Bayles <jophba@chromium.org>2021-06-22 11:28:50 -0700
committerOpenscreen LUCI CQ <openscreen-scoped@luci-project-accounts.iam.gserviceaccount.com>2021-06-24 02:35:56 +0000
commitf3b911c8dbd011a8f96802ad6e3a4998799ebd9c (patch)
tree75044e00a7e4033bf8005222426d19c1a91e0773 /third_party
parent5139930c36d7f9e6949bbd5d9ec254aa111683d8 (diff)
downloadopenscreen-f3b911c8dbd011a8f96802ad6e3a4998799ebd9c.tar.gz
Fix GN check issues
This patch fixes various issues found through `gn check` throughout the repository, including some fuzzing issues. Bug: b/155434332 Change-Id: I2dffa42f5dfd291a7c59653eb7ca16ec680bfddb Reviewed-on: https://chromium-review.googlesource.com/c/openscreen/+/2964569 Reviewed-by: Ryan Keane <rwkeane@google.com> Commit-Queue: Jordan Bayles <jophba@chromium.org>
Diffstat (limited to 'third_party')
-rw-r--r--third_party/googletest/BUILD.gn28
-rw-r--r--third_party/jsoncpp/BUILD.gn1
-rw-r--r--third_party/libprotobuf-mutator/BUILD.gn53
-rw-r--r--third_party/libprotobuf-mutator/dummy.cc6
-rw-r--r--third_party/libprotobuf-mutator/fuzzable_proto_library.gni12
-rw-r--r--third_party/libprotobuf-mutator/test_fuzzer/imported.proto17
-rw-r--r--third_party/libprotobuf-mutator/test_fuzzer/imported_publicly.proto14
-rw-r--r--third_party/libprotobuf-mutator/test_fuzzer/test_fuzzer.cc16
-rw-r--r--third_party/libprotobuf-mutator/test_fuzzer/test_fuzzer_input.proto22
-rw-r--r--third_party/protobuf/BUILD.gn7
-rw-r--r--third_party/protobuf/proto_library.gni6
-rw-r--r--third_party/valijson/BUILD.gn2
12 files changed, 116 insertions, 68 deletions
diff --git a/third_party/googletest/BUILD.gn b/third_party/googletest/BUILD.gn
index 27006582..93705bbf 100644
--- a/third_party/googletest/BUILD.gn
+++ b/third_party/googletest/BUILD.gn
@@ -11,9 +11,7 @@ if (build_with_chromium) {
"//build/config/compiler:default_include_dirs",
"../../build:openscreen_include_dirs",
]
- public_deps = [
- "//third_party/googletest:gmock",
- ]
+ public_deps = [ "//third_party/googletest:gmock" ]
}
source_set("gtest") {
@@ -22,9 +20,7 @@ if (build_with_chromium) {
"//build/config/compiler:default_include_dirs",
"../../build:openscreen_include_dirs",
]
- public_deps = [
- "//third_party/googletest:gtest",
- ]
+ public_deps = [ "//third_party/googletest:gtest" ]
}
source_set("gtest_main") {
@@ -33,9 +29,7 @@ if (build_with_chromium) {
"//build/config/compiler:default_include_dirs",
"../../build:openscreen_include_dirs",
]
- public_deps = [
- "//third_party/googletest:gtest_main",
- ]
+ public_deps = [ "//third_party/googletest:gtest_main" ]
}
} else {
config("gmock_config") {
@@ -68,7 +62,7 @@ if (build_with_chromium) {
source_set("gmock") {
testonly = true
sources = [
- "src/googlemock/include/gmock.h",
+ "src/googlemock/include/gmock/gmock.h",
"src/googlemock/src/gmock-all.cc",
]
@@ -77,9 +71,7 @@ if (build_with_chromium) {
":gtest_config",
]
- public_deps = [
- ":gtest",
- ]
+ public_deps = [ ":gtest" ]
include_dirs = [ "src/googlemock" ]
}
@@ -87,7 +79,7 @@ if (build_with_chromium) {
source_set("gtest") {
testonly = true
sources = [
- "src/googletest/include/gtest.h",
+ "src/googletest/include/gtest/gtest.h",
"src/googletest/src/gtest-all.cc",
]
@@ -98,11 +90,7 @@ if (build_with_chromium) {
source_set("gtest_main") {
testonly = true
- sources = [
- "src/googletest/src/gtest_main.cc",
- ]
- deps = [
- ":gtest",
- ]
+ sources = [ "src/googletest/src/gtest_main.cc" ]
+ deps = [ ":gtest" ]
}
}
diff --git a/third_party/jsoncpp/BUILD.gn b/third_party/jsoncpp/BUILD.gn
index bc96a235..2350a72e 100644
--- a/third_party/jsoncpp/BUILD.gn
+++ b/third_party/jsoncpp/BUILD.gn
@@ -22,7 +22,6 @@ if (build_with_chromium) {
source_set("jsoncpp") {
sources = [
"src/include/json/allocator.h",
- "src/include/json/autolink.h",
"src/include/json/config.h",
"src/include/json/forwards.h",
"src/include/json/json.h",
diff --git a/third_party/libprotobuf-mutator/BUILD.gn b/third_party/libprotobuf-mutator/BUILD.gn
index cc3eeaeb..cc8c6a01 100644
--- a/third_party/libprotobuf-mutator/BUILD.gn
+++ b/third_party/libprotobuf-mutator/BUILD.gn
@@ -1,4 +1,4 @@
-# Copyright 2020 The Chromium Authors. All rights reserved.
+# Copyright 2017 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -7,14 +7,17 @@ import("//testing/libfuzzer/fuzzer_test.gni")
import("//third_party/libprotobuf-mutator/fuzzable_proto_library.gni")
config("include_config") {
- include_dirs = [ "src/" ]
+ include_dirs = [
+ "src/",
+ "//",
+ ]
+ cflags_cc = [ "-Wno-exit-time-destructors" ]
}
source_set("libprotobuf-mutator") {
testonly = true
configs += [ ":include_config" ]
-
public_configs = [ ":include_config" ]
sources = [
"src/src/binary_format.cc",
@@ -30,49 +33,28 @@ source_set("libprotobuf-mutator") {
public_deps = [ "//third_party/protobuf:protobuf_full" ]
}
-# This protoc plugin, like the compiler, should only be built for the host
-# architecture.
-if (current_toolchain == host_toolchain) {
- # This plugin will be needed to fuzz most protobuf code in Chromium. That's
- # because production protobuf code must contain the line:
- # "option optimize_for = LITE_RUNTIME", which instructs the proto compiler not
- # to compile the proto using the full protobuf runtime. This allows Chromium
- # not to depend on the full protobuf library, but prevents
- # libprotobuf-mutator from fuzzing because the lite runtime lacks needed
- # features (such as reflection). The plugin simply compiles a proto library
- # as normal but ensures that is compiled with the full protobuf runtime.
- executable("override_lite_runtime_plugin") {
- sources = [ "protoc_plugin/protoc_plugin.cc" ]
- deps = [ "//third_party/protobuf:protoc_lib" ]
- public_configs = [ "//third_party/protobuf:protobuf_config" ]
- }
- # To use the plugin in a proto_library you want to fuzz, change the build
- # target to fuzzable_proto_library (defined in
- # //third_party/libprotobuf-mutator/fuzzable_proto_library.gni)
-}
-
# The CQ will try building this target without "use_libfuzzer" if it is defined.
# That will cause the build to fail, so don't define it when "use_libfuzzer" is
# is false.
if (use_libfuzzer) {
- # Test that override_lite_runtime_plugin is working when built. This target
- # contains files that are optimized for LITE_RUNTIME and which import other
- # files that are also optimized for LITE_RUNTIME.
- openscreen_fuzzer_test("override_lite_runtime_plugin_test_fuzzer") {
- sources = [ "protoc_plugin/test_fuzzer.cc" ]
+ # Test that fuzzable_proto_library works. This target contains files that are
+ # optimized for LITE_RUNTIME and which import other files that are also
+ # optimized for LITE_RUNTIME.
+ openscreen_fuzzer_test("lpm_test_fuzzer") {
+ sources = [ "test_fuzzer/test_fuzzer.cc" ]
deps = [
":libprotobuf-mutator",
- ":override_lite_runtime_plugin_test_fuzzer_proto",
+ ":lpm_test_fuzzer_proto",
]
}
}
-# Proto library for override_lite_runtime_plugin_test_fuzzer
-fuzzable_proto_library("override_lite_runtime_plugin_test_fuzzer_proto") {
+# Proto library for lpm_test_fuzzer
+fuzzable_proto_library("lpm_test_fuzzer_proto") {
sources = [
- "protoc_plugin/imported.proto",
- "protoc_plugin/imported_publicly.proto",
- "protoc_plugin/test_fuzzer_input.proto",
+ "test_fuzzer/imported.proto",
+ "test_fuzzer/imported_publicly.proto",
+ "test_fuzzer/test_fuzzer_input.proto",
]
}
@@ -83,5 +65,6 @@ if (use_libfuzzer) {
# Component that can provide protobuf_full to non-testonly targets
static_library("protobuf_full") {
public_deps = [ "//third_party/protobuf:protobuf_full" ]
+ sources = [ "dummy.cc" ]
}
}
diff --git a/third_party/libprotobuf-mutator/dummy.cc b/third_party/libprotobuf-mutator/dummy.cc
new file mode 100644
index 00000000..8df1899d
--- /dev/null
+++ b/third_party/libprotobuf-mutator/dummy.cc
@@ -0,0 +1,6 @@
+// Copyright 2021 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+// Dummy file used to ensure that wrapper libraries get built on non-Linux
+// platforms. \ No newline at end of file
diff --git a/third_party/libprotobuf-mutator/fuzzable_proto_library.gni b/third_party/libprotobuf-mutator/fuzzable_proto_library.gni
index fee136c6..2d357db7 100644
--- a/third_party/libprotobuf-mutator/fuzzable_proto_library.gni
+++ b/third_party/libprotobuf-mutator/fuzzable_proto_library.gni
@@ -6,7 +6,7 @@
# non-fuzzer builds (ie: use_libfuzzer=false). However, in fuzzer builds, the
# proto_library is built with the full protobuf runtime and any "optimize_for =
# LITE_RUNTIME" options are ignored. This is done because libprotobuf-mutator
-# needs the full protobuf runtime, but proto_libraries shipped in chrome must
+# needs the full protobuf runtime, but proto_libraries shipped in Chrome must
# use the optimize for LITE_RUNTIME option which is incompatible with the full
# protobuf runtime. tl;dr: A fuzzable_proto_library is a proto_library that can
# be fuzzed with libprotobuf-mutator and shipped in Chrome.
@@ -16,18 +16,12 @@ import("//testing/libfuzzer/fuzzer_test.gni")
import("//third_party/protobuf/proto_library.gni")
template("fuzzable_proto_library") {
- # Only make the proto library fuzzable if we are doing a build that we can
- # use LPM on (i.e. libFuzzer not on Chrome OS).
- if (use_libfuzzer && current_toolchain != "//build/toolchain/cros:target") {
+ if (use_libfuzzer) {
proto_library("proto_library_" + target_name) {
forward_variables_from(invoker, "*")
assert(current_toolchain == host_toolchain)
- if (!defined(proto_deps)) {
- proto_deps = []
- }
- proto_deps +=
- [ "//third_party/libprotobuf-mutator:override_lite_runtime_plugin" ]
+ cc_generator_options = "speed"
extra_configs = [ "//third_party/protobuf:protobuf_config" ]
}
diff --git a/third_party/libprotobuf-mutator/test_fuzzer/imported.proto b/third_party/libprotobuf-mutator/test_fuzzer/imported.proto
new file mode 100644
index 00000000..f347c366
--- /dev/null
+++ b/third_party/libprotobuf-mutator/test_fuzzer/imported.proto
@@ -0,0 +1,17 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Ensure imported files are handled properly. This file is imported by
+// test_fuzzer_input.proto and imports imported_publicly publicly.
+
+syntax = "proto2";
+option optimize_for = LITE_RUNTIME;
+package lpm_test_fuzzer;
+
+// Test public imported files are handled properly.
+import public "imported_publicly.proto";
+
+message Imported {
+ required ImportedPublicly imported_publicly = 1;
+}
diff --git a/third_party/libprotobuf-mutator/test_fuzzer/imported_publicly.proto b/third_party/libprotobuf-mutator/test_fuzzer/imported_publicly.proto
new file mode 100644
index 00000000..10768495
--- /dev/null
+++ b/third_party/libprotobuf-mutator/test_fuzzer/imported_publicly.proto
@@ -0,0 +1,14 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Ensure publicly imported files are handled properly. This file is imported
+// publicly by test_fuzzer_input2.proto
+
+syntax = "proto2";
+option optimize_for = LITE_RUNTIME;
+package lpm_test_fuzzer;
+
+message ImportedPublicly {
+ required int32 input = 1;
+}
diff --git a/third_party/libprotobuf-mutator/test_fuzzer/test_fuzzer.cc b/third_party/libprotobuf-mutator/test_fuzzer/test_fuzzer.cc
new file mode 100644
index 00000000..e7af5346
--- /dev/null
+++ b/third_party/libprotobuf-mutator/test_fuzzer/test_fuzzer.cc
@@ -0,0 +1,16 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Test fuzzer that when built successfully proves that fuzzable_proto_library
+// is working. Building this fuzzer without using fuzzable_proto_library will
+// fail because of test_fuzzer_input.proto
+
+#include <iostream>
+
+#include "third_party/libprotobuf-mutator/src/src/libfuzzer/libfuzzer_macro.h"
+#include "third_party/libprotobuf-mutator/test_fuzzer/test_fuzzer_input.pb.h"
+
+DEFINE_PROTO_FUZZER(const lpm_test_fuzzer::TestFuzzerInput& input) {
+ std::cout << input.imported().imported_publicly().input() << std::endl;
+}
diff --git a/third_party/libprotobuf-mutator/test_fuzzer/test_fuzzer_input.proto b/third_party/libprotobuf-mutator/test_fuzzer/test_fuzzer_input.proto
new file mode 100644
index 00000000..45645fc9
--- /dev/null
+++ b/third_party/libprotobuf-mutator/test_fuzzer/test_fuzzer_input.proto
@@ -0,0 +1,22 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Depended on by lpm_test_fuzzer. Tests whether fuzzable_proto_library is
+// working since without it builds will fail because of the optimize_for
+// LITE_RUNTIME option this file has set. Also imports a file that does the same
+// thing.
+
+syntax = "proto2";
+
+// This line is essentially the purpose of this test fuzzer. The build rule, if
+// working, ignores this line. If it is not working or isn't used, then this
+// build will fail.
+option optimize_for = LITE_RUNTIME;
+
+package lpm_test_fuzzer;
+import "imported.proto";
+
+message TestFuzzerInput {
+ required Imported imported = 1;
+} \ No newline at end of file
diff --git a/third_party/protobuf/BUILD.gn b/third_party/protobuf/BUILD.gn
index 13793df7..1616b80e 100644
--- a/third_party/protobuf/BUILD.gn
+++ b/third_party/protobuf/BUILD.gn
@@ -29,6 +29,7 @@ config("protobuf_warnings") {
"-Wno-extra-semi",
"-Wno-unneeded-internal-declaration",
"-Wno-unused-private-field",
+ "-Wno-inconsistent-missing-override",
]
}
@@ -73,7 +74,6 @@ lite_sources = [
"src/src/google/protobuf/has_bits.h",
"src/src/google/protobuf/implicit_weak_message.cc",
"src/src/google/protobuf/implicit_weak_message.h",
- "src/src/google/protobuf/inlined_string_field.h",
"src/src/google/protobuf/io/coded_stream.cc",
"src/src/google/protobuf/io/coded_stream.h",
"src/src/google/protobuf/io/io_win32.cc",
@@ -103,7 +103,6 @@ lite_sources = [
"src/src/google/protobuf/stubs/casts.h",
"src/src/google/protobuf/stubs/common.cc",
"src/src/google/protobuf/stubs/common.h",
- "src/src/google/protobuf/stubs/fastmem.h",
"src/src/google/protobuf/stubs/hash.h",
"src/src/google/protobuf/stubs/int128.cc",
"src/src/google/protobuf/stubs/int128.h",
@@ -313,6 +312,8 @@ if (current_toolchain == host_toolchain) {
"src/src/google/protobuf/compiler/cpp/cpp_options.h",
"src/src/google/protobuf/compiler/cpp/cpp_padding_optimizer.cc",
"src/src/google/protobuf/compiler/cpp/cpp_padding_optimizer.h",
+ "src/src/google/protobuf/compiler/cpp/cpp_parse_function_generator.cc",
+ "src/src/google/protobuf/compiler/cpp/cpp_parse_function_generator.h",
"src/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc",
"src/src/google/protobuf/compiler/cpp/cpp_primitive_field.h",
"src/src/google/protobuf/compiler/cpp/cpp_service.cc",
@@ -378,6 +379,8 @@ if (current_toolchain == host_toolchain) {
"src/src/google/protobuf/compiler/java/java_generator_factory.h",
"src/src/google/protobuf/compiler/java/java_helpers.cc",
"src/src/google/protobuf/compiler/java/java_helpers.h",
+ "src/src/google/protobuf/compiler/java/java_kotlin_generator.cc",
+ "src/src/google/protobuf/compiler/java/java_kotlin_generator.h",
"src/src/google/protobuf/compiler/java/java_map_field.cc",
"src/src/google/protobuf/compiler/java/java_map_field.h",
"src/src/google/protobuf/compiler/java/java_map_field_lite.cc",
diff --git a/third_party/protobuf/proto_library.gni b/third_party/protobuf/proto_library.gni
index 7bbc73b7..9c550457 100644
--- a/third_party/protobuf/proto_library.gni
+++ b/third_party/protobuf/proto_library.gni
@@ -58,6 +58,12 @@ template("proto_library") {
rel_cc_out_dir,
]
+ if (defined(invoker.cc_generator_options)) {
+ args += [
+ "--cc-options",
+ invoker.cc_generator_options,
+ ]
+ }
inputs = [ protoc_path ]
deps = [ protoc_label ]
}
diff --git a/third_party/valijson/BUILD.gn b/third_party/valijson/BUILD.gn
index 8df84598..b7286470 100644
--- a/third_party/valijson/BUILD.gn
+++ b/third_party/valijson/BUILD.gn
@@ -22,7 +22,7 @@ if (!build_with_chromium) {
# We only need the adapter for JsonCpp.
"src/include/valijson/adapters/jsoncpp_adapter.hpp",
- "src/include/valijson/constraints_builder.hpp",
+ "src/include/valijson/constraint_builder.hpp",
"src/include/valijson/internal/custom_allocator.hpp",
"src/include/valijson/internal/debug.hpp",
"src/include/valijson/internal/json_pointer.hpp",