Commit 873601c6 authored by Rouslan Solomakhin's avatar Rouslan Solomakhin Committed by Commit Bot

Revert "various small tweaks to blink's gperf use"

This reverts commit 2f79d543.

Reason for revert: Failed compile on https://ci.chromium.org/buildbot/chromium.win/WinMSVC64/1698

[74/5635] ACTION //third_party/WebKit/Source/platform:color_data(//build/toolchain/win:x64)
FAILED: gen/blink/platform/ColorData.cpp 
E:/b/depot_tools/win_tools-2_7_6_bin/python/bin/python.exe ../../third_party/WebKit/Source/build/scripts/gperf.py ../../third_party/gperf/bin/gperf.exe --key-positions=* -D -s 2 ../../third_party/WebKit/Source/platform/ColorData.gperf --output-file=gen/blink/platform/ColorData.cpp
Traceback (most recent call last):
  File "../../third_party/WebKit/Source/build/scripts/gperf.py", line 88, in <module>
    main()
  File "../../third_party/WebKit/Source/build/scripts/gperf.py", line 85, in main
    generate_gperf(gperf_path, open(infile).read(), gperf_args))
  File "../../third_party/WebKit/Source/build/scripts/gperf.py", line 30, in generate_gperf
    gperf_output = gperf.communicate(gperf_input)[0]
  File "E:\b\depot_tools\win_tools-2_7_6_bin\python\bin\lib\subprocess.py", line 798, in communicate
    return self._communicate(input)
  File "E:\b\depot_tools\win_tools-2_7_6_bin\python\bin\lib\subprocess.py", line 1035, in _communicate
    self.stdin.write(input)
IOError: [Errno 22] Invalid argument

Original change's description:
> various small tweaks to blink's gperf use
> 
> * make gperf.py call generate_gperf() both when it's invoked via
>   use_jinja_gperf_template() as well as when it's called directly
>   as a standalone script
> 
> * make generate_gperf() do massaging of gperf's output to remove
>   uses of the `register` keyword (needed to build with -std=c++17)
>   and replace `/*FALLTHROUGH*/` with real FALLTHROUGH statements
>   (needed for -Wimplicit-fallthrough)
> 
> * remove now-unneeded suppressions for -Wdeprecated-register
> 
> * remove TODO about removing gperf.py; that's from a time when the
>   script was 1 non-comment line long
> 
> * bump check_output() requirement in comment to 3.4 (since that added
>   the input= parameter)
> 
> * add missing dependency on gperf.py to build steps calling it
>   through the jinja interface, so that these edges rerun when
>   gperf.py gets modified
> 
> * add a comment mentioning gperf.py at the start of the generated
>   outputs
> 
> * make :character_data not call gperf.py since it doesn't use gperf,
>   and make it use compiled_action() instead which is made for
>   exactly character_data's use case
> 
> No intended behavior change.
> 
> Bug: 752720,177475
> Change-Id: I56372729bb47787e2d41a5dff2f30804574770f0
> Reviewed-on: https://chromium-review.googlesource.com/891141
> Commit-Queue: Nico Weber <thakis@chromium.org>
> Reviewed-by: Darren Shen <shend@chromium.org>
> Reviewed-by: Daniel Cheng <dcheng@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#533269}

TBR=dcheng@chromium.org,thakis@chromium.org,shend@chromium.org

Change-Id: Iddbf12ba341fa4ea456552f449154bc5d6328073
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 752720, 177475
Reviewed-on: https://chromium-review.googlesource.com/895543Reviewed-by: default avatarRouslan Solomakhin <rouslan@chromium.org>
Commit-Queue: Rouslan Solomakhin <rouslan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#533276}
parent a27c5abe
......@@ -14,6 +14,12 @@
#pragma warning(disable : 4302 4311)
#endif
#if defined(__clang__)
#pragma clang diagnostic push
// TODO(thakis): Remove once we use a gperf that no longer produces "register".
#pragma clang diagnostic ignored "-Wdeprecated-register"
#endif
namespace blink {
namespace {
......@@ -42,6 +48,10 @@ struct Property;
{% endfor %}
%%
#if defined(__clang__)
#pragma clang diagnostic pop
#endif
const Property* FindDescriptor(const char* str, unsigned int len) {
return AtRuleDescriptorHash::findDescriptorImpl(str, len);
}
......
......@@ -14,6 +14,12 @@
#pragma warning(disable : 4302 4311)
#endif
#if defined(__clang__)
#pragma clang diagnostic push
// TODO(thakis): Remove once we use a gperf that no longer produces "register".
#pragma clang diagnostic ignored "-Wdeprecated-register"
#endif
namespace blink {
static const char valueListStringPool[] = {
{% for keyword in value_keywords %}
......@@ -47,6 +53,10 @@ struct Value;
{% endfor %}
%%
#if defined(__clang__)
#pragma clang diagnostic pop
#endif
const Value* FindValue(const char* str, unsigned int len) {
return CSSValueKeywordsHash::findValueImpl(str, len);
}
......
......@@ -4,18 +4,24 @@
# Invokes gperf for the GN build.
# Usage: gperf.py [--developer_dir PATH_TO_XCODE] gperf ...
# TODO(brettw) this can be removed once the run_executable rules have been
# checked in for the GN build.
import argparse
import os
import re
import subprocess
import sys
import template_expander
def generate_gperf(gperf_path, gperf_input, gperf_args):
# FIXME: If we could depend on Python 3.4, we would use
def generate_gperf(gperf_path, gperf_input, extra_args=None):
# FIXME: If we could depend on Python 2.7, we would use
# subprocess.check_output
gperf_args = [gperf_path, '--key-positions=*', '-P', '-n']
gperf_args.extend(['-m', '50']) # Pick best of 50 attempts.
gperf_args.append('-D') # Allow duplicate hashes -> More compact code.
if extra_args:
gperf_args.extend(extra_args)
# If gperf isn't in the path we get an OSError. We don't want to use
# the normal solution of shell=True (as this has to run on many
......@@ -23,23 +29,11 @@ def generate_gperf(gperf_path, gperf_input, gperf_args):
# CalledProcessError like subprocess would do when shell=True is set.
try:
gperf = subprocess.Popen(
[gperf_path] + gperf_args,
gperf_args,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
universal_newlines=True)
gperf_output = gperf.communicate(gperf_input)[0]
# Massage gperf output to be more palatable for modern compilers.
# TODO(thakis): Upstream these to gperf so we don't need massaging.
# `register` is deprecated in C++11 and removed in C++17, so remove
# it from gperf's output.
# https://savannah.gnu.org/bugs/index.php?53029
gperf_output = re.sub(r'\bregister ', '', gperf_output)
# -Wimplicit-fallthrough needs an explicit fallthrough statement,
# so replace gperf's /*FALLTHROUGH*/ comment with the statement.
# https://savannah.gnu.org/bugs/index.php?53028
gperf_output = gperf_output.replace('/*FALLTHROUGH*/', ' FALLTHROUGH;')
script = 'third_party/WebKit/Source/build/scripts/gperf.py'
return '// Generated by %s\n' % script + gperf_output
return gperf.communicate(gperf_input)[0]
except OSError:
raise subprocess.CalledProcessError(
127, gperf_args, output='Command not found.')
......@@ -54,12 +48,7 @@ def use_jinja_gperf_template(template_path, gperf_extra_args=None):
gperf_path = parameters['gperf_path']
gperf_input = template_expander.apply_template(template_path,
parameters)
gperf_args = ['--key-positions=*', '-P', '-n']
gperf_args.extend(['-m', '50']) # Pick best of 50 attempts.
gperf_args.append('-D') # Allow duplicate hashes -> More compact code.
if gperf_extra_args:
gperf_args.extend(gperf_extra_args)
return generate_gperf(gperf_path, gperf_input, gperf_args)
return generate_gperf(gperf_path, gperf_input, gperf_extra_args)
generator_internal.func_name = generator.func_name
return generator_internal
return wrapper
......@@ -68,21 +57,11 @@ def use_jinja_gperf_template(template_path, gperf_extra_args=None):
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--developer_dir", required=False)
parser.add_argument("--output-file")
args, unknownargs = parser.parse_known_args()
if args.developer_dir:
os.environ['DEVELOPER_DIR'] = args.developer_dir
gperf_path, gperf_args = unknownargs[0], unknownargs[1:]
infile = None
for arg in gperf_args:
if os.path.isfile(arg):
assert infile is None, 'duplicate inputs? %s, %s' % (infile, arg)
infile = arg
assert infile is not None, 'no input found'
open(args.output_file, 'wb').write(
generate_gperf(gperf_path, open(infile).read(), gperf_args))
subprocess.check_call(unknownargs)
if __name__ == '__main__':
main()
......@@ -18,6 +18,12 @@
#pragma warning(disable : 4302 4311)
#endif
#if defined(__clang__)
#pragma clang diagnostic push
// TODO(thakis): Remove once we use a gperf that no longer produces "register".
#pragma clang diagnostic ignored "-Wdeprecated-register"
#endif
namespace blink {
%}
%struct-type
......@@ -37,6 +43,10 @@ struct Property;
{{property_to_enum_map}}
%%
#if defined(__clang__)
#pragma clang diagnostic pop
#endif
const Property* FindProperty(const char* str, unsigned int len) {
return {{class_name}}Hash::findPropertyImpl(str, len);
}
......
......@@ -1098,7 +1098,6 @@ css_properties("make_core_generated_css_shorthand_property_classes") {
css_properties("make_core_generated_css_property_names") {
script = "../build/scripts/make_css_property_names.py"
other_inputs = [
"../build/scripts/gperf.py",
"../build/scripts/templates/CSSPropertyNames.cpp.tmpl",
"../build/scripts/templates/CSSPropertyNames.h.tmpl",
]
......@@ -1111,7 +1110,6 @@ css_properties("make_core_generated_css_property_names") {
code_generator("make_core_generated_atrule_names") {
script = "../build/scripts/core/css/parser/make_atrule_names.py"
json_inputs = [ "css/parser/AtRuleNames.json5" ]
other_inputs = [ "../build/scripts/gperf.py" ]
templates = [
"../build/scripts/core/css/parser/templates/AtRuleDescriptors.cpp.tmpl",
"../build/scripts/core/css/parser/templates/AtRuleDescriptors.h.tmpl",
......@@ -1179,7 +1177,6 @@ code_generator("make_core_generated_css_value_keywords") {
"css/CSSValueKeywords.json5",
"css/SVGCSSValueKeywords.json5",
]
other_inputs = [ "../build/scripts/gperf.py" ]
templates = [
"../build/scripts/core/css/templates/CSSValueKeywords.cpp.tmpl",
"../build/scripts/core/css/templates/CSSValueKeywords.h.tmpl",
......
......@@ -3,7 +3,6 @@
# found in the LICENSE file.
import("//build/buildflag_header.gni")
import("//build/compiled_action.gni")
import("//build/config/features.gni")
import("//build/config/jumbo.gni")
import("//build/config/ui.gni")
......@@ -94,12 +93,26 @@ action("color_data") {
]
}
compiled_action("character_data") {
tool = ":character_data_generator"
action("character_data") {
script = "../build/scripts/gperf.py"
deps = [
":character_data_generator($host_toolchain)",
]
output_file = "$blink_platform_output_dir/CharacterPropertyData.cpp"
outputs = [
"$blink_platform_output_dir/CharacterPropertyData.cpp",
output_file,
]
# Find character_data_generator, which is generated in a different directory
# when cross-compile.
generator = "./" + rebase_path(
get_label_info(":character_data_generator($host_toolchain)",
"root_out_dir") + "/character_data_generator",
root_build_dir)
args = [
generator,
rebase_path(output_file, root_build_dir),
]
args = rebase_path(outputs, root_build_dir)
}
action("instrumentation_probes") {
......
......@@ -4,6 +4,12 @@
namespace blink {
#if defined(__clang__)
#pragma clang diagnostic push
// TODO(thakis): Remove once we use a gperf that no longer produces "register".
#pragma clang diagnostic ignored "-Wdeprecated-register"
#endif
%}
%struct-type
struct NamedColor;
......@@ -170,6 +176,10 @@ yellow, 0xffffff00
yellowgreen, 0xff9acd32
%%
#if defined(__clang__)
#pragma clang diagnostic pop
#endif
const struct NamedColor* FindColor(const char* str, unsigned len) {
return ColorDataHash::findColorImpl(str, len);
}
......
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