Commit 4c0410cb authored by Takuto Ikuta's avatar Takuto Ikuta Committed by Commit Bot

Extract param struct to separate header

This change extracts param data related struct only used in mojom cc files to another header file, params-data.h.
And only mojom cc files include params-data.h.
By extracting structs, this CL reduces total size of included files from compiles including mojom headers.

This CL reduces total size of generated header files when building chrome.
mojom-shared.h: 9576659 -> 6343886
mojom-shared-internal.h: 7552016 -> 3053172

And this helped to reduce compile time.
e.g. obj/content/browser/browser/navigation_url_loader_impl.o: 25.6s -> 22.7s in Z840 Linux

chrome build time on 24C/48T Z840 Linux reduced from 3478.5s to 3385.5s.

Bug: 922875
Change-Id: I0e233e6046f9b47d6386ea24ea911da638b6aa69
Reviewed-on: https://chromium-review.googlesource.com/c/1436286
Commit-Queue: Takuto Ikuta <tikuta@chromium.org>
Reviewed-by: default avatarKen Rockot <rockot@google.com>
Cr-Commit-Position: refs/heads/master@{#626302}
parent 0b65cb95
......@@ -17,6 +17,7 @@ action("precompile_templates") {
"$mojom_generator_root/generators/cpp_templates/interface_request_validator_declaration.tmpl",
"$mojom_generator_root/generators/cpp_templates/interface_response_validator_declaration.tmpl",
"$mojom_generator_root/generators/cpp_templates/interface_stub_declaration.tmpl",
"$mojom_generator_root/generators/cpp_templates/module-params-data.h.tmpl",
"$mojom_generator_root/generators/cpp_templates/module-shared-internal.h.tmpl",
"$mojom_generator_root/generators/cpp_templates/module-shared-message-ids.h.tmpl",
"$mojom_generator_root/generators/cpp_templates/module-shared.cc.tmpl",
......
// 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_PARAMS_DATA_H_"|format(
module.path|upper|replace("/","_")|replace(".","_")|
replace("-", "_")) %}
#ifndef {{header_guard}}
#define {{header_guard}}
#include "base/logging.h"
#include "base/macros.h"
#include "mojo/public/cpp/bindings/lib/bindings_internal.h"
#include "mojo/public/cpp/bindings/lib/buffer.h"
#include "mojo/public/cpp/bindings/lib/validation_context.h"
#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-private-field"
#elif defined(_MSC_VER)
#pragma warning(push)
#pragma warning(disable:4056)
#pragma warning(disable:4065)
#pragma warning(disable:4756)
#endif
{%- for namespace in namespaces_as_array %}
namespace {{namespace}} {
{%- endfor %}
namespace internal {
{#--- Interface parameter definitions #}
{%- for interface in interfaces %}
{%- for method in interface.methods %}
{%- set struct = method.param_struct %}
{% include "struct_declaration.tmpl" %}
{%- if method.response_parameters != None %}
{%- set struct = method.response_param_struct %}
{% include "struct_declaration.tmpl" %}
{%- endif %}
{%- endfor %}
{%- endfor %}
} // namespace internal
{#--- Interface parameter definitions #}
{%- for interface in interfaces %}
{%- for method in interface.methods %}
{%- set struct = method.param_struct %}
{% include "struct_data_view_declaration.tmpl" %}
{%- if method.response_parameters != None %}
{%- set struct = method.response_param_struct %}
{% include "struct_data_view_declaration.tmpl" %}
{%- endif %}
{%- endfor %}
{%- endfor %}
{%- for interface in interfaces %}
{%- for method in interface.methods %}
{%- set struct = method.param_struct %}
{% include "struct_data_view_definition.tmpl" %}
{%- if method.response_parameters != None %}
{%- set struct = method.response_param_struct %}
{% include "struct_data_view_definition.tmpl" %}
{%- endif %}
{%- endfor %}
{%- endfor %}
{%- for namespace in namespaces_as_array|reverse %}
} // namespace {{namespace}}
{%- endfor %}
#if defined(__clang__)
#pragma clang diagnostic pop
#elif defined(_MSC_VER)
#pragma warning(pop)
#endif
#endif // {{header_guard}}
......@@ -78,18 +78,6 @@ using {{enum|get_name_for_kind(flatten_nested_kind=True)}}_Data =
{%- endif %}
{%- endfor %}
{#--- Interface parameter definitions #}
{%- for interface in interfaces %}
{%- for method in interface.methods %}
{%- set struct = method.param_struct %}
{% include "struct_declaration.tmpl" %}
{%- if method.response_parameters != None %}
{%- set struct = method.response_param_struct %}
{% include "struct_declaration.tmpl" %}
{%- endif %}
{%- endfor %}
{%- endfor %}
#pragma pack(pop)
} // namespace internal
......
......@@ -18,6 +18,8 @@
#include "mojo/public/cpp/bindings/lib/validation_errors.h"
#include "mojo/public/cpp/bindings/lib/validation_util.h"
#include "{{module.path}}-params-data.h"
{%- for header in extra_traits_headers %}
#include "{{header}}"
{%- endfor %}
......
......@@ -140,18 +140,6 @@ using {{interface.name}}AssociatedRequestDataView =
{%- endif %}
{%- endfor %}
{#--- Interface parameter definitions #}
{%- for interface in interfaces %}
{%- for method in interface.methods %}
{%- set struct = method.param_struct %}
{% include "struct_data_view_declaration.tmpl" %}
{%- if method.response_parameters != None %}
{%- set struct = method.response_param_struct %}
{% include "struct_data_view_declaration.tmpl" %}
{%- endif %}
{%- endfor %}
{%- endfor %}
{#--- Unions #}
{%- for union in unions %}
{% include "union_data_view_declaration.tmpl" %}
......@@ -203,17 +191,6 @@ namespace mojo {
{%- endif %}
{%- endfor %}
{%- for interface in interfaces %}
{%- for method in interface.methods %}
{%- set struct = method.param_struct %}
{% include "struct_data_view_definition.tmpl" %}
{%- if method.response_parameters != None %}
{%- set struct = method.response_param_struct %}
{% include "struct_data_view_definition.tmpl" %}
{%- endif %}
{%- endfor %}
{%- endfor %}
{%- for union in unions %}
{% include "union_data_view_definition.tmpl" %}
{%- endfor %}
......
......@@ -38,6 +38,7 @@
#include "mojo/public/cpp/bindings/lib/validation_errors.h"
#include "mojo/public/interfaces/bindings/interface_control_messages.mojom.h"
#include "{{module.path}}-params-data.h"
#include "{{module.path}}-shared-message-ids.h"
{%- if for_blink %}
......
......@@ -404,6 +404,10 @@ class Generator(generator.Generator):
def _GenerateModuleTestUtilsSource(self):
return self._GetJinjaExports()
@UseJinja("module-params-data.h.tmpl")
def _GenerateModuleParamsDataHeader(self):
return self._GetJinjaExports()
def GenerateFiles(self, args):
self.module.Stylize(generator.Stylizer())
......@@ -418,6 +422,8 @@ class Generator(generator.Generator):
"%s-shared-internal.h" % self.module.path)
self.Write(self._GenerateModuleSharedSource(),
"%s-shared.cc" % self.module.path)
self.Write(self._GenerateModuleParamsDataHeader(),
"%s-params-data.h" % self.module.path)
else:
suffix = "-%s" % self.variant if self.variant else ""
self.Write(self._GenerateModuleHeader(),
......
......@@ -617,6 +617,7 @@ template("mojom") {
}
generator_shared_cpp_outputs = [
"{{source_gen_dir}}/{{source_file_part}}-params-data.h",
"{{source_gen_dir}}/{{source_file_part}}-shared-internal.h",
"{{source_gen_dir}}/{{source_file_part}}-shared.cc",
"{{source_gen_dir}}/{{source_file_part}}-shared.h",
......@@ -638,6 +639,7 @@ template("mojom") {
foreach(source, invoker.sources) {
filelist += [ rebase_path("$source", root_build_dir) ]
outputs += [
"$target_gen_dir/$source-params-data.h",
"$target_gen_dir/$source-shared-internal.h",
"$target_gen_dir/$source-shared.cc",
"$target_gen_dir/$source-shared.h",
......
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