Commit e4e1221c authored by Scott Violet's avatar Scott Violet Committed by Commit Bot

Revert "Reland "Adding mojolpm fuzzer.""

This reverts commit cc205c1f.

Reason for revert: This looks to have broken linux-archive-rel.
I'm guessing DEPS are wrong.
https://ci.chromium.org/p/chromium/builders/ci/linux-archive-rel/24465
[48678/80681] CXX obj/chrome/common/importer/interfaces_mojolpm/profile_import.mojom-mojolpm.o
FAILED: obj/chrome/common/importer/interfaces_mojolpm/profile_import.mojom-mojolpm.o 
/b/s/w/ir/cache/goma/client/gomacc ../../third_party/llvm-build/Release+Asserts/bin/clang++ -MMD -MF obj/chrome/common/importer/interfaces_mojolpm/profile_import.mojom-mojolpm.o.d -DUSE_UDEV -DUSE_AURA=1 -DUSE_GLIB=1 -DUSE_NSS_CERTS=1 -DUSE_X11=1 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_GNU_SOURCE -DCR_CLANG_REVISION=\"n344329-9284abd0-6\" -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D_FORTIFY_SOURCE=2 -D_LIBCPP_ABI_UNSTABLE -D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS -D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS -D_LIBCPP_ENABLE_NODISCARD -DCR_LIBCXX_REVISION=375504 -DCR_SYSROOT_HASH=79a7783607a69b6f439add567eb6fcb48877085c -DNDEBUG -DNVALGRIND -DDYNAMIC_ANNOTATIONS_ENABLED=0 -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_40 -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_40 -DENABLE_IPC_FUZZER -DWEBP_EXTERN=extern -DGOOGLE_PROTOBUF_NO_RTTI -DGOOGLE_PROTOBUF_NO_STATIC_INITIALIZER -DHAVE_PTHREAD -DSK_CODEC_DECODES_PNG -DSK_CODEC_DECODES_WEBP -DSK_ENCODE_PNG -DSK_ENCODE_WEBP -DSK_HAS_PNG_LIBRARY -DSK_HAS_WEBP_LIBRARY -DSK_USER_CONFIG_HEADER=\"../../skia/config/SkUserConfig.h\" -DSK_GL -DSK_CODEC_DECODES_JPEG -DSK_ENCODE_JPEG -DSK_HAS_JPEG_LIBRARY -DSK_USE_LIBGIFCODEC -DSK_VULKAN_HEADER=\"../../skia/config/SkVulkanConfig.h\" -DSK_VULKAN=1 -DSK_SUPPORT_GPU=1 -DSK_GPU_WORKAROUNDS_HEADER=\"gpu/config/gpu_driver_bug_workaround_autogen.h\" -DVK_NO_PROTOTYPES -DU_USING_ICU_NAMESPACE=0 -DU_ENABLE_DYLOAD=0 -DUSE_CHROMIUM_ICU=1 -DU_ENABLE_TRACING=1 -DU_ENABLE_RESOURCE_TRACING=0 -DU_STATIC_IMPLEMENTATION -DICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_FILE -DUCHAR_TYPE=uint16_t -DWEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS=0 -DWEBRTC_CHROMIUM_BUILD -DWEBRTC_POSIX -DWEBRTC_LINUX -DABSL_ALLOCATOR_NOTHROW=1 -DWEBRTC_USE_BUILTIN_ISAC_FIX=0 -DWEBRTC_USE_BUILTIN_ISAC_FLOAT=1 -DWEBRTC_USE_X11 -DHAVE_SCTP -DNO_MAIN_THREAD_WRAPPING -I../.. -Igen -I../../third_party/libwebp/src -I../../third_party/libyuv/include -I../../third_party/jsoncpp/source/include -I../../third_party/jsoncpp/generated -I../../third_party/protobuf/src -Igen/protoc_out -Igen -Igen/out/Release/gen -I../../third_party/protobuf/src -Igen -Igen/out/Release/gen -Igen -Igen/out/Release/gen -Igen -Igen/out/Release/gen -Igen -Igen/out/Release/gen -Igen -Igen/out/Release/gen -I../../third_party/skia -I../../third_party/libgifcodec -I../../third_party/vulkan/include -I../../third_party/skia/third_party/vulkanmemoryallocator -I../../third_party/vulkan/include -I../../third_party/boringssl/src/include -I../../third_party/icu/source/common -I../../third_party/icu/source/i18n -I../../third_party/perfetto/include -Igen/third_party/perfetto/build_config -Igen/third_party/perfetto -I../../third_party/webrtc_overrides -I../../third_party/webrtc -Igen/third_party/webrtc -I../../third_party/abseil-cpp -fno-strict-aliasing --param=ssp-buffer-size=4 -fstack-protector -funwind-tables -fPIC -B../../third_party/binutils/Linux_x64/Release/bin -pthread -fcolor-diagnostics -fmerge-all-constants -fcrash-diagnostics-dir=../../tools/clang/crashreports -Xclang -mllvm -Xclang -instcombine-lower-dbg-declare=0 -fcomplete-member-pointers -m64 -march=x86-64 -Wno-builtin-macro-redefined -D__DATE__= -D__TIME__= -D__TIMESTAMP__= -Xclang -fdebug-compilation-dir -Xclang . -no-canonical-prefixes -Wall -Werror -Wextra -Wimplicit-fallthrough -Wthread-safety -Wextra-semi -Wno-missing-field-initializers -Wno-unused-parameter -Wno-c++11-narrowing -Wno-unneeded-internal-declaration -Wno-undefined-var-template -Wno-ignored-pragma-optimize -Wno-implicit-int-float-conversion -Wno-final-dtor-non-final-class -Wno-builtin-assume-aligned-alignment -Wno-deprecated-copy -Wno-non-c-typedef-for-linkage -O2 -fno-ident -fdata-sections -ffunction-sections -fno-omit-frame-pointer -g0 -ftrivial-auto-var-init=pattern -fvisibility=hidden -Xclang -add-plugin -Xclang find-bad-constructs -Xclang -plugin-arg-find-bad-constructs -Xclang check-ipc -Wheader-hygiene -Wstring-conversion -Wtautological-overlap-compare -isystem../../build/linux/debian_sid_amd64-sysroot/usr/include/glib-2.0 -isystem../../build/linux/debian_sid_amd64-sysroot/usr/lib/x86_64-linux-gnu/glib-2.0/include -Wno-shorten-64-to-32 -std=c++14 -fno-exceptions -fno-rtti -nostdinc++ -isystem../../buildtools/third_party/libc++/trunk/include -isystem../../buildtools/third_party/libc++abi/trunk/include --sysroot=../../build/linux/debian_sid_amd64-sysroot -fvisibility-inlines-hidden -Wno-deprecated-declarations -c gen/chrome/common/importer/profile_import.mojom-mojolpm.cc -o obj/chrome/common/importer/interfaces_mojolpm/profile_import.mojom-mojolpm.o
In file included from gen/chrome/common/importer/profile_import.mojom-mojolpm.cc:17:
In file included from ../../chrome/common/importer/profile_import_process_param_traits.h:8:
In file included from ../../chrome/common/importer/profile_import_process_param_traits_macros.h:23:
In file included from ../../content/public/common/common_param_traits.h:24:
In file included from ../../content/public/common/common_param_traits_macros.h:15:
../../content/public/common/web_preferences.h:18:10: fatal error: 'third_party/blink/public/mojom/v8_cache_options.mojom.h' file not found
#include "third_party/blink/public/mojom/v8_cache_options.mojom.h"
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

Original change's description:
> Reland "Adding mojolpm fuzzer."
> 
> This is a reland of 96b8d308
> 
> Original change's description:
> > Adding mojolpm fuzzer.
> >
> > This adds code that generates libprotobuf-mutator based
> > structure-aware fuzzers as part of the mojom compilation process.
> > (changes in //mojo).
> >
> > It also adds a fuzzer for CodeCacheHost using this framework to demonstrate
> > how it will be used, and documentation explaining that fuzzer and how to use
> > this generator to write new fuzzers. (changes in //content/test).
> >
> > It finally includes a few changes to typemap and traits files that
> > were necessary to smooth over some inconsistencies in existing code
> > using mojo.
> >
> > Bug: 941849
> > Change-Id: I660a57bd90c0963bd9a0b8608c746cdb767edc98
> > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1978739
> > Commit-Queue: Mark Brand <markbrand@google.com>
> > Auto-Submit: Mark Brand <markbrand@google.com>
> > Reviewed-by: Peter Kasting <pkasting@chromium.org>
> > Reviewed-by: Daniel Cheng <dcheng@chromium.org>
> > Reviewed-by: Ted Meyer <tmathmeyer@chromium.org>
> > Reviewed-by: Oliver Chang <ochang@chromium.org>
> > Reviewed-by: Ken Rockot <rockot@google.com>
> > Cr-Commit-Position: refs/heads/master@{#746827}
> 
> Bug: 941849
> Change-Id: I01feb96401e1c9cbd3bbb2bf2a22ecc253d36b4e
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2087408
> Commit-Queue: Peter Kasting <pkasting@chromium.org>
> Reviewed-by: Peter Kasting <pkasting@chromium.org>
> Reviewed-by: Oliver Chang <ochang@chromium.org>
> Reviewed-by: Matthew Denton <mpdenton@chromium.org>
> Reviewed-by: Daniel Cheng <dcheng@chromium.org>
> Reviewed-by: David Roger <droger@chromium.org>
> Reviewed-by: Ken Rockot <rockot@google.com>
> Reviewed-by: Ted Meyer <tmathmeyer@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#751464}

TBR=pkasting@chromium.org,dcheng@chromium.org,droger@chromium.org,rockot@google.com,ochang@chromium.org,markbrand@google.com,mpdenton@google.com,tmathmeyer@chromium.org,mpdenton@chromium.org

Change-Id: If628a61fbfa40c17aa25752317263d7a79a4fb9f
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 941849
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2109280Reviewed-by: default avatarScott Violet <sky@chromium.org>
Commit-Queue: Scott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#751526}
parent 905b76df
...@@ -10,7 +10,4 @@ per-file *_param_traits*.*=file://ipc/SECURITY_OWNERS ...@@ -10,7 +10,4 @@ per-file *_param_traits*.*=file://ipc/SECURITY_OWNERS
per-file *.mojom=set noparent per-file *.mojom=set noparent
per-file *.mojom=file://ipc/SECURITY_OWNERS per-file *.mojom=file://ipc/SECURITY_OWNERS
per-file *.typemap=set noparent
per-file *.typemap=file://ipc/SECURITY_OWNERS
# COMPONENT: UI>Browser>Import # COMPONENT: UI>Browser>Import
...@@ -12,7 +12,7 @@ public_headers = [ ...@@ -12,7 +12,7 @@ public_headers = [
] ]
traits_headers = traits_headers =
[ "//chrome/common/importer/profile_import_process_param_traits.h" ] [ "//chrome/common/importer/profile_import_process_param_traits.h" ]
public_deps = [ deps = [
"//chrome/common", "//chrome/common",
"//components/favicon_base", "//components/favicon_base",
"//ipc", "//ipc",
......
...@@ -5,4 +5,7 @@ ...@@ -5,4 +5,7 @@
mojom = "//content/public/common/web_preferences.mojom" mojom = "//content/public/common/web_preferences.mojom"
public_headers = [ "//content/public/common/web_preferences.h" ] public_headers = [ "//content/public/common/web_preferences.h" ]
traits_headers = [ "//content/public/common/common_param_traits_macros.h" ] traits_headers = [ "//content/public/common/common_param_traits_macros.h" ]
type_mappings = [ "content.mojom.WebPreferences=::content::WebPreferences" ] type_mappings = [
"content.mojom.V8CacheOptions=::content::V8CacheOptions",
"content.mojom.WebPreferences=::content::WebPreferences",
]
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
import("//testing/libfuzzer/fuzzer_test.gni") import("//testing/libfuzzer/fuzzer_test.gni")
import("//third_party/protobuf/proto_library.gni") import("//third_party/protobuf/proto_library.gni")
import("//tools/ipc_fuzzer/ipc_fuzzer.gni")
# Empty group for package discovery. # Empty group for package discovery.
group("fuzzer") { group("fuzzer") {
...@@ -162,47 +161,6 @@ fuzzer_test("appcache_fuzzer") { ...@@ -162,47 +161,6 @@ fuzzer_test("appcache_fuzzer") {
] ]
} }
if (enable_ipc_fuzzer) {
copy("code_cache_host_mojolpm_fuzzer_proto_copy") {
sources = [ "code_cache_host_mojolpm_fuzzer.proto" ]
outputs = [ "$root_gen_dir/code_cache_host_mojolpm_fuzzer.proto" ]
testonly = true
}
proto_library("code_cache_host_mojolpm_fuzzer_proto") {
sources = [ "$root_gen_dir/code_cache_host_mojolpm_fuzzer.proto" ]
generate_python = false
# TODO(markbrand): this is kind of a hack, but it works. not sure if it's
# the best way to get this generated in the right place though.
proto_out_dir = "content/test/fuzzer/../../../"
proto_deps = [
":code_cache_host_mojolpm_fuzzer_proto_copy",
"//third_party/blink/public/mojom:mojom_platform_mojolpm",
]
link_deps = [ "//third_party/blink/public/mojom:mojom_platform_mojolpm" ]
testonly = true
}
fuzzer_test("code_cache_host_mojolpm_fuzzer") {
sources = [ "code_cache_host_mojolpm_fuzzer.cc" ]
deps = [
":code_cache_host_mojolpm_fuzzer_proto",
"//base/test:test_support",
"//content/browser:for_content_tests",
"//content/public/browser:browser_sources",
"//content/test:test_support",
"//mojo/core/embedder",
"//mojo/public/tools/fuzzers:mojolpm",
"//services/network:test_support",
"//storage/browser:test_support",
"//third_party/blink/public/mojom:mojom_modules_mojolpm",
"//third_party/libprotobuf-mutator",
]
}
}
# Note: this compiles and runs on Mac but may cause # Note: this compiles and runs on Mac but may cause
# system instability; if you try it out, close other # system instability; if you try it out, close other
# programs and then reboot afterwards. It should be # programs and then reboot afterwards. It should be
......
This diff is collapsed.
syntax = "proto2";
package content.fuzzing.code_cache_host.proto;
import "third_party/blink/public/mojom/loader/code_cache.mojom.mojolpm.proto";
message NewCodeCacheHost {
enum OriginId {
ORIGIN_A = 0;
ORIGIN_B = 1;
ORIGIN_OPAQUE = 2;
ORIGIN_EMPTY = 3;
}
required uint32 id = 1;
required uint32 render_process_id = 2;
required OriginId origin_id = 3;
}
message RunUntilIdle {
enum ThreadId {
IO = 0;
UI = 1;
}
required ThreadId id = 1;
}
message Action {
oneof action {
NewCodeCacheHost new_code_cache_host = 1;
RunUntilIdle run_until_idle = 2;
mojolpm.blink.mojom.CodeCacheHost.RemoteMethodCall code_cache_host_call = 3;
}
}
message Sequence {
repeated Action actions = 1;
}
message Testcase {
repeated Sequence sequences = 1;
}
\ No newline at end of file
...@@ -250,13 +250,6 @@ mojom("gpu_preferences_interface") { ...@@ -250,13 +250,6 @@ mojom("gpu_preferences_interface") {
mojom("vulkan_interface") { mojom("vulkan_interface") {
generate_java = true generate_java = true
# TODO(1062364): This interface code is used by some javascript targets even
# when vulkan isn't enabled, but the C++ fuzzer code will fail to compile if
# the headers aren't available.
if (!enable_vulkan) {
enable_fuzzing = false
}
sources = [ sources = [
"vulkan_info.mojom", "vulkan_info.mojom",
"vulkan_types.mojom", "vulkan_types.mojom",
......
...@@ -284,22 +284,6 @@ module gpu.mojom; ...@@ -284,22 +284,6 @@ module gpu.mojom;
WriteMojomTypes(_STRUCTS, mojom_file) WriteMojomTypes(_STRUCTS, mojom_file)
def NormalizedCamelCase(identifier):
result = identifier[0].upper()
lowercase_next = True
for i in range(1, len(identifier)):
if identifier[i].isupper():
if lowercase_next:
result += identifier[i].lower()
else:
result += identifier[i]
lowercase_next = True
else:
lowercase_next = False
result += identifier[i]
return result
def WriteStructTraits(name, traits_header_file, traits_source_file): def WriteStructTraits(name, traits_header_file, traits_source_file):
traits_header_file.write( traits_header_file.write(
""" """
...@@ -366,7 +350,7 @@ bool StructTraits<gpu::mojom::%sDataView, %s>::Read( ...@@ -366,7 +350,7 @@ bool StructTraits<gpu::mojom::%sDataView, %s>::Read(
if field_type == "char": if field_type == "char":
assert array_len assert array_len
read_method = "Read%s" % (NormalizedCamelCase(field_name)) read_method = "Read%s%s" % (field_name[0].upper(), field_name[1:])
traits_source_file.write( traits_source_file.write(
""" """
base::StringPiece %s; base::StringPiece %s;
...@@ -375,7 +359,7 @@ bool StructTraits<gpu::mojom::%sDataView, %s>::Read( ...@@ -375,7 +359,7 @@ bool StructTraits<gpu::mojom::%sDataView, %s>::Read(
%s.copy(out->%s, sizeof(out->%s)); %s.copy(out->%s, sizeof(out->%s));
""" % (field_name, read_method, field_name, field_name, field_name, field_name)) """ % (field_name, read_method, field_name, field_name, field_name, field_name))
elif array_len: elif array_len:
read_method = "Read%s" % (NormalizedCamelCase(field_name)) read_method = "Read%s%s" % (field_name[0].upper(), field_name[1:])
traits_source_file.write( traits_source_file.write(
""" """
base::span<%s> %s(out->%s); base::span<%s> %s(out->%s);
...@@ -385,9 +369,9 @@ bool StructTraits<gpu::mojom::%sDataView, %s>::Read( ...@@ -385,9 +369,9 @@ bool StructTraits<gpu::mojom::%sDataView, %s>::Read(
elif field_type in _structs or field_type in _enums: elif field_type in _structs or field_type in _enums:
traits_source_file.write( traits_source_file.write(
""" """
if (!data.Read%s(&out->%s)) if (!data.Read%s%s(&out->%s))
return false; return false;
""" % (NormalizedCamelCase(field_name), field_name)) """ % (field_name[0].upper(), field_name[1:], field_name))
else: else:
traits_source_file.write( traits_source_file.write(
""" """
......
...@@ -69,7 +69,7 @@ bool StructTraits<gpu::mojom::VkPhysicalDevicePropertiesDataView, ...@@ -69,7 +69,7 @@ bool StructTraits<gpu::mojom::VkPhysicalDevicePropertiesDataView,
deviceName.copy(out->deviceName, sizeof(out->deviceName)); deviceName.copy(out->deviceName, sizeof(out->deviceName));
base::span<uint8_t> pipelineCacheUUID(out->pipelineCacheUUID); base::span<uint8_t> pipelineCacheUUID(out->pipelineCacheUUID);
if (!data.ReadPipelineCacheUuid(&pipelineCacheUUID)) if (!data.ReadPipelineCacheUUID(&pipelineCacheUUID))
return false; return false;
if (!data.ReadLimits(&out->limits)) if (!data.ReadLimits(&out->limits))
......
...@@ -28,6 +28,10 @@ enum BufferingStateChangeReason; ...@@ -28,6 +28,10 @@ enum BufferingStateChangeReason;
[Native] [Native]
enum ChannelLayout; enum ChannelLayout;
// See media/base/video_types.h for descriptions.
[Native]
enum ColorSpace;
// See media/base/decode_status.h for descriptions. // See media/base/decode_status.h for descriptions.
[Native] [Native]
enum DecodeStatus; enum DecodeStatus;
......
...@@ -50,6 +50,7 @@ type_mappings = [ ...@@ -50,6 +50,7 @@ type_mappings = [
"media.mojom.BufferingState=::media::BufferingState", "media.mojom.BufferingState=::media::BufferingState",
"media.mojom.BufferingStateChangeReason=::media::BufferingStateChangeReason", "media.mojom.BufferingStateChangeReason=::media::BufferingStateChangeReason",
"media.mojom.ChannelLayout=::media::ChannelLayout", "media.mojom.ChannelLayout=::media::ChannelLayout",
"media.mojom.ColorSpace=::media::ColorSpace",
"media.mojom.DecodeStatus=::media::DecodeStatus", "media.mojom.DecodeStatus=::media::DecodeStatus",
"media.mojom.EncryptionScheme=::media::EncryptionScheme", "media.mojom.EncryptionScheme=::media::EncryptionScheme",
"media.mojom.MediaContainerName=::media::container_names::MediaContainerName", "media.mojom.MediaContainerName=::media::container_names::MediaContainerName",
......
...@@ -11,6 +11,9 @@ namespace media { ...@@ -11,6 +11,9 @@ namespace media {
Vp8Metadata::Vp8Metadata() Vp8Metadata::Vp8Metadata()
: non_reference(false), temporal_idx(0), layer_sync(false) {} : non_reference(false), temporal_idx(0), layer_sync(false) {}
Vp8Metadata::Vp8Metadata(const Vp8Metadata& other) = default;
Vp8Metadata::Vp8Metadata(Vp8Metadata&& other) = default;
Vp8Metadata::~Vp8Metadata() = default;
BitstreamBufferMetadata::BitstreamBufferMetadata() BitstreamBufferMetadata::BitstreamBufferMetadata()
: payload_size_bytes(0), key_frame(false) {} : payload_size_bytes(0), key_frame(false) {}
......
...@@ -39,6 +39,9 @@ class VideoFrame; ...@@ -39,6 +39,9 @@ class VideoFrame;
// temporal_idx > 0. // temporal_idx > 0.
struct MEDIA_EXPORT Vp8Metadata final { struct MEDIA_EXPORT Vp8Metadata final {
Vp8Metadata(); Vp8Metadata();
Vp8Metadata(const Vp8Metadata& other);
Vp8Metadata(Vp8Metadata&& other);
~Vp8Metadata();
bool non_reference; bool non_reference;
uint8_t temporal_idx; uint8_t temporal_idx;
bool layer_sync; bool layer_sync;
......
This diff is collapsed.
// Copyright 2019 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.
{%- set header_guard = "%s_MOJOLPM_H_"|format(
module.path|upper|replace("/","_")|replace(".","_")|
replace("-", "_")) %}
{%- macro namespace_begin() %}
namespace mojolpm {
{%- for namespace in namespaces_as_array %}
namespace {{namespace}} {
{%- endfor %}
{%- endmacro %}
{%- macro namespace_end() %}
{%- for namespace in namespaces_as_array|reverse %}
} // namespace {{namespace}}
{%- endfor %}
} // namespace mojolpm
{%- endmacro %}
#ifndef {{header_guard}}
#define {{header_guard}}
#include "mojo/public/cpp/bindings/associated_receiver.h"
#include "mojo/public/cpp/bindings/associated_remote.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "mojo/public/tools/fuzzers/mojolpm.h"
{% for extra_public_header in extra_public_headers %}
#include "{{extra_public_header}}"
{%- endfor %}
{% for import in imports %}
#include "{{import.path}}-mojolpm.h"
#include "{{import.path}}.h"
{%- endfor %}
#include "{{module.path}}.mojolpm.pb.h"
#include "{{module.path}}.h"
{%- import "mojolpm_macros.tmpl" as util %}
{%- import "mojolpm_from_proto_macros.tmpl" as from_proto %}
{%- import "mojolpm_to_proto_macros.tmpl" as to_proto %}
namespace mojolpm {
{%- for enum in all_enums %}
{%- set mojom_type = enum|cpp_wrapper_type(add_same_module_namespaces=true) %}
{%- set proto_type = "::mojolpm" ~ (enum|get_qualified_name_for_kind(flatten_nested_kind=True)) %}
// enum {{enum.name}}
bool FromProto(
const {{proto_type}}& input,
{{mojom_type}}& output);
bool ToProto(
const {{mojom_type}}& input,
{{proto_type}}& output);
{% endfor %}
{%- for struct in structs %}
{%- set mojom_in_type = struct|cpp_wrapper_param_type(add_same_module_namespaces=true) %}
{%- set mojom_out_type = struct|cpp_wrapper_call_type(add_same_module_namespaces=true) %}
{%- set maybe_const = "const " if not struct|contains_handles_or_interfaces else "" %}
{%- set proto_type = "::mojolpm" ~ (struct|get_qualified_name_for_kind(flatten_nested_kind=True)) %}
{%- set struct_type = proto_type ~ "_ProtoStruct" %}
// struct {{struct.name}}
bool FromProto(
const {{proto_type}}& input,
{{mojom_out_type}}& output);
bool ToProto(
{{mojom_in_type}} input,
{{proto_type}}& output);{{"\n"-}}
{%- for field in struct.fields %}
{%- set name = field.name %}
{%- set kind = field.kind %}
{%- if kind|is_array_kind or kind|is_map_kind %}
{{- from_proto.declare(struct_type, kind, name) }}
{{- to_proto.declare(struct_type, kind, name) }}
{%- endif %}
{%- endfor %}
{%- endfor %}
{%- for union in unions %}
{%- set mojom_in_type = union|cpp_wrapper_param_type(add_same_module_namespaces=true) %}
{%- set mojom_out_type = union|cpp_wrapper_call_type(add_same_module_namespaces=true) %}
{%- set maybe_const = "const " if not union|contains_handles_or_interfaces else "" %}
{%- set proto_type = "::mojolpm" ~ (union|get_qualified_name_for_kind(flatten_nested_kind=True)) %}
{%- set union_type = proto_type ~ "_ProtoUnion" %}
{%- if union|is_native_only_kind %}
#error "Mojo native-only union {{union.name}} - don't think this is possible"
{%- else %}
// union {{union.name}}
bool FromProto(
const {{proto_type}}& input,
{{mojom_out_type}}& output);
bool ToProto(
{{mojom_in_type}} input,
{{proto_type}}& output);{{"\n"-}}
{%- endif %}
{%- for field in union.fields %}
{%- set name = field.name %}
{%- set kind = field.kind %}
{%- if kind|is_array_kind or kind|is_map_kind %}
{{- from_proto.declare(union_type, kind, name) }}
{{- to_proto.declare(union_type, kind, name) }}
{%- endif %}
{%- endfor %}
{%- endfor %}
{%- for interface in interfaces %}
{%- set mojom_type = interface|get_qualified_name_for_kind(flatten_nested_kind=True) %}
{%- set proto_type = "::mojolpm" ~ (interface|get_qualified_name_for_kind(flatten_nested_kind=True)) %}
// interface {{interface.name}}
bool FromProto(
const {{proto_type}}::Ptr& input,
{{mojom_type}}PtrInfo& output);
bool ToProto(
{{mojom_type}}Ptr&& input,
{{proto_type}}::Ptr& output);
bool ToProto(
{{mojom_type}}PtrInfo&& input,
{{proto_type}}::Ptr& output);
bool FromProto(
const {{proto_type}}::AssociatedPtr& input,
{{mojom_type}}AssociatedPtrInfo& output);
bool ToProto(
{{mojom_type}}AssociatedPtrInfo&& input,
{{proto_type}}::AssociatedPtr& output);
bool FromProto(
const {{proto_type}}::Request& input,
{{mojom_type}}Request& output);
bool ToProto(
{{mojom_type}}Request&& input,
{{proto_type}}::Request& output);
bool FromProto(
const {{proto_type}}::AssociatedRequest& input,
{{mojom_type}}AssociatedRequest& output);
bool ToProto(
{{mojom_type}}AssociatedRequest&& input,
{{proto_type}}::AssociatedRequest& output);
bool FromProto(
const {{proto_type}}::PendingRemote& input,
::mojo::PendingRemote<{{mojom_type}}>& output);
bool ToProto(
::mojo::PendingRemote<{{mojom_type}}>&& input,
{{proto_type}}::PendingRemote& output);
bool FromProto(
const {{proto_type}}::PendingReceiver& input,
::mojo::PendingReceiver<{{mojom_type}}>& output);
bool ToProto(
::mojo::PendingReceiver<{{mojom_type}}>&& input,
{{proto_type}}::PendingReceiver& output);
bool FromProto(
const {{proto_type}}::PendingAssociatedRemote& input,
::mojo::PendingAssociatedRemote<{{mojom_type}}>& output);
bool ToProto(
::mojo::PendingAssociatedRemote<{{mojom_type}}>&& input,
{{proto_type}}::PendingAssociatedRemote& output);
bool FromProto(
const {{proto_type}}::PendingAssociatedReceiver& input,
::mojo::PendingAssociatedReceiver<{{mojom_type}}>& output);
bool ToProto(
::mojo::PendingAssociatedReceiver<{{mojom_type}}>&& input,
{{proto_type}}::PendingAssociatedReceiver& output);{{"\n"-}}
{%- for method in interface.methods %}
{%- set method_type = proto_type ~ "::" ~ interface.name ~ "_" ~ method.name %}
{%- for param in method.parameters %}
{%- set name = param.name %}
{%- set kind = param.kind %}
{%- if kind|is_array_kind or kind|is_map_kind -%}
{{- from_proto.declare(method_type, kind, name)}}
{{- to_proto.declare(method_type, kind, name)}}
{%- endif %}
{%- endfor %}
{%- endfor %}
{%- endfor %}
{%- for interface in interfaces %}
{%- set mojom_type = interface|get_qualified_name_for_kind(flatten_nested_kind=True) %}
{%- set proto_type = "::mojolpm" ~ (interface|get_qualified_name_for_kind(flatten_nested_kind=True)) %}
{%- if interface.methods %}
bool HandleMethodCall(
const {{proto_type}}::MethodCall& input);
bool HandleMethodCallA(
const {{proto_type}}::MethodCallA& input);
bool HandleRemoteMethodCall(
const {{proto_type}}::RemoteMethodCall& input);
bool HandleAssociatedRemoteMethodCall(
const {{proto_type}}::AssociatedRemoteMethodCall& input);{{"\n"-}}
{%- for method in interface.methods %}
bool HandleMethodCall(
{{mojom_type}}Ptr& instance,
const {{proto_type}}::{{interface.name}}_{{method.name}}& input);
bool HandleMethodCallA(
{{mojom_type}}AssociatedPtr& instance,
const {{proto_type}}::{{interface.name}}_{{method.name}}& input);
bool HandleRemoteMethodCall(
::mojo::Remote<{{mojom_type}}>& instance,
const {{proto_type}}::{{interface.name}}_{{method.name}}& input);
bool HandleAssociatedRemoteMethodCall(
::mojo::AssociatedRemote<{{mojom_type}}>& instance,
const {{proto_type}}::{{interface.name}}_{{method.name}}& input);{{"\n"-}}
{%- endfor %}
{%- endif %}
{%- endfor -%}
} // namespace mojolpm
#endif // {{header_guard}}
{%- macro not_null(kind, name) %}
{%- if kind|is_typemapped_kind and kind|is_struct_kind and kind|nullable_is_same_kind %}
{%- set data_view = kind|get_qualified_name_for_kind ~ "DataView" %}
{%- set data_type = kind|cpp_wrapper_type(ignore_nullable=True) %}
{%- if data_type|truncate(16, true, '', 0) == '::scoped_refptr<' %}
{{name}}
{%- else %}
!::mojo::internal::CallIsNullIfExists<::mojo::StructTraits<{{data_view}}, {{data_type}}>>({{name}})
{%- endif %}
{%- else -%}{{name}}
{%- endif %}
{%- endmacro -%}
{%- macro value(kind, name) %}
{%- if kind|is_nullable_kind and (not kind|nullable_is_same_kind) -%}*{{name}}
{%- else -%}{{name}}
{%- endif %}
{%- endmacro -%}
{%- macro add_instance(kind, name, nested) %}
{%- if kind|is_array_kind %}
for (auto& {{name}}_iter : {{ value(kind, name) }}) {
{{ add_instance(kind.kind, name ~ '_iter', True)|indent(2, True) }}
}
{%- elif kind|is_map_kind %}
for (auto& {{name}}_iter : {{ value(kind, name) }}) {
auto& {{name}}_key = {{name}}_iter.first;
auto& {{name}}_value = {{name}}_iter.second;
{{ add_instance(kind.key_kind, name ~ "_key", True)|indent(2, True) }}
{{ add_instance(kind.value_kind, name ~ "_value", True)|indent(2, True) }}
}
{%- elif kind|is_interface_kind %}
{%- set mojom_type = kind|get_qualified_name_for_kind(flatten_nested_kind=True) %}
if ({{name}}) {
{{mojom_type}}Ptr tmp_{{name}}(std::move({{name}}));
mojolpm::GetContext()->AddInstance(std::move(tmp_{{name}}));
}
{%- elif kind|is_associated_interface_kind %}
{%- set mojom_type = kind.kind|get_qualified_name_for_kind(flatten_nested_kind=True) %}
if ({{name}}) {
{{mojom_type}}AssociatedPtr tmp_{{name}}(std::move({{name}}));
mojolpm::GetContext()->AddInstance(std::move(tmp_{{name}}));
}
{%- elif kind|is_pending_remote_kind %}
{%- set mojom_type = kind.kind|get_qualified_name_for_kind(flatten_nested_kind=True) %}
if ({{name}}) {
::mojo::Remote<{{mojom_type}}> tmp_{{name}}(std::move({{name}}));
mojolpm::GetContext()->AddInstance(std::move(tmp_{{name}}));
}
{%- elif kind|is_pending_associated_remote_kind %}
{%- set mojom_type = kind.kind|get_qualified_name_for_kind(flatten_nested_kind=True) %}
if ({{name}}) {
::mojo::AssociatedRemote<{{mojom_type}}> tmp_{{name}}(std::move({{name}}));
mojolpm::GetContext()->AddInstance(std::move(tmp_{{name}}));
}
{%- else %}
{%- if kind|is_nullable_kind %}
{%- set proto_type = kind|cpp_wrapper_proto_type(add_same_module_namespaces=true) %}
{{proto_type}} tmp_{{name}};
if ({{ not_null(kind, name) }}) {
{%- if kind|is_move_only_kind %}
if (ToProto(std::move({{ value(kind, name) }}), tmp_{{name}})) {
{%- else %}
if (ToProto({{ value(kind, name) }}, tmp_{{name}})) {
{%- endif %}
mojolpm::GetContext()->AddInstance(tmp_{{name}});
}
}
{%- else %}
{%- set proto_type = kind|cpp_wrapper_proto_type(add_same_module_namespaces=true) %}
{{proto_type}} tmp_{{name}};
{%- if kind|is_move_only_kind %}
if (ToProto(std::move({{name}}), tmp_{{name}})) {
{%- else %}
if (ToProto({{name}}, tmp_{{name}})) {
{%- endif %}
mojolpm::GetContext()->AddInstance(tmp_{{name}});
}
{%- endif %}
{%- endif %}
{%- endmacro %}
\ No newline at end of file
{% import "mojolpm_macros.tmpl" as util %}
{%- macro define_struct(struct) %}
{%- set mojom_type = struct|cpp_wrapper_type(add_same_module_namespaces=true) %}
{%- set proto_type = "::mojolpm" ~ (struct|get_qualified_name_for_kind(flatten_nested_kind=True)) %}
{%- set struct_type = proto_type ~ "_ProtoStruct" %}
{%- set dataview_type = (struct|get_qualified_name_for_kind(flatten_nested_kind=True)) ~ "DataView" %}
template <>
struct StructTraits<{{dataview_type}}, {{struct_type}}> {
{%- for field in struct.fields %}
{%- set name = field.name|camel_to_under %}
{%- set kind = field.kind %}
{%- if field.kind|is_nullable_kind and not field.kind|nullable_is_same_kind %}
{%- set field_mojom_type = kind|cpp_wrapper_type(add_same_module_namespaces=true) %}
{%- set field_maybe_mojom_type = kind|cpp_wrapper_type(add_same_module_namespaces=true, ignore_nullable=true) %}
static {{field_mojom_type}} {{field.name}}(
const {{struct_type}}& input) {
{{field_mojom_type}} maybe_local_{{name}};
{{field_maybe_mojom_type}} local_{{name}};
if (mojolpm::FromProto(
input.m_{{name}}(),
local_{{name}})) {
maybe_local_{{name}} = std::move(local_{{name}});
}
return maybe_local_{{name}};
}{{ "\n" }}
{%- else %}
{%- set field_mojom_type = kind|cpp_wrapper_type(add_same_module_namespaces=true) %}
static {{field_mojom_type}} {{field.name}}(
const {{struct_type}}& input) {
{{field_mojom_type}} local_{{name}};
(void) mojolpm::FromProto(
input.m_{{name}}(),
local_{{name}});
return local_{{name}};
}{{ "\n" }}
{%- endif %}
{%- endfor -%}
};
{% endmacro -%}
{%- macro define_union(union) -%}
{%- set mojom_type = union|cpp_wrapper_type(add_same_module_namespaces=true) %}
{%- set proto_type = "::mojolpm" ~ (union|get_qualified_name_for_kind(flatten_nested_kind=True)) %}
{%- set union_type = proto_type ~ "_ProtoUnion" %}
{%- if union|is_typemapped_kind %}
{%- set dataview_type = (union|get_qualified_name_for_kind(flatten_nested_kind=True)) ~ "DataView" %}
template<>
struct UnionTraits<{{dataview_type}}, {{union_type}}> {
static {{dataview_type}}::Tag GetTag(
const {{union_type}}& input) {
switch (input.union_member_case()) {
{%- for field in union.fields %}
{%- set name = field.name|camel_to_under %}
{%- set kind = field.kind %}
{%- set field_mojom_type = kind|cpp_wrapper_type(add_same_module_namespaces=true) %}
case {{union_type}}::k{{("m_" ~ name)|under_to_camel}}:
return {{dataview_type}}::Tag::{{name|upper}};
{%- endfor %}
default:
NOTREACHED();
return static_cast<{{dataview_type}}::Tag>(0);
}
}{{"\n"}}
{%- for field in union.fields %}
{%- set name = field.name|camel_to_under %}
{%- set kind = field.kind %}
{%- if field.kind|is_nullable_kind and not field.kind|nullable_is_same_kind %}
{%- set field_mojom_type = kind|cpp_wrapper_type(add_same_module_namespaces=true) %}
{%- set field_maybe_mojom_type = kind|cpp_wrapper_type(add_same_module_namespaces=true, ignore_nullable=true) %}
static {{field_mojom_type}} {{field.name}}(
const {{union_type}}& input) {
{{field_mojom_type}} maybe_local_{{name}};
{{field_maybe_mojom_type}} local_{{name}};
if (mojolpm::FromProto(
input.m_{{name}}(),
local_{{name}})) {
maybe_local_{{name}} = std::move(local_{{name}});
}
return maybe_local_{{name}};
}{{ "\n" }}
{%- else %}
{%- set field_mojom_type = kind|cpp_wrapper_type(add_same_module_namespaces=true) %}
static {{field_mojom_type}} {{field.name}}(
const {{union_type}}& input) {
{{field_mojom_type}} local_{{name}};
(void) mojolpm::FromProto(
input.m_{{name}}(),
local_{{name}});
return local_{{name}};
}{{ "\n" }}
{%- endif %}
{%- endfor -%}
};
{% endif %}
{% endmacro -%}
\ No newline at end of file
...@@ -111,8 +111,7 @@ def CamelCase(name): ...@@ -111,8 +111,7 @@ def CamelCase(name):
return uccc[0].lower() + uccc[1:] return uccc[0].lower() + uccc[1:]
def ConstantStyle(name): def ConstantStyle(name):
return generator.ToUpperSnakeCase(name) return generator.ToConstantCase(name)
def GetNameForElement(element): def GetNameForElement(element):
if (mojom.IsEnumKind(element) or mojom.IsInterfaceKind(element) or if (mojom.IsEnumKind(element) or mojom.IsInterfaceKind(element) or
...@@ -149,29 +148,29 @@ def GetJavaTrueFalse(value): ...@@ -149,29 +148,29 @@ def GetJavaTrueFalse(value):
return 'true' if value else 'false' return 'true' if value else 'false'
def GetArrayNullabilityFlags(kind): def GetArrayNullabilityFlags(kind):
"""Returns nullability flags for an array type, see Decoder.java. """Returns nullability flags for an array type, see Decoder.java.
As we have dedicated decoding functions for arrays, we have to pass As we have dedicated decoding functions for arrays, we have to pass
nullability information about both the array itself, as well as the array nullability information about both the array itself, as well as the array
element type there. element type there.
""" """
assert mojom.IsArrayKind(kind) assert mojom.IsArrayKind(kind)
ARRAY_NULLABLE = \ ARRAY_NULLABLE = \
'org.chromium.mojo.bindings.BindingsHelper.ARRAY_NULLABLE' 'org.chromium.mojo.bindings.BindingsHelper.ARRAY_NULLABLE'
ELEMENT_NULLABLE = \ ELEMENT_NULLABLE = \
'org.chromium.mojo.bindings.BindingsHelper.ELEMENT_NULLABLE' 'org.chromium.mojo.bindings.BindingsHelper.ELEMENT_NULLABLE'
NOTHING_NULLABLE = \ NOTHING_NULLABLE = \
'org.chromium.mojo.bindings.BindingsHelper.NOTHING_NULLABLE' 'org.chromium.mojo.bindings.BindingsHelper.NOTHING_NULLABLE'
flags_to_set = [] flags_to_set = []
if mojom.IsNullableKind(kind): if mojom.IsNullableKind(kind):
flags_to_set.append(ARRAY_NULLABLE) flags_to_set.append(ARRAY_NULLABLE)
if mojom.IsNullableKind(kind.kind): if mojom.IsNullableKind(kind.kind):
flags_to_set.append(ELEMENT_NULLABLE) flags_to_set.append(ELEMENT_NULLABLE)
if not flags_to_set: if not flags_to_set:
flags_to_set = [NOTHING_NULLABLE] flags_to_set = [NOTHING_NULLABLE]
return ' | '.join(flags_to_set) return ' | '.join(flags_to_set)
def AppendEncodeDecodeParams(initial_params, context, kind, bit): def AppendEncodeDecodeParams(initial_params, context, kind, bit):
......
...@@ -236,7 +236,7 @@ def GetRelativeUrl(module, base_module): ...@@ -236,7 +236,7 @@ def GetRelativeUrl(module, base_module):
class JavaScriptStylizer(generator.Stylizer): class JavaScriptStylizer(generator.Stylizer):
def StylizeConstant(self, mojom_name): def StylizeConstant(self, mojom_name):
return generator.ToUpperSnakeCase(mojom_name) return generator.ToConstantCase(mojom_name)
def StylizeField(self, mojom_name): def StylizeField(self, mojom_name):
return generator.ToCamel(mojom_name, lower_initial=True) return generator.ToCamel(mojom_name, lower_initial=True)
...@@ -267,20 +267,20 @@ class JavaScriptStylizer(generator.Stylizer): ...@@ -267,20 +267,20 @@ class JavaScriptStylizer(generator.Stylizer):
class Generator(generator.Generator): class Generator(generator.Generator):
def _GetParameters(self, for_compile=False): def _GetParameters(self, for_compile=False):
return { return {
"enums": self.module.enums, "enums": self.module.enums,
"html_imports": self._GenerateHtmlImports(), "html_imports": self._GenerateHtmlImports(),
"imports": self.module.imports, "imports": self.module.imports,
"interfaces": self.module.interfaces, "interfaces": self.module.interfaces,
"kinds": self.module.kinds, "kinds": self.module.kinds,
"module": self.module, "module": self.module,
"mojom_filename": os.path.basename(self.module.path), "mojom_filename": os.path.basename(self.module.path),
"mojom_namespace": self.module.mojom_namespace, "mojom_namespace": self.module.mojom_namespace,
"structs": self.module.structs + self._GetStructsFromMethods(), "structs": self.module.structs + self._GetStructsFromMethods(),
"unions": self.module.unions, "unions": self.module.unions,
"generate_fuzzing": self.generate_fuzzing, "generate_fuzzing": self.generate_fuzzing,
"generate_closure_exports": for_compile, "generate_closure_exports": for_compile,
"generate_struct_deserializers": self.js_generate_struct_deserializers, "generate_struct_deserializers": self.js_generate_struct_deserializers,
} }
@staticmethod @staticmethod
def GetTemplatePrefix(): def GetTemplatePrefix():
......
...@@ -40,16 +40,15 @@ class TypescriptStylizer(generator.Stylizer): ...@@ -40,16 +40,15 @@ class TypescriptStylizer(generator.Stylizer):
for word in mojom_namespace.split('.')) for word in mojom_namespace.split('.'))
def StylizeConstant(self, mojom_name): def StylizeConstant(self, mojom_name):
return generator.ToUpperSnakeCase(mojom_name) return generator.ToConstantCase(mojom_name)
class Generator(generator.Generator): class Generator(generator.Generator):
def _GetParameters(self, use_es_modules=False): def _GetParameters(self, use_es_modules=False):
return { return {
"module": self.module, "module": self.module,
"use_es_modules": use_es_modules, "use_es_modules": use_es_modules,
"enums": self.module.enums, "enums": self.module.enums,
} }
@staticmethod @staticmethod
def GetTemplatePrefix(): def GetTemplatePrefix():
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
import("//build/config/jumbo.gni") import("//build/config/jumbo.gni")
import("//third_party/closure_compiler/closure_args.gni") import("//third_party/closure_compiler/closure_args.gni")
import("//third_party/closure_compiler/compile_js.gni") import("//third_party/closure_compiler/compile_js.gni")
import("//third_party/protobuf/proto_library.gni")
import("//ui/webui/webui_features.gni") import("//ui/webui/webui_features.gni")
# TODO(rockot): Maybe we can factor these dependencies out of //mojo. They're # TODO(rockot): Maybe we can factor these dependencies out of //mojo. They're
...@@ -597,9 +596,9 @@ template("mojom") { ...@@ -597,9 +596,9 @@ template("mojom") {
write_file("$target_gen_dir/$target_name.deps_sources_list", deps_sources) write_file("$target_gen_dir/$target_name.deps_sources_list", deps_sources)
generate_fuzzing = generate_fuzzing = enable_ipc_fuzzer && (!defined(invoker.enable_fuzzing) ||
(!defined(invoker.enable_fuzzing) || invoker.enable_fuzzing) && invoker.enable_fuzzing) &&
enable_ipc_fuzzer && (!defined(invoker.testonly) || !invoker.testonly) (!defined(invoker.testonly) || !invoker.testonly)
if (sources_list != []) { if (sources_list != []) {
parser_target_name = "${target_name}__parser" parser_target_name = "${target_name}__parser"
...@@ -935,127 +934,6 @@ template("mojom") { ...@@ -935,127 +934,6 @@ template("mojom") {
} }
} }
if (generate_fuzzing) {
generator_mojolpm_proto_target_name =
"${target_name}_mojolpm_proto_generator"
action(generator_mojolpm_proto_target_name) {
#visibility = [ ":*" ]
script = mojom_generator_script
inputs = mojom_generator_sources + jinja2_sources
sources = invoker.sources
deps = [
":$parsed_target_name",
"//mojo/public/tools/bindings:precompile_templates",
] + verify_deps_target_names
outputs = []
args = common_generator_args
filelist = []
foreach(source, invoker.sources) {
filelist += [ rebase_path("$source", root_build_dir) ]
outputs += [ "$target_gen_dir/$source.mojolpm.proto" ]
}
response_file_contents = filelist
args += [
"--filelist={{response_file_name}}",
"--generate_non_variant_code",
"-g",
"mojolpm",
]
}
mojolpm_proto_target_name = "${target_name}_mojolpm_proto"
if (defined(invoker.sources)) {
proto_library(mojolpm_proto_target_name) {
testonly = true
generate_python = false
sources = process_file_template(
invoker.sources,
[ "{{source_gen_dir}}/{{source_file_part}}.mojolpm.proto" ])
import_dirs = [ "${root_gen_dir}" ]
proto_in_dir = "${root_gen_dir}"
proto_out_dir = "."
proto_deps = [ "//mojo/public/tools/fuzzers:mojolpm_proto_copy" ]
proto_deps += [ ":$generator_mojolpm_proto_target_name" ]
link_deps = [ "//mojo/public/tools/fuzzers:mojolpm_proto" ]
foreach(d, all_deps) {
# Resolve the name, so that a target //mojo/something becomes
# //mojo/something:something and we can append mojoller_proto_suffix
# to get the proto dependency name.
full_name = get_label_info("$d", "label_no_toolchain")
proto_deps += [ "${full_name}_mojolpm_proto" ]
link_deps += [ "${full_name}_mojolpm_proto" ]
}
}
mojolpm_target_name = "${target_name}_mojolpm"
mojolpm_generator_target_name = "${target_name}__generator"
static_library(mojolpm_target_name) {
testonly = true
if (defined(invoker.sources)) {
sources = process_file_template(
invoker.sources,
[
"{{source_gen_dir}}/{{source_file_part}}-mojolpm.cc",
"{{source_gen_dir}}/{{source_file_part}}-mojolpm.h",
])
} else {
sources = []
deps = []
}
public_deps = [
":$generator_shared_target_name",
# NB: hardcoded dependency on the no-variant variant generator, since
# mojolpm only uses the no-variant type.
":$mojolpm_generator_target_name",
":$mojolpm_proto_target_name",
"//mojo/public/tools/fuzzers:mojolpm",
]
deps = [
# TODO(markbrand): figure out how to add these dependencies only where
# they are needed instead.
"//device/vr/buildflags:buildflags",
"//media:media_buildflags",
"//net:buildflags",
"//skia",
"//third_party/boringssl",
"//third_party/icu:icuuc",
"//third_party/perfetto:libperfetto",
"//third_party/webrtc_overrides:webrtc_component",
]
foreach(d, all_deps) {
# Resolve the name, so that a target //mojo/something becomes
# //mojo/something:something and we can append variant_suffix to
# get the cpp dependency name.
full_name = get_label_info("$d", "label_no_toolchain")
public_deps += [ "${full_name}_mojolpm" ]
}
}
} else {
group(mojolpm_proto_target_name) {
testonly = true
public_deps = [ "//mojo/public/tools/fuzzers:mojolpm_proto" ]
if (defined(generator_shared_target_name)) {
public_deps += [ ":$generator_shared_target_name" ]
}
foreach(d, all_deps) {
# Resolve the name, so that a target //mojo/something becomes
# //mojo/something:something and we can append #mojoller_proto_suffix
# to get the proto dependency name.
full_name = get_label_info("$d", "label_no_toolchain")
public_deps += [ "${full_name}_mojolpm_proto" ]
}
}
}
}
# Generate code for variants. # Generate code for variants.
if (!defined(invoker.disable_variants) || !invoker.disable_variants) { if (!defined(invoker.disable_variants) || !invoker.disable_variants) {
enabled_configurations = _bindings_configurations enabled_configurations = _bindings_configurations
...@@ -1233,12 +1111,6 @@ template("mojom") { ...@@ -1233,12 +1111,6 @@ template("mojom") {
"$root_gen_dir/${base_path}${variant_dash_suffix}.cc", "$root_gen_dir/${base_path}${variant_dash_suffix}.cc",
"$root_gen_dir/${base_path}${variant_dash_suffix}.h", "$root_gen_dir/${base_path}${variant_dash_suffix}.h",
] ]
if (generate_fuzzing && !defined(bindings_configuration.variant)) {
outputs += [
"$root_gen_dir/${base_path}${variant_dash_suffix}-mojolpm.cc",
"$root_gen_dir/${base_path}${variant_dash_suffix}-mojolpm.h",
]
}
} }
response_file_contents = filelist response_file_contents = filelist
...@@ -1246,14 +1118,9 @@ template("mojom") { ...@@ -1246,14 +1118,9 @@ template("mojom") {
args += [ args += [
"--filelist={{response_file_name}}", "--filelist={{response_file_name}}",
"-g", "-g",
"c++",
] ]
if (generate_fuzzing && !defined(bindings_configuration.variant)) {
args += [ "c++,mojolpm" ]
} else {
args += [ "c++" ]
}
if (defined(bindings_configuration.variant)) { if (defined(bindings_configuration.variant)) {
args += [ args += [
"--variant", "--variant",
......
...@@ -56,11 +56,10 @@ import crbug_1001171 ...@@ -56,11 +56,10 @@ import crbug_1001171
_BUILTIN_GENERATORS = { _BUILTIN_GENERATORS = {
"c++": "mojom_cpp_generator", "c++": "mojom_cpp_generator",
"javascript": "mojom_js_generator", "javascript": "mojom_js_generator",
"java": "mojom_java_generator", "java": "mojom_java_generator",
"mojolpm": "mojom_mojolpm_generator", "typescript": "mojom_ts_generator",
"typescript": "mojom_ts_generator",
} }
...@@ -178,8 +177,6 @@ class MojomProcessor(object): ...@@ -178,8 +177,6 @@ class MojomProcessor(object):
language_map = self._typemap.get(language, {}) language_map = self._typemap.get(language, {})
language_map.update(typemap) language_map.update(typemap)
self._typemap[language] = language_map self._typemap[language] = language_map
if 'c++' in self._typemap:
self._typemap['mojolpm'] = self._typemap['c++']
def _GenerateModule(self, args, remaining_args, generator_modules, def _GenerateModule(self, args, remaining_args, generator_modules,
rel_filename, imported_filename_stack): rel_filename, imported_filename_stack):
...@@ -448,13 +445,11 @@ def main(): ...@@ -448,13 +445,11 @@ def main():
generate_parser.add_argument("--filelist", help="mojom input file list") generate_parser.add_argument("--filelist", help="mojom input file list")
generate_parser.add_argument("-d", "--depth", dest="depth", default=".", generate_parser.add_argument("-d", "--depth", dest="depth", default=".",
help="depth from source root") help="depth from source root")
generate_parser.add_argument( generate_parser.add_argument("-g", "--generators",
"-g", dest="generators_string",
"--generators", metavar="GENERATORS",
dest="generators_string", default="c++,javascript,java",
metavar="GENERATORS", help="comma-separated list of generators")
default="c++,javascript,java,mojolpm",
help="comma-separated list of generators")
generate_parser.add_argument( generate_parser.add_argument(
"--gen_dir", dest="gen_directories", action="append", metavar="directory", "--gen_dir", dest="gen_directories", action="append", metavar="directory",
default=[], help="add a directory to be searched for the syntax trees.") default=[], help="add a directory to be searched for the syntax trees.")
......
...@@ -8,7 +8,6 @@ import("//build/config/features.gni") ...@@ -8,7 +8,6 @@ import("//build/config/features.gni")
import("//mojo/public/tools/bindings/mojom.gni") import("//mojo/public/tools/bindings/mojom.gni")
import("//testing/libfuzzer/fuzzer_test.gni") import("//testing/libfuzzer/fuzzer_test.gni")
import("//third_party/protobuf/proto_library.gni") import("//third_party/protobuf/proto_library.gni")
import("//tools/ipc_fuzzer/ipc_fuzzer.gni")
# mojo/public BUILD depends on this target. Needed for package discovery # mojo/public BUILD depends on this target. Needed for package discovery
group("fuzzers") { group("fuzzers") {
...@@ -62,30 +61,3 @@ fuzzer_test("mojo_parse_message_proto_fuzzer") { ...@@ -62,30 +61,3 @@ fuzzer_test("mojo_parse_message_proto_fuzzer") {
proto_library("mojo_fuzzer_proto") { proto_library("mojo_fuzzer_proto") {
sources = [ "mojo_fuzzer.proto" ] sources = [ "mojo_fuzzer.proto" ]
} }
copy("mojolpm_proto_copy") {
sources = [ "mojolpm.proto" ]
outputs = [ "$root_gen_dir/mojolpm.proto" ]
testonly = true
}
proto_library("mojolpm_proto") {
sources = [ "mojolpm.proto" ]
generate_python = false
# TODO(markbrand): this is kind of a hack, but it works. not sure if it's
# the best way to get this generated in the right place though.
proto_out_dir = "mojo/public/tools/fuzzers/../../../../"
proto_deps = [ ":mojolpm_proto_copy" ]
testonly = true
}
static_library("mojolpm") {
sources = [ "mojolpm.cc" ]
deps = [
":mojolpm_proto",
"//base",
"//mojo/public/cpp/bindings",
]
testonly = true
}
This diff is collapsed.
This diff is collapsed.
// Copyright 2019 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.
syntax = "proto2";
package mojolpm;
// TODO(markbrand): Is there anything sensible to do to fuzz interfaces that
// use or expect a generic mojo handle?
message Handle {}
message CreateDataPipeOptions {
required uint32 flags = 2;
required uint32 element_num_bytes = 3;
required uint32 capacity_num_bytes = 4;
}
message DataPipeConsumerHandle {
oneof instance {
uint32 old = 1;
CreateDataPipeOptions new = 2;
}
}
message DataPipeProducerHandle {
oneof instance {
uint32 old = 1;
CreateDataPipeOptions new = 2;
}
}
message DataPipeRead {
required DataPipeConsumerHandle handle = 1;
required uint32 size = 2;
}
message DataPipeWrite {
required DataPipeProducerHandle handle = 1;
required bytes data = 2;
}
message DataPipeConsumerClose {
required uint32 id = 1;
}
message DataPipeProducerClose {
required uint32 id = 1;
}
// TODO(markbrand): Implement these last two.
message MessagePipeHandle {}
message SharedBufferHandle {}
message PlatformHandle {}
\ No newline at end of file
...@@ -9,4 +9,6 @@ traits_headers = [ ...@@ -9,4 +9,6 @@ traits_headers = [
"//services/network/public/cpp/cross_origin_embedder_policy_mojom_traits.h", "//services/network/public/cpp/cross_origin_embedder_policy_mojom_traits.h",
] ]
sources = [] sources = []
type_mappings = [ "network.mojom.CrossOriginEmbedderPolicy=::network::CrossOriginEmbedderPolicy" ] type_mappings = [
"network.mojom.CrossOriginEmbedderPolicy=network::CrossOriginEmbedderPolicy",
]
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
#include "mojo/public/cpp/bindings/pending_remote.h" #include "mojo/public/cpp/bindings/pending_remote.h"
#include "services/network/public/cpp/resource_request_body.h" #include "services/network/public/cpp/resource_request_body.h"
#include "services/network/public/mojom/url_loader.mojom-forward.h" #include "services/network/public/mojom/url_loader.mojom-forward.h"
#include "third_party/blink/public/mojom/fetch/fetch_api_request.mojom-shared.h" #include "third_party/blink/public/mojom/fetch/fetch_api_request.mojom-forward.h"
namespace mojo { namespace mojo {
......
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment