summaryrefslogtreecommitdiffstats
path: root/webkit/build
diff options
context:
space:
mode:
Diffstat (limited to 'webkit/build')
-rw-r--r--webkit/build/action_csspropertynames.py142
-rwxr-xr-xwebkit/build/action_cssvaluekeywords.py144
-rwxr-xr-xwebkit/build/action_jsconfig.py47
-rwxr-xr-xwebkit/build/action_makenames.py147
-rwxr-xr-xwebkit/build/action_maketokenizer.py72
-rwxr-xr-xwebkit/build/action_useragentstylesheets.py74
-rwxr-xr-xwebkit/build/rule_binding.py100
-rwxr-xr-xwebkit/build/rule_bison.py75
-rwxr-xr-xwebkit/build/rule_gperf.py54
9 files changed, 855 insertions, 0 deletions
diff --git a/webkit/build/action_csspropertynames.py b/webkit/build/action_csspropertynames.py
new file mode 100644
index 0000000..8aa2b20
--- /dev/null
+++ b/webkit/build/action_csspropertynames.py
@@ -0,0 +1,142 @@
+#!/usr/bin/python
+
+# Copyright (c) 2009 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.
+
+# action_csspropertynames.py is a harness script to connect actions sections of
+# gyp-based builds to makeprop.pl.
+#
+# usage: action_makenames.py OUTPUTS -- INPUTS
+#
+# Exactly two outputs must be specified: a path to each of CSSPropertyNames.cpp
+# and CSSPropertyNames.h.
+#
+# Multiple inputs may be specified. One input must have a basename of
+# makeprop.pl; this is taken as the path to makeprop.pl. All other inputs are
+# paths to .in files that are used as input to makeprop.pl; at least one,
+# CSSPropertyNames.in, is required.
+
+
+import os
+import posixpath
+import shutil
+import subprocess
+import sys
+
+
+def SplitArgsIntoSections(args):
+ sections = []
+ while len(args) > 0:
+ if not '--' in args:
+ # If there is no '--' left, everything remaining is an entire section.
+ dashes = len(args)
+ else:
+ dashes = args.index('--')
+
+ sections.append(args[:dashes])
+
+ # Next time through the loop, look at everything after this '--'.
+ if dashes + 1 == len(args):
+ # If the '--' is at the end of the list, we won't come back through the
+ # loop again. Add an empty section now corresponding to the nothingness
+ # following the final '--'.
+ args = []
+ sections.append(args)
+ else:
+ args = args[dashes + 1:]
+
+ return sections
+
+
+def main(args):
+ (outputs, inputs) = SplitArgsIntoSections(args[1:])
+
+ # Make all output pathnames absolute so that they can be accessed after
+ # changing directory.
+ for index in xrange(0, len(outputs)):
+ outputs[index] = os.path.abspath(outputs[index])
+
+ output_dir = os.path.dirname(outputs[0])
+
+ # Look at the inputs and figure out which one is makeprop.pl and which are
+ # inputs to that script.
+ makeprop_input = None
+ in_files = []
+ for input in inputs:
+ # Make input pathnames absolute so they can be accessed after changing
+ # directory. On Windows, convert \ to / for inputs to the perl script to
+ # work around the intermix of activepython + cygwin perl.
+ input_abs = os.path.abspath(input)
+ input_abs_posix = input_abs.replace(os.path.sep, posixpath.sep)
+ input_basename = os.path.basename(input)
+ if input_basename == 'makeprop.pl':
+ assert makeprop_input == None
+ makeprop_input = input_abs
+ elif input_basename.endswith('.in'):
+ in_files.append(input_abs_posix)
+ else:
+ assert False
+
+ assert makeprop_input != None
+ assert len(in_files) >= 1
+
+ # Change to the output directory because makeprop.pl puts output in its
+ # working directory.
+ os.chdir(output_dir)
+
+ # Merge all in_files into a single file whose name will be the same as the
+ # first listed in_file, but in the output directory.
+ merged_path = os.path.basename(in_files[0])
+ merged = open(merged_path, 'wb') # 'wb' to get \n only on windows
+
+ # Make sure there aren't any duplicate lines in the in files.
+ line_dict = {}
+ for in_file_path in in_files:
+ in_file = open(in_file_path)
+ for line in in_file:
+ line = line.rstrip()
+ if line.startswith('#'):
+ line = ''
+ if line == '':
+ continue
+ if line in line_dict:
+ raise KeyError, 'Duplicate value %s' % line
+ line_dict[line] = True
+ print >>merged, line
+ in_file.close()
+
+ merged.close()
+
+ # Build up the command.
+ command = ['perl', makeprop_input]
+
+ # Do it. check_call is new in 2.5, so simulate its behavior with call and
+ # assert.
+ return_code = subprocess.call(command)
+ assert return_code == 0
+
+ # Don't leave behind the merged file or the .gperf file created by
+ # makeprop.
+ (root, ext) = os.path.splitext(merged_path)
+ gperf_path = root + '.gperf'
+ os.unlink(gperf_path)
+ os.unlink(merged_path)
+
+ # Go through the outputs. Any output that belongs in a different directory
+ # is moved. Do a copy and delete instead of rename for maximum portability.
+ # Note that all paths used in this section are still absolute.
+ for output in outputs:
+ this_output_dir = os.path.dirname(output)
+ if this_output_dir != output_dir:
+ output_basename = os.path.basename(output)
+ src = os.path.join(output_dir, output_basename)
+ dst = os.path.join(this_output_dir, output_basename)
+ shutil.copyfile(src, dst)
+ os.unlink(src)
+
+ return return_code
+
+
+if __name__ == '__main__':
+ sys.exit(main(sys.argv))
diff --git a/webkit/build/action_cssvaluekeywords.py b/webkit/build/action_cssvaluekeywords.py
new file mode 100755
index 0000000..12b0f40
--- /dev/null
+++ b/webkit/build/action_cssvaluekeywords.py
@@ -0,0 +1,144 @@
+#!/usr/bin/python
+
+# Copyright (c) 2009 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.
+
+# action_cssvaluekeywords.py is a harness script to connect actions sections of
+# gyp-based builds to makevalues.pl.
+#
+# usage: action_cssvaluekeywords.py OUTPUTS -- INPUTS
+#
+# Exactly two outputs must be specified: a path to each of CSSValueKeywords.c
+# and CSSValueKeywords.h.
+#
+# Multiple inputs may be specified. One input must have a basename of
+# makevalues.pl; this is taken as the path to makevalues.pl. All other inputs
+# are paths to .in files that are used as input to makevalues.pl; at least
+# one, CSSValueKeywords.in, is required.
+
+
+import os
+import posixpath
+import shutil
+import subprocess
+import sys
+
+
+def SplitArgsIntoSections(args):
+ sections = []
+ while len(args) > 0:
+ if not '--' in args:
+ # If there is no '--' left, everything remaining is an entire section.
+ dashes = len(args)
+ else:
+ dashes = args.index('--')
+
+ sections.append(args[:dashes])
+
+ # Next time through the loop, look at everything after this '--'.
+ if dashes + 1 == len(args):
+ # If the '--' is at the end of the list, we won't come back through the
+ # loop again. Add an empty section now corresponding to the nothingness
+ # following the final '--'.
+ args = []
+ sections.append(args)
+ else:
+ args = args[dashes + 1:]
+
+ return sections
+
+
+def main(args):
+ (outputs, inputs) = SplitArgsIntoSections(args[1:])
+
+ # Make all output pathnames absolute so that they can be accessed after
+ # changing directory.
+ for index in xrange(0, len(outputs)):
+ outputs[index] = os.path.abspath(outputs[index])
+
+ output_dir = os.path.dirname(outputs[0])
+
+ # Look at the inputs and figure out which one is makevalues.pl and which are
+ # inputs to that script.
+ makevalues_input = None
+ in_files = []
+ for input in inputs:
+ # Make input pathnames absolute so they can be accessed after changing
+ # directory. On Windows, convert \ to / for inputs to the perl script to
+ # work around the intermix of activepython + cygwin perl.
+ input_abs = os.path.abspath(input)
+ input_abs_posix = input_abs.replace(os.path.sep, posixpath.sep)
+ input_basename = os.path.basename(input)
+ if input_basename == 'makevalues.pl':
+ assert makevalues_input == None
+ makevalues_input = input_abs
+ elif input_basename.endswith('.in'):
+ in_files.append(input_abs_posix)
+ else:
+ assert False
+
+ assert makevalues_input != None
+ assert len(in_files) >= 1
+
+ # Change to the output directory because makevalues.pl puts output in its
+ # working directory.
+ os.chdir(output_dir)
+
+ # Merge all in_files into a single file whose name will be the same as the
+ # first listed in_file, but in the output directory.
+ merged_path = os.path.basename(in_files[0])
+ merged = open(merged_path, 'wb') # 'wb' to get \n only on windows
+
+ # Make sure there aren't any duplicate lines in the in files. Lowercase
+ # everything because CSS values are case-insensitive.
+ line_dict = {}
+ for in_file_path in in_files:
+ in_file = open(in_file_path)
+ for line in in_file:
+ line = line.rstrip()
+ if line.startswith('#'):
+ line = ''
+ if line == '':
+ continue
+ line = line.lower()
+ if line in line_dict:
+ raise KeyError, 'Duplicate value %s' % line
+ line_dict[line] = True
+ print >>merged, line
+ in_file.close()
+
+ merged.close()
+
+ # Build up the command.
+ command = ['perl', makevalues_input]
+
+ # Do it. check_call is new in 2.5, so simulate its behavior with call and
+ # assert.
+ return_code = subprocess.call(command)
+ assert return_code == 0
+
+ # Don't leave behind the merged file or the .gperf file created by
+ # makevalues.
+ (root, ext) = os.path.splitext(merged_path)
+ gperf_path = root + '.gperf'
+ os.unlink(gperf_path)
+ os.unlink(merged_path)
+
+ # Go through the outputs. Any output that belongs in a different directory
+ # is moved. Do a copy and delete instead of rename for maximum portability.
+ # Note that all paths used in this section are still absolute.
+ for output in outputs:
+ this_output_dir = os.path.dirname(output)
+ if this_output_dir != output_dir:
+ output_basename = os.path.basename(output)
+ src = os.path.join(output_dir, output_basename)
+ dst = os.path.join(this_output_dir, output_basename)
+ shutil.copyfile(src, dst)
+ os.unlink(src)
+
+ return return_code
+
+
+if __name__ == '__main__':
+ sys.exit(main(sys.argv))
diff --git a/webkit/build/action_jsconfig.py b/webkit/build/action_jsconfig.py
new file mode 100755
index 0000000..2160983
--- /dev/null
+++ b/webkit/build/action_jsconfig.py
@@ -0,0 +1,47 @@
+#!/usr/bin/python
+
+# Copyright (c) 2009 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.
+
+# usage: action_jsconfig.py JS_ENGINE OUTPUT_DIR CONFIG_H_IN FILES_TO_COPY
+# JS_ENGINE may be v8 at present. jsc will be added in the future.
+# CONFIG_H_DIR is the directory to put config.h in.
+# OUTPUT_DIR is the directory to put other files in.
+# CONFIG_H_IN is the path to config.h.in upon which config.h will be based.
+# FILES_TO_COPY is a list of additional headers to be copied. It may be empty.
+
+import errno
+import os
+import os.path
+import shutil
+import sys
+
+assert len(sys.argv) >= 5
+js_engine = sys.argv[1]
+config_h_dir = sys.argv[2]
+output_dir = sys.argv[3]
+config_h_in_path = sys.argv[4]
+files_to_copy = sys.argv[5:]
+
+config_h_path = os.path.join(config_h_dir, 'config.h')
+
+assert js_engine == 'v8'
+
+config_h_in_file = open(config_h_in_path)
+config_h_in_contents = config_h_in_file.read()
+config_h_in_file.close()
+
+config_h_file = open(config_h_path, 'w')
+print >>config_h_file, config_h_in_contents
+if js_engine == 'v8':
+ print >>config_h_file, '#define WTF_USE_V8_BINDING 1'
+ print >>config_h_file, '#define WTF_USE_NPOBJECT 1'
+config_h_file.close()
+
+for file in files_to_copy:
+ # This is not strictly right for jsc headers, which will want to be in one
+ # more subdirectory named JavaScriptCore.
+ basename = os.path.basename(file)
+ destination = os.path.join(output_dir, basename)
+ shutil.copy(file, destination)
diff --git a/webkit/build/action_makenames.py b/webkit/build/action_makenames.py
new file mode 100755
index 0000000..fe95936
--- /dev/null
+++ b/webkit/build/action_makenames.py
@@ -0,0 +1,147 @@
+#!/usr/bin/python
+
+# Copyright (c) 2009 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.
+
+# action_makenames.py is a harness script to connect actions sections of
+# gyp-based builds to make_names.pl.
+#
+# usage: action_makenames.py OUTPUTS -- INPUTS [-- OPTIONS]
+#
+# Multiple OUTPUTS, INPUTS, and OPTIONS may be listed. The sections are
+# separated by -- arguments.
+#
+# The directory name of the first output is chosen as the directory in which
+# make_names will run. If the directory name for any subsequent output is
+# different, those files will be moved to the desired directory.
+#
+# Multiple INPUTS may be listed. An input with a basename matching
+# "make_names.pl" is taken as the path to that script. Inputs with names
+# ending in TagNames.in or tags.in are taken as tag inputs. Inputs with names
+# ending in AttributeNames.in or attrs.in are taken as attribute inputs. There
+# may be at most one tag input and one attribute input. A make_names.pl input
+# is required and at least one tag or attribute input must be present.
+#
+# OPTIONS is a list of additional options to pass to make_names.pl. This
+# section need not be present.
+
+
+import os
+import posixpath
+import shutil
+import subprocess
+import sys
+
+
+def SplitArgsIntoSections(args):
+ sections = []
+ while len(args) > 0:
+ if not '--' in args:
+ # If there is no '--' left, everything remaining is an entire section.
+ dashes = len(args)
+ else:
+ dashes = args.index('--')
+
+ sections.append(args[:dashes])
+
+ # Next time through the loop, look at everything after this '--'.
+ if dashes + 1 == len(args):
+ # If the '--' is at the end of the list, we won't come back through the
+ # loop again. Add an empty section now corresponding to the nothingness
+ # following the final '--'.
+ args = []
+ sections.append(args)
+ else:
+ args = args[dashes + 1:]
+
+ return sections
+
+
+def main(args):
+ sections = SplitArgsIntoSections(args[1:])
+ assert len(sections) == 2 or len(sections) == 3
+ (outputs, inputs) = sections[:2]
+ if len(sections) == 3:
+ options = sections[2]
+ else:
+ options = []
+
+ # Make all output pathnames absolute so that they can be accessed after
+ # changing directory.
+ for index in xrange(0, len(outputs)):
+ outputs[index] = os.path.abspath(outputs[index])
+
+ output_dir = os.path.dirname(outputs[0])
+
+ # Look at the inputs and figure out which ones are make_names.pl, tags, and
+ # attributes. There can be at most one of each, and those are the only
+ # input types supported. make_names.pl is required and at least one of tags
+ # and attributes is required.
+ make_names_input = None
+ tag_input = None
+ attr_input = None
+ for input in inputs:
+ # Make input pathnames absolute so they can be accessed after changing
+ # directory. On Windows, convert \ to / for inputs to the perl script to
+ # work around the intermix of activepython + cygwin perl.
+ input_abs = os.path.abspath(input)
+ input_abs_posix = input_abs.replace(os.path.sep, posixpath.sep)
+ input_basename = os.path.basename(input)
+ if input_basename == 'make_names.pl':
+ assert make_names_input == None
+ make_names_input = input_abs
+ elif input_basename.endswith('TagNames.in') or \
+ input_basename.endswith('tags.in'):
+ assert tag_input == None
+ tag_input = input_abs_posix
+ elif input_basename.endswith('AttributeNames.in') or \
+ input_basename.endswith('attrs.in'):
+ assert attr_input == None
+ attr_input = input_abs_posix
+ else:
+ assert False
+
+ assert make_names_input != None
+ assert tag_input != None or attr_input != None
+
+ # scripts_path is a Perl include directory, located relative to
+ # make_names_input.
+ scripts_path = os.path.normpath(
+ os.path.join(os.path.dirname(make_names_input), os.pardir,
+ 'bindings', 'scripts'))
+
+ # Change to the output directory because make_names.pl puts output in its
+ # working directory.
+ os.chdir(output_dir)
+
+ # Build up the command.
+ command = ['perl', '-I', scripts_path, make_names_input]
+ if tag_input != None:
+ command.extend(['--tags', tag_input])
+ if attr_input != None:
+ command.extend(['--attrs', attr_input])
+ command.extend(options)
+
+ # Do it. check_call is new in 2.5, so simulate its behavior with call and
+ # assert.
+ return_code = subprocess.call(command)
+ assert return_code == 0
+
+ # Go through the outputs. Any output that belongs in a different directory
+ # is moved. Do a copy and delete instead of rename for maximum portability.
+ # Note that all paths used in this section are still absolute.
+ for output in outputs:
+ this_output_dir = os.path.dirname(output)
+ if this_output_dir != output_dir:
+ output_basename = os.path.basename(output)
+ src = os.path.join(output_dir, output_basename)
+ dst = os.path.join(this_output_dir, output_basename)
+ shutil.copyfile(src, dst)
+ os.unlink(src)
+
+ return return_code
+
+
+if __name__ == '__main__':
+ sys.exit(main(sys.argv))
diff --git a/webkit/build/action_maketokenizer.py b/webkit/build/action_maketokenizer.py
new file mode 100755
index 0000000..1823495
--- /dev/null
+++ b/webkit/build/action_maketokenizer.py
@@ -0,0 +1,72 @@
+#!/usr/bin/python
+
+# Copyright (c) 2009 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.
+
+# usage: action_maketokenizer.py OUTPUTS -- INPUTS
+#
+# Multiple INPUTS may be listed. The sections are separated by -- arguments.
+#
+# OUTPUTS must contain a single item: a path to tokenizer.cpp.
+#
+# INPUTS must contain exactly two items. The first item must be the path to
+# maketokenizer. The second item must be the path to tokenizer.flex.
+
+
+import os
+import subprocess
+import sys
+
+
+def SplitArgsIntoSections(args):
+ sections = []
+ while len(args) > 0:
+ if not '--' in args:
+ # If there is no '--' left, everything remaining is an entire section.
+ dashes = len(args)
+ else:
+ dashes = args.index('--')
+
+ sections.append(args[:dashes])
+
+ # Next time through the loop, look at everything after this '--'.
+ if dashes + 1 == len(args):
+ # If the '--' is at the end of the list, we won't come back through the
+ # loop again. Add an empty section now corresponding to the nothingness
+ # following the final '--'.
+ args = []
+ sections.append(args)
+ else:
+ args = args[dashes + 1:]
+
+ return sections
+
+
+def main(args):
+ sections = SplitArgsIntoSections(args[1:])
+ assert len(sections) == 2
+ (outputs, inputs) = sections
+
+ assert len(outputs) == 1
+ output = outputs[0]
+
+ assert len(inputs) == 2
+ maketokenizer = inputs[0]
+ flex_input = inputs[1]
+
+ # Build up the command.
+ command = 'flex -t %s | perl %s > %s' % (flex_input, maketokenizer, output)
+
+ # Do it. check_call is new in 2.5, so simulate its behavior with call and
+ # assert.
+ # TODO(mark): Don't use shell=True, build up the pipeline directly.
+ p = subprocess.Popen(command, shell=True)
+ return_code = p.wait()
+ assert return_code == 0
+
+ return return_code
+
+
+if __name__ == '__main__':
+ sys.exit(main(sys.argv))
diff --git a/webkit/build/action_useragentstylesheets.py b/webkit/build/action_useragentstylesheets.py
new file mode 100755
index 0000000..3394cb7
--- /dev/null
+++ b/webkit/build/action_useragentstylesheets.py
@@ -0,0 +1,74 @@
+#!/usr/bin/python
+
+# Copyright (c) 2009 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.
+
+# usage: action_useragentstylesheets.py OUTPUTS -- INPUTS
+#
+# Multiple OUTPUTS and INPUTS may be listed. The sections are separated by
+# -- arguments.
+#
+# OUTPUTS must contain two items, in order: a path to UserAgentStyleSheets.h
+# and a path to UserAgentStyleSheetsData.cpp.
+#
+# INPUTS must contain at least two items. The first item must be the path to
+# make-css-file-arrays.pl. The remaining items are paths to style sheets to
+# be fed to that script.
+
+
+import os
+import subprocess
+import sys
+
+
+def SplitArgsIntoSections(args):
+ sections = []
+ while len(args) > 0:
+ if not '--' in args:
+ # If there is no '--' left, everything remaining is an entire section.
+ dashes = len(args)
+ else:
+ dashes = args.index('--')
+
+ sections.append(args[:dashes])
+
+ # Next time through the loop, look at everything after this '--'.
+ if dashes + 1 == len(args):
+ # If the '--' is at the end of the list, we won't come back through the
+ # loop again. Add an empty section now corresponding to the nothingness
+ # following the final '--'.
+ args = []
+ sections.append(args)
+ else:
+ args = args[dashes + 1:]
+
+ return sections
+
+
+def main(args):
+ sections = SplitArgsIntoSections(args[1:])
+ assert len(sections) == 2
+ (outputs, inputs) = sections
+
+ assert len(outputs) == 2
+ output_h = outputs[0]
+ output_cpp = outputs[1]
+
+ make_css_file_arrays = inputs[0]
+ style_sheets = inputs[1:]
+
+ # Build up the command.
+ command = ['perl', make_css_file_arrays, output_h, output_cpp]
+ command.extend(style_sheets)
+
+ # Do it. check_call is new in 2.5, so simulate its behavior with call and
+ # assert.
+ return_code = subprocess.call(command)
+ assert return_code == 0
+
+ return return_code
+
+
+if __name__ == '__main__':
+ sys.exit(main(sys.argv))
diff --git a/webkit/build/rule_binding.py b/webkit/build/rule_binding.py
new file mode 100755
index 0000000..96040ee
--- /dev/null
+++ b/webkit/build/rule_binding.py
@@ -0,0 +1,100 @@
+#!/usr/bin/python
+
+# Copyright (c) 2009 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.
+
+# usage: rule_binding.py INPUT CPPDIR HDIR -- INPUTS -- OPTIONS
+#
+# INPUT is an IDL file, such as Whatever.idl.
+#
+# CPPDIR is the directory into which V8Whatever.cpp will be placed. HDIR is
+# the directory into which V8Whatever.h will be placed.
+#
+# The first item in INPUTS is the path to generate-bindings.pl. Remaining
+# items in INPUTS are used to build the Perl module include path.
+#
+# OPTIONS are passed as-is to generate-bindings.pl as additional arguments.
+
+
+import errno
+import os
+import shutil
+import subprocess
+import sys
+
+
+def SplitArgsIntoSections(args):
+ sections = []
+ while len(args) > 0:
+ if not '--' in args:
+ # If there is no '--' left, everything remaining is an entire section.
+ dashes = len(args)
+ else:
+ dashes = args.index('--')
+
+ sections.append(args[:dashes])
+
+ # Next time through the loop, look at everything after this '--'.
+ if dashes + 1 == len(args):
+ # If the '--' is at the end of the list, we won't come back through the
+ # loop again. Add an empty section now corresponding to the nothingness
+ # following the final '--'.
+ args = []
+ sections.append(args)
+ else:
+ args = args[dashes + 1:]
+
+ return sections
+
+
+def main(args):
+ sections = SplitArgsIntoSections(args[1:])
+ assert len(sections) == 3
+ (base, inputs, options) = sections
+
+ assert len(base) == 3
+ input = base[0]
+ cppdir = base[1]
+ hdir = base[2]
+
+ assert len(inputs) > 1
+ generate_bindings = inputs[0]
+ perl_modules = inputs[1:]
+
+ include_dirs = []
+ for perl_module in perl_modules:
+ include_dir = os.path.dirname(perl_module)
+ if not include_dir in include_dirs:
+ include_dirs.append(include_dir)
+
+ # Build up the command.
+ command = ['perl', '-w']
+ for include_dir in include_dirs:
+ command.extend(['-I', include_dir])
+ command.append(generate_bindings)
+ command.extend(options)
+ command.extend(['--outputdir', cppdir, input])
+
+ # Do it. check_call is new in 2.5, so simulate its behavior with call and
+ # assert.
+ return_code = subprocess.call(command)
+ assert return_code == 0
+
+ # Both the .cpp and .h were generated in cppdir, but if hdir is different,
+ # the .h needs to move. Copy it instead of using os.rename for maximum
+ # portability in all cases.
+ if cppdir != hdir:
+ input_basename = os.path.basename(input)
+ (root, ext) = os.path.splitext(input_basename)
+ hname = 'V8%s.h' % root
+ hsrc = os.path.join(cppdir, hname)
+ hdst = os.path.join(hdir, hname)
+ shutil.copyfile(hsrc, hdst)
+ os.unlink(hsrc)
+
+ return return_code
+
+
+if __name__ == '__main__':
+ sys.exit(main(sys.argv))
diff --git a/webkit/build/rule_bison.py b/webkit/build/rule_bison.py
new file mode 100755
index 0000000..5ba2b5a
--- /dev/null
+++ b/webkit/build/rule_bison.py
@@ -0,0 +1,75 @@
+#!/usr/bin/python
+
+# Copyright (c) 2009 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.
+
+# usage: rule_bison.py INPUT_FILE OUTPUT_DIR
+# INPUT_FILE is a path to either CSSGrammar.y or XPathGrammar.y.
+# OUTPUT_DIR is where the bison-generated .cpp and .h files should be placed.
+
+import errno
+import os
+import os.path
+import subprocess
+import sys
+
+assert len(sys.argv) == 3
+
+input_file = sys.argv[1]
+output_dir = sys.argv[2]
+
+input_name = os.path.basename(input_file)
+assert input_name == 'CSSGrammar.y' or input_name == 'XPathGrammar.y'
+prefix = {'CSSGrammar.y': 'cssyy', 'XPathGrammar.y': 'xpathyy'}[input_name]
+
+(input_root, input_ext) = os.path.splitext(input_name)
+
+# The generated .h will be in a different location depending on the bison
+# version.
+output_h_tries = [
+ os.path.join(output_dir, input_root + '.cpp.h'),
+ os.path.join(output_dir, input_root + '.hpp'),
+]
+
+for output_h_try in output_h_tries:
+ try:
+ os.unlink(output_h_try)
+ except OSError, e:
+ if e.errno != errno.ENOENT:
+ raise
+
+output_cpp = os.path.join(output_dir, input_root + '.cpp')
+
+return_code = subprocess.call(['bison', '-d', '-p', prefix, input_file,
+ '-o', output_cpp])
+assert return_code == 0
+
+# Find the name that bison used for the generated header file.
+output_h_tmp = None
+for output_h_try in output_h_tries:
+ try:
+ os.stat(output_h_try)
+ output_h_tmp = output_h_try
+ break
+ except OSError, e:
+ if e.errno != errno.ENOENT:
+ raise
+
+assert output_h_tmp != None
+
+# Read the header file in under the generated name and remove it.
+output_h_file = open(output_h_tmp)
+output_h_contents = output_h_file.read()
+output_h_file.close()
+os.unlink(output_h_tmp)
+
+# Rewrite the generated header with #include guards.
+output_h = os.path.join(output_dir, input_root + '.h')
+
+output_h_file = open(output_h, 'w')
+print >>output_h_file, '#ifndef %s_h' % input_root
+print >>output_h_file, '#define %s_h' % input_root
+print >>output_h_file, output_h_contents
+print >>output_h_file, '#endif'
+output_h_file.close()
diff --git a/webkit/build/rule_gperf.py b/webkit/build/rule_gperf.py
new file mode 100755
index 0000000..873eff8
--- /dev/null
+++ b/webkit/build/rule_gperf.py
@@ -0,0 +1,54 @@
+#!/usr/bin/python
+
+# Copyright (c) 2009 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.
+
+# usage: rule_gperf.py INPUT_FILE OUTPUT_DIR
+# INPUT_FILE is a path to DocTypeStrings.gperf, HTMLEntityNames.gperf, or
+# ColorData.gperf.
+# OUTPUT_DIR is where the gperf-generated .cpp file should be placed. Because
+# some users want a .c file instead of a .cpp file, the .cpp file is copied
+# to .c when done.
+
+import posixpath
+import shutil
+import subprocess
+import sys
+
+assert len(sys.argv) == 3
+
+input_file = sys.argv[1]
+output_dir = sys.argv[2]
+
+gperf_commands = {
+ 'DocTypeStrings.gperf': [
+ '-CEot', '-L', 'ANSI-C', '-k*', '-N', 'findDoctypeEntry',
+ '-F', ',PubIDInfo::eAlmostStandards,PubIDInfo::eAlmostStandards'
+ ],
+ 'HTMLEntityNames.gperf': [
+ '-a', '-L', 'ANSI-C', '-C', '-G', '-c', '-o', '-t', '-k*',
+ '-N', 'findEntity', '-D', '-s', '2'
+ ],
+ 'ColorData.gperf': [
+ '-CDEot', '-L', 'ANSI-C', '-k*', '-N', 'findColor', '-D', '-s', '2'
+ ],
+}
+
+input_name = posixpath.basename(input_file)
+assert input_name in gperf_commands
+
+(input_root, input_ext) = posixpath.splitext(input_name)
+output_cpp = posixpath.join(output_dir, input_root + '.cpp')
+
+command = ['gperf', '--output-file', output_cpp]
+command.extend(gperf_commands[input_name])
+command.append(input_file)
+
+# Do it. check_call is new in 2.5, so simulate its behavior with call and
+# assert.
+return_code = subprocess.call(command)
+assert return_code == 0
+
+output_c = posixpath.join(output_dir, input_root + '.c')
+shutil.copyfile(output_cpp, output_c)