Commit 7323c987 authored by anthonyvd's avatar anthonyvd Committed by Commit Bot

Revert "bind-gen: Implement the first step of the new bindings generator"

This reverts commit 3cb21f50.

Reason for revert: This change appears to be causing failures on some bots (see https://logs.chromium.org/logs/chromium/buildbucket/cr-buildbucket.appspot.com/8902604840241120592/+/steps/compile/0/stdout)

Original change's description:
> bind-gen: Implement the first step of the new bindings generator
> 
> Implement a "do almost nothing" bindings generator.
> bindings/core/v8/v8_example.cc is generated
> purposelessly.
> 
> Bug: 839389
> Change-Id: I39445cd361677d5a78d96a2d45589c571802b63c
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1782212
> Reviewed-by: Hitoshi Yoshida <peria@chromium.org>
> Reviewed-by: Andrew Grieve <agrieve@chromium.org>
> Commit-Queue: Yuki Shiino <yukishiino@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#695608}

TBR=peria@chromium.org,yukishiino@chromium.org,agrieve@chromium.org

Change-Id: If3dd4dec18b3347f204ffec4da1fb7f2b93b446e
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 839389
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1798525Reviewed-by: default avataranthonyvd <anthonyvd@chromium.org>
Commit-Queue: anthonyvd <anthonyvd@chromium.org>
Cr-Commit-Position: refs/heads/master@{#695617}
parent db47b3e7
......@@ -1237,11 +1237,10 @@ _ANDROID_SPECIFIC_PYDEPS_FILES = [
_GENERIC_PYDEPS_FILES = [
'chrome/test/chromedriver/log_replay/client_replay_unittest.pydeps',
'chrome/test/chromedriver/test/run_py_tests.pydeps',
'chrome/test/chromedriver/log_replay/client_replay_unittest.pydeps',
'third_party/blink/renderer/bindings/scripts/build_web_idl_database.pydeps',
'third_party/blink/renderer/bindings/scripts/collect_idl_files.pydeps',
'third_party/blink/renderer/bindings/scripts/generate_bindings.pydeps',
'tools/binary_size/sizes.pydeps',
'tools/binary_size/supersize.pydeps',
]
......
......@@ -125,32 +125,3 @@ action_with_pydeps("web_idl_database") {
":web_idl_in_modules",
]
}
action_with_pydeps("generate_bindings_example") {
script = "${bindings_scripts_dir}/generate_bindings.py"
web_idl_database_outputs = get_target_outputs(":web_idl_database")
web_idl_database = web_idl_database_outputs[0]
inputs = [
web_idl_database,
"${bindings_scripts_dir}/bind_gen/example.cc.tmpl",
]
outputs = [
"${bindings_output_dir}/core/v8/v8_example.cc",
]
args = [
"example",
"--web_idl_database",
rebase_path(web_idl_database, root_build_dir),
"--output_dir_core",
rebase_path("${bindings_output_dir}/core/v8/", root_build_dir),
"--output_dir_modules",
rebase_path("${bindings_output_dir}/modules/v8/", root_build_dir),
]
deps = [
":web_idl_database",
]
}
[style]
# https://www.chromium.org/blink/coding-style
based_on_style = pep8
# 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.
import os.path
import sys
# Set up |sys.path| so that this module works without user-side setup of
# PYTHONPATH assuming Chromium's directory tree structure.
def _setup_sys_path():
expected_path = 'third_party/blink/renderer/bindings/scripts/bind_gen/'
this_dir = os.path.dirname(__file__)
root_dir = os.path.join(this_dir, *(['..'] * expected_path.count('/')))
sys.path = [
# //third_party/blink/renderer/build/scripts/blinkbuild
os.path.join(root_dir, 'third_party', 'blink', 'renderer', 'build',
'scripts'),
# //third_party/mako/mako
os.path.join(root_dir, 'third_party', 'mako'),
] + sys.path
_setup_sys_path()
from .clang_format import init_clang_format
def _setup_clang_format():
expected_path = 'third_party/blink/renderer/bindings/scripts/bind_gen/'
this_dir = os.path.dirname(__file__)
root_dir = os.path.join(this_dir, *(['..'] * expected_path.count('/')))
# //third_party/depot_tools/clang-format
command_path = os.path.abspath(
os.path.join(root_dir, 'third_party', 'depot_tools', 'clang-format'))
init_clang_format(command_path=command_path)
_setup_clang_format()
from .example import run_example
__all__ = [
"run_example",
]
# 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.
import os.path
import subprocess
_clang_format_command_path = None
def init_clang_format(command_path):
assert isinstance(command_path, str)
assert os.path.exists(command_path)
global _clang_format_command_path
assert _clang_format_command_path is None
_clang_format_command_path = command_path
def clang_format(contents, filename=None):
command_line = [_clang_format_command_path]
if filename is not None:
command_line.append('-assume-filename={}'.format(filename))
proc = subprocess.Popen(
command_line, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
stdout_output, stderr_output = proc.communicate(input=contents)
exit_code = proc.wait()
return ClangFormatResult(
stdout_output=stdout_output,
stderr_output=stderr_output,
exit_code=exit_code,
filename=filename)
class ClangFormatResult(object):
def __init__(self, stdout_output, stderr_output, exit_code, filename):
self._stdout_output = stdout_output
self._stderr_output = stderr_output
self._exit_code = exit_code
self._filename = filename
@property
def did_succeed(self):
return self._exit_code == 0
@property
def contents(self):
assert self.did_succeed
return self._stdout_output
@property
def error_message(self):
return self._stderr_output
@property
def filename(self):
return self._filename
// 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.
<%
interface = web_idl.find('HTMLElement')
%>
class ${interface.identifier} : public ${interface.inherited.identifier} {
// attributes
% for attribute in interface.attributes:
int ${attribute.identifier};
% endfor
};
# 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.
import os.path
from .mako_renderer import MakoRenderer
from .clang_format import clang_format
def run_example(web_idl_database, output_dirs):
mako = MakoRenderer()
mako_output = mako.render('example.cc.tmpl', web_idl=web_idl_database)
filename = 'v8_example.cc'
formatted_result = clang_format(mako_output, filename=filename)
with open(os.path.join(output_dirs['core'], filename), 'w') as output_file:
output_file.write(formatted_result.contents)
# 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.
import os.path
from mako.lookup import TemplateLookup
_TEMPLATES_DIR = os.path.dirname(__file__)
class MakoRenderer(object):
def __init__(self, template_dirs=None):
template_dirs = template_dirs or [_TEMPLATES_DIR]
self._template_lookup = TemplateLookup(directories=template_dirs)
def render(self, template_path, **variable_bindings):
template = self._template_lookup.get_template(template_path)
return template.render(**variable_bindings)
......@@ -18,14 +18,11 @@ import web_idl
def parse_options():
parser = optparse.OptionParser()
parser.add_option('--output', type='string',
help="filepath of the resulting database")
help='filepath of the resulting database')
options, args = parser.parse_args()
if options.output is None:
parser.error("Specify a filepath of the database with --output.")
if not args:
parser.error("No argument specified.")
parser.error('Specify a filepath of the database with --output.')
return options, args
......@@ -37,13 +34,13 @@ def main():
def report_error(message):
was_error_reported[0] = True
sys.stderr.writelines([message, "\n"])
sys.stderr.writelines([message, '\n'])
database = web_idl.build_database(filepaths=filepaths,
report_error=report_error)
if was_error_reported[0]:
sys.exit("Aborted due to error.")
sys.exit('Aborted due to error.')
database.write_to_file(options.output)
......
......@@ -17,34 +17,33 @@ import utilities
import web_idl
_VALID_COMPONENTS = ('core', 'modules')
_VALID_COMPONENTS = ("core", "modules")
def parse_options():
parser = optparse.OptionParser()
parser.add_option('--idl-list-file', type='string',
help="a file path which lists IDL file paths to process")
help='a file path which lists IDL file paths to process')
parser.add_option('--component', type='choice', choices=_VALID_COMPONENTS,
help="specify a component name")
help='specify a component name')
parser.add_option('--output', type='string',
help="the output file path")
help='the output file path')
options, args = parser.parse_args()
if options.idl_list_file is None:
parser.error("Specify a file listing IDL files with --idl-list-file.")
parser.error('Specify a file listing IDL files with --idl-list-file.')
if options.output is None:
parser.error("Specify the output file path with --output.")
parser.error('Specify the output file path with --output.')
if options.component is None:
parser.error("Specify a component with --component.")
if args:
parser.error("Unknown arguments {}".format(args))
parser.error('Specify a component with --component.')
return options, args
def main():
options, _ = parse_options()
options, args = parse_options()
if args:
raise RuntimeError('unknown arguments {}'.format(args))
filepaths = utilities.read_idl_files_list_from_file(options.idl_list_file)
parser = blink_idl_parser.BlinkIDLParser()
......
# 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.
"""
Runs the bindings code generator for the given tasks.
"""
import optparse
import sys
import bind_gen
import web_idl
def parse_options():
parser = optparse.OptionParser(usage="%prog [options] TASK...")
parser.add_option('--web_idl_database', type='string',
help="filepath of the input database")
parser.add_option('--output_dir_core', type='string',
help="outout directory for 'core' component")
parser.add_option('--output_dir_modules', type='string',
help="outout directory for 'modules' component")
options, args = parser.parse_args()
required_option_names = (
'web_idl_database', 'output_dir_core', 'output_dir_modules')
for opt_name in required_option_names:
if getattr(options, opt_name) is None:
parser.error("--{} is a required option.".format(opt_name))
if not args:
parser.error("No argument specified.")
return options, args
def main():
options, tasks = parse_options()
dispatch_table = {
'example': bind_gen.run_example,
}
for task in tasks:
if task not in dispatch_table:
sys.exit("Unknown task: {}".format(task))
web_idl_database = web_idl.Database.read_from_file(options.web_idl_database)
output_dirs = {
web_idl.Component('core'): options.output_dir_core,
web_idl.Component('modules'): options.output_dir_modules,
}
for task in tasks:
dispatch_table[task](web_idl_database=web_idl_database,
output_dirs=output_dirs)
if __name__ == '__main__':
main()
# Generated by running:
# build/print_python_deps.py --root third_party/blink/renderer/bindings/scripts --output third_party/blink/renderer/bindings/scripts/generate_bindings.pydeps third_party/blink/renderer/bindings/scripts/generate_bindings.py
../../../../mako/mako/__init__.py
../../../../mako/mako/_ast_util.py
../../../../mako/mako/ast.py
../../../../mako/mako/cache.py
../../../../mako/mako/codegen.py
../../../../mako/mako/compat.py
../../../../mako/mako/exceptions.py
../../../../mako/mako/ext/__init__.py
../../../../mako/mako/filters.py
../../../../mako/mako/lexer.py
../../../../mako/mako/lookup.py
../../../../mako/mako/parsetree.py
../../../../mako/mako/pygen.py
../../../../mako/mako/pyparser.py
../../../../mako/mako/runtime.py
../../../../mako/mako/template.py
../../../../mako/mako/util.py
../../build/scripts/blinkbuild/__init__.py
../../build/scripts/blinkbuild/name_style_converter.py
bind_gen/__init__.py
bind_gen/clang_format.py
bind_gen/example.py
bind_gen/mako_renderer.py
generate_bindings.py
web_idl/__init__.py
web_idl/argument.py
web_idl/ast_group.py
web_idl/attribute.py
web_idl/callback_function.py
web_idl/callback_interface.py
web_idl/code_generator_info.py
web_idl/composition_parts.py
web_idl/constant.py
web_idl/database.py
web_idl/database_builder.py
web_idl/dictionary.py
web_idl/enumeration.py
web_idl/exposure.py
web_idl/extended_attribute.py
web_idl/file_io.py
web_idl/function_like.py
web_idl/idl_compiler.py
web_idl/idl_type.py
web_idl/includes.py
web_idl/interface.py
web_idl/ir_builder.py
web_idl/ir_map.py
web_idl/literal_constant.py
web_idl/make_copy.py
web_idl/namespace.py
web_idl/operation.py
web_idl/overload_group.py
web_idl/reference.py
web_idl/typedef.py
web_idl/union.py
web_idl/user_defined_type.py
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