Commit f8838172 authored by Daniel McArdle's avatar Daniel McArdle Committed by Commit Bot

Remove automatic Bison invocation for blink's xpath_grammar.y

To avoid targeting many versions of Bison, we will now require editors
of xpath_grammar.y to manually regenerate the generated files. See
xpath_grammar.y for instructions on running Bison.

Since we're only targeting new versions of Bison, we can now replace
the %pure-parser directive with the equivalent %define. As a result,
we no longer need to silence the warning about %pure-parser.

Also removing //third_party/bison from DEPS, which contains a snapshot
of a Windows fork of Bison 2.4.1 (from 2012).

Bug: 1028421
Change-Id: I8deb986f0cafb8e7f093c5def71d427709a4a845
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1954609Reviewed-by: default avatarChris Palmer <palmer@chromium.org>
Reviewed-by: default avatarNico Weber <thakis@chromium.org>
Commit-Queue: Dan McArdle <dmcardle@chromium.org>
Cr-Commit-Position: refs/heads/master@{#722623}
parent 03a8efef
...@@ -797,11 +797,6 @@ deps = { ...@@ -797,11 +797,6 @@ deps = {
'dep_type': 'cipd', 'dep_type': 'cipd',
}, },
'src/third_party/bison': {
'url': Var('chromium_git') + '/chromium/deps/bison.git' + '@' + '083c9a45e4affdd5464ee2b224c2df649c6e26c3',
'condition': 'checkout_win',
},
'src/third_party/boringssl/src': 'src/third_party/boringssl/src':
Var('boringssl_git') + '/boringssl.git' + '@' + Var('boringssl_revision'), Var('boringssl_git') + '/boringssl.git' + '@' + Var('boringssl_revision'),
......
...@@ -4,13 +4,14 @@ ...@@ -4,13 +4,14 @@
"""Top-level presubmit script for Blink. """Top-level presubmit script for Blink.
See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts See https://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
for more details about the presubmit API built into gcl. for more details about the presubmit API built into gcl.
""" """
import imp import imp
import inspect import inspect
import os import os
import re
try: try:
# pylint: disable=C0103 # pylint: disable=C0103
...@@ -103,6 +104,10 @@ def _FilterPaths(input_api): ...@@ -103,6 +104,10 @@ def _FilterPaths(input_api):
continue continue
if '/PRESUBMIT' in file_path: if '/PRESUBMIT' in file_path:
continue continue
# Skip files that were generated by bison.
if re.search('third_party/blink/renderer/' +
'core/xml/xpath_grammar_generated\.(cc|h)$', file_path):
continue
files.append(input_api.os_path.join('..', '..', file_path)) files.append(input_api.os_path.join('..', '..', file_path))
return files return files
......
...@@ -62,13 +62,14 @@ assert inputName == 'xpath_grammar.y' ...@@ -62,13 +62,14 @@ assert inputName == 'xpath_grammar.y'
prefix = {'xpath_grammar.y': 'xpathyy'}[inputName] prefix = {'xpath_grammar.y': 'xpathyy'}[inputName]
(inputRoot, inputExt) = os.path.splitext(inputName) (inputRoot, inputExt) = os.path.splitext(inputName)
newInputRoot = inputRoot + '_generated'
# The generated .h will be in a different location depending on the bison # The generated .h will be in a different location depending on the bison
# version. # version.
outputHTries = [ outputHTries = [
os.path.join(outputDir, inputRoot + '.cpp.h'), os.path.join(outputDir, newInputRoot + '.cpp.h'),
os.path.join(outputDir, inputRoot + '.hpp'), os.path.join(outputDir, newInputRoot + '.hpp'),
os.path.join(outputDir, inputRoot + '.hh'), os.path.join(outputDir, newInputRoot + '.hh'),
] ]
for outputHTry in outputHTries: for outputHTry in outputHTries:
...@@ -78,7 +79,7 @@ for outputHTry in outputHTries: ...@@ -78,7 +79,7 @@ for outputHTry in outputHTries:
if e.errno != errno.ENOENT: if e.errno != errno.ENOENT:
raise raise
outputCpp = os.path.join(outputDir, inputRoot + '.cc') outputCpp = os.path.join(outputDir, newInputRoot + '.cc')
returnCode = subprocess.call([bisonExe, '-d', '-p', prefix, inputFile, '-o', outputCpp]) returnCode = subprocess.call([bisonExe, '-d', '-p', prefix, inputFile, '-o', outputCpp])
assert returnCode == 0 assert returnCode == 0
...@@ -96,21 +97,26 @@ for outputHTry in outputHTries: ...@@ -96,21 +97,26 @@ for outputHTry in outputHTries:
assert outputHTmp != None assert outputHTmp != None
# Read the header file in under the generated name and remove it.
outputHFile = open(outputHTmp)
outputHContents = outputHFile.read()
outputHFile.close()
os.unlink(outputHTmp)
# Rewrite the generated header with #include guards. def modifyFile(path, prefixLines, suffixLines):
outputH = os.path.join(outputDir, inputRoot + '.h') prefixLines = map(lambda s: s + '\n', prefixLines)
suffixLines = map(lambda s: s + '\n', suffixLines)
outputHInGen = outputH.replace('gen/', '') with open(path, 'r') as f:
headerGuard = NameStyleConverter(outputHInGen).to_header_guard() oldLines = f.readlines()
newLines = prefixLines + oldLines + suffixLines
with open(path, 'w') as f:
f.writelines(newLines)
outputHFile = open(outputH, 'w') # Rewrite the generated header with #include guards.
print >>outputHFile, '#ifndef %s' % headerGuard kClangFormatDisableLine = "// clang-format off"
print >>outputHFile, '#define %s' % headerGuard outputH = os.path.join(outputDir, newInputRoot + '.h')
print >>outputHFile, outputHContents headerGuard = NameStyleConverter(outputH).to_header_guard()
print >>outputHFile, '#endif // %s' % headerGuard modifyFile(outputHTmp,
outputHFile.close() [kClangFormatDisableLine,
'#ifndef %s' % headerGuard,
'#define %s' % headerGuard,
], ['#endif // %s' % headerGuard]
)
os.rename(outputHTmp, outputH)
modifyFile(outputCpp, [kClangFormatDisableLine], [])
...@@ -71,13 +71,10 @@ make_trie_helpers_files = ...@@ -71,13 +71,10 @@ make_trie_helpers_files =
# on Posix we want to run the system one on the path. # on Posix we want to run the system one on the path.
if (host_os == "win") { if (host_os == "win") {
gperf_exe = rebase_path("//third_party/gperf/bin/gperf.exe", root_build_dir) gperf_exe = rebase_path("//third_party/gperf/bin/gperf.exe", root_build_dir)
bison_exe = rebase_path("//third_party/bison/bin/bison.exe", root_build_dir)
} else if (is_mac) { } else if (is_mac) {
gperf_exe = mac_bin_path + "gperf" gperf_exe = mac_bin_path + "gperf"
bison_exe = mac_bin_path + "bison"
} else { } else {
gperf_exe = "gperf" gperf_exe = "gperf"
bison_exe = "bison"
} }
# Templates -------------------------------------------------------------------- # Templates --------------------------------------------------------------------
......
...@@ -944,30 +944,11 @@ blink_python_runner("make_core_generated_web_origin_trials") { ...@@ -944,30 +944,11 @@ blink_python_runner("make_core_generated_web_origin_trials") {
] ]
} }
action_foreach("make_core_generated_bison") {
script = "../build/scripts/rule_bison.py"
sources = [
"xml/xpath_grammar.y",
]
outputs = [
"$blink_core_output_dir/{{source_name_part}}.cc",
"$blink_core_output_dir/{{source_name_part}}.h",
]
args = [
"{{source}}",
rel_blink_core_gen_dir,
bison_exe,
]
deps = make_core_generated_deps
}
# Targets from above that generate outputs that need to be compiled. # Targets from above that generate outputs that need to be compiled.
# All sources declared as outputs from these targets will be compiled into one # All sources declared as outputs from these targets will be compiled into one
# target. # target.
targets_generating_sources = [ targets_generating_sources = [
":make_core_generated_atrule_names", ":make_core_generated_atrule_names",
":make_core_generated_bison",
":make_core_generated_css_primitive_value_unit_trie", ":make_core_generated_css_primitive_value_unit_trie",
":make_core_generated_computed_style_initial_values", ":make_core_generated_computed_style_initial_values",
":make_core_generated_computed_style_base", ":make_core_generated_computed_style_base",
......
...@@ -35,6 +35,8 @@ blink_core_sources("xml") { ...@@ -35,6 +35,8 @@ blink_core_sources("xml") {
"xpath_expression_node.h", "xpath_expression_node.h",
"xpath_functions.cc", "xpath_functions.cc",
"xpath_functions.h", "xpath_functions.h",
"xpath_grammar_generated.cc",
"xpath_grammar_generated.h",
"xpath_node_set.cc", "xpath_node_set.cc",
"xpath_node_set.h", "xpath_node_set.h",
"xpath_ns_resolver.h", "xpath_ns_resolver.h",
...@@ -64,11 +66,4 @@ blink_core_sources("xml") { ...@@ -64,11 +66,4 @@ blink_core_sources("xml") {
"xslt_unicode_sort.cc", "xslt_unicode_sort.cc",
"xslt_unicode_sort.h", "xslt_unicode_sort.h",
] ]
# XCode's ancient bison (v2.3 from 2006) prevents us from updating a
# deprecated bison directive. This will silence the warning.
# See https://crbug.com/1028421.
if (!is_mac) {
cflags = [ "-Wno-deprecated" ]
}
} }
...@@ -25,6 +25,21 @@ ...@@ -25,6 +25,21 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
/* === NOTA BENE ===
* If you modify this file, you must run bison to regenerate the corresponding
* .cc and .h files. From chromium's root directory, run the following command
* on a system with a modern version of bison (>= 3.4.1):
*
* $ third_party/blink/renderer/build/scripts/rule_bison.py \
* third_party/blink/renderer/core/xml/xpath_grammar.y \
* third_party/blink/renderer/core/xml/ \
* bison
*
* This process is not automated because newer bison releases have diverged from
* (1) the version included with Xcode and (2) the Windows binary checked into
* //third_party/bison. See https://crbug.com/1028421.
*/
%{ %{
#include "third_party/blink/renderer/core/xml/xpath_functions.h" #include "third_party/blink/renderer/core/xml/xpath_functions.h"
...@@ -51,7 +66,7 @@ ...@@ -51,7 +66,7 @@
using blink::xpath::Step; using blink::xpath::Step;
%} %}
%pure-parser %define api.pure full
%parse-param { blink::xpath::Parser* parser } %parse-param { blink::xpath::Parser* parser }
%union %union
......
This diff is collapsed.
// clang-format off
#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_XML_XPATH_GRAMMAR_GENERATED_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_XML_XPATH_GRAMMAR_GENERATED_H_
/* A Bison parser, made by GNU Bison 3.4.1. */
/* Bison interface for Yacc-like parsers in C
Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2019 Free Software Foundation,
Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
under terms of your choice, so long as that work isn't itself a
parser generator using the skeleton or a modified version thereof
as a parser skeleton. Alternatively, if you modify or redistribute
the parser skeleton itself, you may (at your option) remove this
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
/* Undocumented macros, especially those whose name start with YY_,
are private implementation details. Do not rely on them. */
#ifndef YY_XPATHYY_THIRD_PARTY_BLINK_RENDERER_CORE_XML_XPATH_GRAMMAR_GENERATED_HH_INCLUDED
# define YY_XPATHYY_THIRD_PARTY_BLINK_RENDERER_CORE_XML_XPATH_GRAMMAR_GENERATED_HH_INCLUDED
/* Debug traces. */
#ifndef YYDEBUG
# define YYDEBUG 0
#endif
#if YYDEBUG
extern int xpathyydebug;
#endif
/* Token type. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
enum yytokentype
{
MULOP = 258,
EQOP = 259,
RELOP = 260,
PLUS = 261,
MINUS = 262,
OR = 263,
AND = 264,
AXISNAME = 265,
NODETYPE = 266,
PI = 267,
FUNCTIONNAME = 268,
LITERAL = 269,
VARIABLEREFERENCE = 270,
NUMBER = 271,
DOTDOT = 272,
SLASHSLASH = 273,
NAMETEST = 274,
XPATH_ERROR = 275
};
#endif
/* Value type. */
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
union YYSTYPE
{
#line 73 "third_party/blink/renderer/core/xml/xpath_grammar.y"
blink::xpath::Step::Axis axis;
blink::xpath::Step::NodeTest* node_test;
blink::xpath::NumericOp::Opcode num_op;
blink::xpath::EqTestOp::Opcode eq_op;
String* str;
blink::xpath::Expression* expr;
blink::HeapVector<blink::Member<blink::xpath::Predicate>>* pred_list;
blink::HeapVector<blink::Member<blink::xpath::Expression>>* arg_list;
blink::xpath::Step* step;
blink::xpath::LocationPath* location_path;
#line 91 "third_party/blink/renderer/core/xml/xpath_grammar_generated.hh"
};
typedef union YYSTYPE YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define YYSTYPE_IS_DECLARED 1
#endif
int xpathyyparse (blink::xpath::Parser* parser);
#endif /* !YY_XPATHYY_THIRD_PARTY_BLINK_RENDERER_CORE_XML_XPATH_GRAMMAR_GENERATED_HH_INCLUDED */
#endif // THIRD_PARTY_BLINK_RENDERER_CORE_XML_XPATH_GRAMMAR_GENERATED_H_
...@@ -29,9 +29,9 @@ ...@@ -29,9 +29,9 @@
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "third_party/blink/renderer/core/xml/xpath_evaluator.h" #include "third_party/blink/renderer/core/xml/xpath_evaluator.h"
#include "third_party/blink/renderer/core/xml/xpath_grammar_generated.h"
#include "third_party/blink/renderer/core/xml/xpath_ns_resolver.h" #include "third_party/blink/renderer/core/xml/xpath_ns_resolver.h"
#include "third_party/blink/renderer/core/xml/xpath_path.h" #include "third_party/blink/renderer/core/xml/xpath_path.h"
#include "third_party/blink/renderer/core/xpath_grammar.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h" #include "third_party/blink/renderer/platform/bindings/exception_state.h"
#include "third_party/blink/renderer/platform/wtf/std_lib_extras.h" #include "third_party/blink/renderer/platform/wtf/std_lib_extras.h"
#include "third_party/blink/renderer/platform/wtf/text/string_hash.h" #include "third_party/blink/renderer/platform/wtf/text/string_hash.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