Commit 551cdd50 authored by Amos Lim's avatar Amos Lim Committed by Commit Bot

probe: Let generated header files follow chromium style on header guards

Generated header files need to follow chromium style on header guards.
Follow up to crrev.com/c/1235356

Bug: 896720
Change-Id: I0b7e1f7a3e6ba2d743979808d2b6247b6a19e12c
Reviewed-on: https://chromium-review.googlesource.com/c/1291192Reviewed-by: default avatarKent Tamura <tkent@chromium.org>
Commit-Queue: Amos Lim <eui-sang.lim@samsung.com>
Cr-Commit-Position: refs/heads/master@{#601472}
parent afde4e72
...@@ -106,7 +106,7 @@ def load_model_from_idl(source): ...@@ -106,7 +106,7 @@ def load_model_from_idl(source):
class File(object): class File(object):
def __init__(self, name, source): def __init__(self, name, source):
self.name = NameStyleConverter(name).to_snake_case() self.name = NameStyleConverter(name).to_snake_case()
self.header_name = self.name + "_inl" self.header_name = self.name + "_inl.h"
self.forward_declarations = [] self.forward_declarations = []
self.declarations = [] self.declarations = []
for line in map(str.strip, source.split("\n")): for line in map(str.strip, source.split("\n")):
...@@ -263,15 +263,18 @@ def main(): ...@@ -263,15 +263,18 @@ def main():
template_context["template_file"] = "/probe_sink.h.tmpl" template_context["template_file"] = "/probe_sink.h.tmpl"
sink_h_template = jinja_env.get_template(template_context["template_file"]) sink_h_template = jinja_env.get_template(template_context["template_file"])
sink_h_file = open(output_dirpath + "/" + to_singular(base_name) + "_sink.h", "w") sink_h_file_name = to_singular(base_name) + "_sink.h"
sink_h_file = open(output_dirpath + "/" + sink_h_file_name, "w")
template_context["header_guard"] = NameStyleConverter(output_path_in_gen_dir + "/" + sink_h_file_name).to_header_guard()
sink_h_file.write(sink_h_template.render(template_context)) sink_h_file.write(sink_h_template.render(template_context))
sink_h_file.close() sink_h_file.close()
for f in files: for f in files:
template_context["file"] = f template_context["file"] = f
template_context["template_file"] = "/instrumenting_probes_inl.h.tmpl" template_context["template_file"] = "/instrumenting_probes_inl.h.tmpl"
template_context["header_guard"] = NameStyleConverter(output_path_in_gen_dir + "/" + f.header_name).to_header_guard()
h_template = jinja_env.get_template(template_context["template_file"]) h_template = jinja_env.get_template(template_context["template_file"])
h_file = open(output_dirpath + "/" + f.header_name + ".h", "w") h_file = open(output_dirpath + "/" + f.header_name, "w")
h_file.write(h_template.render(template_context)) h_file.write(h_template.render(template_context))
h_file.close() h_file.close()
......
...@@ -5,8 +5,8 @@ ...@@ -5,8 +5,8 @@
{% from 'macros.tmpl' import source_files_for_generated_file %} {% from 'macros.tmpl' import source_files_for_generated_file %}
{{source_files_for_generated_file(template_file, input_files)}} {{source_files_for_generated_file(template_file, input_files)}}
#ifndef {{file.header_name.upper()}}_H #ifndef {{header_guard}}
#define {{file.header_name.upper()}}_H #define {{header_guard}}
#include "third_party/blink/renderer/platform/heap/heap_allocator.h" #include "third_party/blink/renderer/platform/heap/heap_allocator.h"
#include "third_party/blink/renderer/bindings/core/v8/script_source_code.h" #include "third_party/blink/renderer/bindings/core/v8/script_source_code.h"
...@@ -80,4 +80,4 @@ inline void {{probe.name}}({{params_list(probe)}}) { ...@@ -80,4 +80,4 @@ inline void {{probe.name}}({{params_list(probe)}}) {
} // namespace probe } // namespace probe
} // namespace blink } // namespace blink
#endif // !defined({{file.header_name.upper()}}_H) #endif // {{header_guard}}
...@@ -6,12 +6,11 @@ ...@@ -6,12 +6,11 @@
{{source_files_for_generated_file(template_file, input_files)}} {{source_files_for_generated_file(template_file, input_files)}}
{% set sink_class = (name | to_singular) + "Sink" %} {% set sink_class = (name | to_singular) + "Sink" %}
{% set sink_class_header = (header | to_singular) + "_sink" %}
{% set export_header = config["settings"]["export_header"] %} {% set export_header = config["settings"]["export_header"] %}
{% set export_symbol = config["settings"]["export_symbol"] %} {% set export_symbol = config["settings"]["export_symbol"] %}
#ifndef {{sink_class_header.upper()}}_H #ifndef {{header_guard}}
#define {{sink_class_header.upper()}}_H #define {{header_guard}}
#include <atomic> #include <atomic>
...@@ -75,4 +74,4 @@ class {{export_symbol}} {{sink_class}} : public GarbageCollectedFinalized<{{sink ...@@ -75,4 +74,4 @@ class {{export_symbol}} {{sink_class}} : public GarbageCollectedFinalized<{{sink
} // namespace blink } // namespace blink
#endif // !defined({{sink_class_header.upper()}}_H) #endif // {{header_guard}}
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