summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/WebCore.gyp/scripts
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2011-05-06 11:45:16 +0100
committerSteve Block <steveblock@google.com>2011-05-12 13:44:10 +0100
commitcad810f21b803229eb11403f9209855525a25d57 (patch)
tree29a6fd0279be608e0fe9ffe9841f722f0f4e4269 /Source/WebCore/WebCore.gyp/scripts
parent121b0cf4517156d0ac5111caf9830c51b69bae8f (diff)
downloadexternal_webkit-cad810f21b803229eb11403f9209855525a25d57.zip
external_webkit-cad810f21b803229eb11403f9209855525a25d57.tar.gz
external_webkit-cad810f21b803229eb11403f9209855525a25d57.tar.bz2
Merge WebKit at r75315: Initial merge by git.
Change-Id: I570314b346ce101c935ed22a626b48c2af266b84
Diffstat (limited to 'Source/WebCore/WebCore.gyp/scripts')
-rw-r--r--Source/WebCore/WebCore.gyp/scripts/action_csspropertynames.py166
-rw-r--r--Source/WebCore/WebCore.gyp/scripts/action_cssvaluekeywords.py172
-rw-r--r--Source/WebCore/WebCore.gyp/scripts/action_derivedsourcesallinone.py203
-rw-r--r--Source/WebCore/WebCore.gyp/scripts/action_makenames.py174
-rw-r--r--Source/WebCore/WebCore.gyp/scripts/action_maketokenizer.py101
-rw-r--r--Source/WebCore/WebCore.gyp/scripts/action_useragentstylesheets.py102
-rw-r--r--Source/WebCore/WebCore.gyp/scripts/rule_binding.py136
-rw-r--r--Source/WebCore/WebCore.gyp/scripts/rule_bison.py102
8 files changed, 1156 insertions, 0 deletions
diff --git a/Source/WebCore/WebCore.gyp/scripts/action_csspropertynames.py b/Source/WebCore/WebCore.gyp/scripts/action_csspropertynames.py
new file mode 100644
index 0000000..60314d7
--- /dev/null
+++ b/Source/WebCore/WebCore.gyp/scripts/action_csspropertynames.py
@@ -0,0 +1,166 @@
+#!/usr/bin/python
+#
+# Copyright (C) 2009 Google Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# 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])
+
+ outputDir = os.path.dirname(outputs[0])
+
+ # Look at the inputs and figure out which one is makeprop.pl and which are
+ # inputs to that script.
+ makepropInput = None
+ inFiles = []
+ 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.
+ inputAbs = os.path.abspath(input)
+ inputAbsPosix = inputAbs.replace(os.path.sep, posixpath.sep)
+ inputBasename = os.path.basename(input)
+ if inputBasename == 'makeprop.pl':
+ assert makepropInput == None
+ makepropInput = inputAbs
+ elif inputBasename.endswith('.in'):
+ inFiles.append(inputAbsPosix)
+ else:
+ assert False
+
+ assert makepropInput != None
+ assert len(inFiles) >= 1
+
+ # Change to the output directory because makeprop.pl puts output in its
+ # working directory.
+ os.chdir(outputDir)
+
+ # Merge all inFiles into a single file whose name will be the same as the
+ # first listed inFile, but in the output directory.
+ mergedPath = os.path.basename(inFiles[0])
+ merged = open(mergedPath, 'wb') # 'wb' to get \n only on windows
+
+ # Make sure there aren't any duplicate lines in the in files.
+ lineDict = {}
+ for inFilePath in inFiles:
+ inFile = open(inFilePath)
+ for line in inFile:
+ line = line.rstrip()
+ if line.startswith('#'):
+ line = ''
+ if line == '':
+ continue
+ if line in lineDict:
+ raise KeyError, 'Duplicate value %s' % line
+ lineDict[line] = True
+ print >>merged, line
+ inFile.close()
+
+ merged.close()
+
+ # Build up the command.
+ command = ['perl', makepropInput]
+
+ # Do it. checkCall is new in 2.5, so simulate its behavior with call and
+ # assert.
+ returnCode = subprocess.call(command)
+ assert returnCode == 0
+
+ # Don't leave behind the merged file or the .gperf file created by
+ # makeprop.
+ (root, ext) = os.path.splitext(mergedPath)
+ gperfPath = root + '.gperf'
+ os.unlink(gperfPath)
+ os.unlink(mergedPath)
+
+ # 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:
+ thisOutputDir = os.path.dirname(output)
+ if thisOutputDir != outputDir:
+ outputBasename = os.path.basename(output)
+ src = os.path.join(outputDir, outputBasename)
+ dst = os.path.join(thisOutputDir, outputBasename)
+ shutil.copyfile(src, dst)
+ os.unlink(src)
+
+ return returnCode
+
+
+if __name__ == '__main__':
+ sys.exit(main(sys.argv))
diff --git a/Source/WebCore/WebCore.gyp/scripts/action_cssvaluekeywords.py b/Source/WebCore/WebCore.gyp/scripts/action_cssvaluekeywords.py
new file mode 100644
index 0000000..ebf895b
--- /dev/null
+++ b/Source/WebCore/WebCore.gyp/scripts/action_cssvaluekeywords.py
@@ -0,0 +1,172 @@
+#!/usr/bin/python
+#
+# Copyright (C) 2009 Google Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# 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])
+
+ outputDir = os.path.dirname(outputs[0])
+
+ # Look at the inputs and figure out which one is makevalues.pl and which are
+ # inputs to that script.
+ makevaluesInput = None
+ inFiles = []
+ 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.
+ inputAbs = os.path.abspath(input)
+ inputAbsPosix = inputAbs.replace(os.path.sep, posixpath.sep)
+ inputBasename = os.path.basename(input)
+ if inputBasename == 'makevalues.pl':
+ assert makevaluesInput == None
+ makevaluesInput = inputAbs
+ elif inputBasename.endswith('.in'):
+ inFiles.append(inputAbsPosix)
+ else:
+ assert False
+
+ assert makevaluesInput != None
+ assert len(inFiles) >= 1
+
+ # Change to the output directory because makevalues.pl puts output in its
+ # working directory.
+ os.chdir(outputDir)
+
+ # Merge all inFiles into a single file whose name will be the same as the
+ # first listed inFile, but in the output directory.
+ mergedPath = os.path.basename(inFiles[0])
+ merged = open(mergedPath, '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.
+ lineDict = {}
+ for inFilePath in inFiles:
+ inFile = open(inFilePath)
+ for line in inFile:
+ line = line.rstrip()
+ if line.startswith('#'):
+ line = ''
+ if line == '':
+ continue
+ line = line.lower()
+ if line in lineDict:
+ raise KeyError, 'Duplicate value %s' % line
+ lineDict[line] = True
+ print >>merged, line
+ inFile.close()
+
+ merged.close()
+
+ # Build up the command.
+ command = ['perl', makevaluesInput]
+
+ # Do it. checkCall is new in 2.5, so simulate its behavior with call and
+ # assert.
+ returnCode = subprocess.call(command)
+ assert returnCode == 0
+
+ # Don't leave behind the merged file or the .gperf file created by
+ # makevalues.
+ (root, ext) = os.path.splitext(mergedPath)
+ gperfPath = root + '.gperf'
+ os.unlink(gperfPath)
+ os.unlink(mergedPath)
+
+ # 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:
+ thisOutputDir = os.path.dirname(output)
+ if thisOutputDir != outputDir:
+ outputBasename = os.path.basename(output)
+ src = os.path.join(outputDir, outputBasename)
+ dst = os.path.join(thisOutputDir, outputBasename)
+ shutil.copyfile(src, dst)
+ os.unlink(src)
+
+ return returnCode
+
+
+if __name__ == '__main__':
+ sys.exit(main(sys.argv))
diff --git a/Source/WebCore/WebCore.gyp/scripts/action_derivedsourcesallinone.py b/Source/WebCore/WebCore.gyp/scripts/action_derivedsourcesallinone.py
new file mode 100644
index 0000000..c9c5bf5
--- /dev/null
+++ b/Source/WebCore/WebCore.gyp/scripts/action_derivedsourcesallinone.py
@@ -0,0 +1,203 @@
+#!/usr/bin/python
+#
+# Copyright (C) 2009 Google Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# 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_derivedsourceslist.py generates a single cpp file that includes
+# all v8 bindings cpp files generated from idls. Files can be assigned into
+# multiple output files, to reduce maximum compilation unit size and allow
+# parallel compilation.
+#
+# usage: action_derivedsourceslist.py IDL_FILES_LIST -- OUTPUT_FILE1 OUTPUT_FILE2 ...
+#
+# Note that IDL_FILES_LIST is a text file containing the IDL file paths.
+
+import errno
+import os
+import os.path
+import re
+import subprocess
+import sys
+
+# A regexp for finding Conditional attributes in interface definitions.
+conditionalPattern = re.compile('interface[\s]*\[[^\]]*Conditional=([\_0-9a-zA-Z&|]*)')
+
+copyrightTemplate = """/*
+ * THIS FILE WAS AUTOMATICALLY GENERATED, DO NOT EDIT.
+ *
+ * This file was generated by the make_jni_lists.py script.
+ *
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+"""
+
+
+# Wraps conditional with ENABLE() and replace '&','|' with '&&','||' if more than one conditional is specified.
+def formatConditional(conditional):
+ def wrapWithEnable(s):
+ if re.match('[|&]$', s):
+ return s * 2
+ return 'ENABLE(' + s + ')'
+ return ' '.join(map(wrapWithEnable, conditional))
+
+
+# Find the conditional interface attribute.
+def extractConditional(idlFilePath):
+ conditional = None
+
+ # Read file and look for "interface [ Conditional=XXX ]".
+ idlFile = open(idlFilePath)
+ idlContents = idlFile.read().replace('\n', '')
+ idlFile.close()
+
+ match = conditionalPattern.search(idlContents)
+ if match:
+ conditional = match.group(1)
+ conditional = re.split('([|&])', conditional)
+
+ return conditional
+
+# Extracts conditional and interface name from each IDL file.
+def extractMetaData(filePaths):
+ metaDataList = []
+
+ for f in filePaths:
+ metaData = {}
+ if len(f) == 0:
+ continue
+ if not os.path.exists(f):
+ print 'WARNING: file not found: "%s"' % f
+ continue
+
+ # Extract type name from file name
+ (parentPath, fileName) = os.path.split(f)
+ (interfaceName, ext) = os.path.splitext(fileName)
+
+ if not ext == '.idl':
+ continue
+
+ metaData = {
+ 'conditional': extractConditional(f),
+ 'name': interfaceName,
+ }
+
+ metaDataList.append(metaData)
+
+ return metaDataList
+
+
+def generateContent(filesMetaData, partition, totalPartitions):
+ # Sort files by conditionals.
+ filesMetaData.sort()
+
+ output = []
+
+ # Add fixed content.
+ output.append(copyrightTemplate)
+ output.append('#define NO_IMPLICIT_ATOMICSTRING\n\n')
+
+ # List all includes segmented by if and endif.
+ prevConditional = None
+ for metaData in filesMetaData:
+ name = metaData['name']
+ if (hash(name) % totalPartitions) != partition:
+ continue
+ conditional = metaData['conditional']
+
+ if prevConditional and prevConditional != conditional:
+ output.append('#endif\n')
+ if conditional and prevConditional != conditional:
+ output.append('\n#if %s\n' % formatConditional(conditional))
+
+ output.append('#include "bindings/V8%s.cpp"\n' % name)
+
+ prevConditional = conditional
+
+ if prevConditional:
+ output.append('#endif\n')
+
+ return ''.join(output)
+
+
+def writeContent(content, outputFileName):
+ (parentPath, fileName) = os.path.split(outputFileName)
+ if not os.path.exists(parentPath):
+ print parentPath
+ os.mkdir(parentPath)
+ f = open(outputFileName, 'w')
+ f.write(content)
+ f.close()
+
+
+def main(args):
+ assert(len(args) > 3)
+ inOutBreakIndex = args.index('--')
+ inputFileName = args[1]
+ outputFileNames = args[inOutBreakIndex+1:]
+
+ inputFile = open(inputFileName, 'r')
+ idlFileNames = inputFile.read().split('\n')
+ inputFile.close()
+
+ filesMetaData = extractMetaData(idlFileNames)
+ for fileName in outputFileNames:
+ print 'Generating derived sources list into %s...' % fileName
+ partition = outputFileNames.index(fileName)
+ fileContents = generateContent(filesMetaData, partition, len(outputFileNames))
+ writeContent(fileContents, fileName)
+
+ return 0
+
+
+if __name__ == '__main__':
+ sys.exit(main(sys.argv))
diff --git a/Source/WebCore/WebCore.gyp/scripts/action_makenames.py b/Source/WebCore/WebCore.gyp/scripts/action_makenames.py
new file mode 100644
index 0000000..ecf543f
--- /dev/null
+++ b/Source/WebCore/WebCore.gyp/scripts/action_makenames.py
@@ -0,0 +1,174 @@
+#!/usr/bin/python
+#
+# Copyright (C) 2009 Google Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# 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])
+
+ outputDir = 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.
+ makeNamesInput = None
+ tagInput = None
+ attrInput = 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.
+ inputAbs = os.path.abspath(input)
+ inputAbsPosix = inputAbs.replace(os.path.sep, posixpath.sep)
+ inputBasename = os.path.basename(input)
+ if inputBasename == 'make_names.pl':
+ assert makeNamesInput == None
+ makeNamesInput = inputAbs
+ elif inputBasename.endswith('TagNames.in') \
+ or inputBasename.endswith('tags.in'):
+ assert tagInput == None
+ tagInput = inputAbsPosix
+ elif inputBasename.endswith('AttributeNames.in') \
+ or inputBasename.endswith('attrs.in'):
+ assert attrInput == None
+ attrInput = inputAbsPosix
+ else:
+ assert False
+
+ assert makeNamesInput != None
+ assert tagInput != None or attrInput != None
+
+ # scriptsPath is a Perl include directory, located relative to
+ # makeNamesInput.
+ scriptsPath = os.path.normpath(
+ os.path.join(os.path.dirname(makeNamesInput), os.pardir, 'bindings', 'scripts'))
+
+ # Change to the output directory because make_names.pl puts output in its
+ # working directory.
+ os.chdir(outputDir)
+
+ # Build up the command.
+ command = ['perl', '-I', scriptsPath, makeNamesInput]
+ if tagInput != None:
+ command.extend(['--tags', tagInput])
+ if attrInput != None:
+ command.extend(['--attrs', attrInput])
+ command.extend(options)
+
+ # Do it. check_call is new in 2.5, so simulate its behavior with call and
+ # assert.
+ returnCode = subprocess.call(command)
+ assert returnCode == 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:
+ thisOutputDir = os.path.dirname(output)
+ if thisOutputDir != outputDir:
+ outputBasename = os.path.basename(output)
+ src = os.path.join(outputDir, outputBasename)
+ dst = os.path.join(thisOutputDir, outputBasename)
+ shutil.copyfile(src, dst)
+ os.unlink(src)
+
+ return returnCode
+
+
+if __name__ == '__main__':
+ sys.exit(main(sys.argv))
diff --git a/Source/WebCore/WebCore.gyp/scripts/action_maketokenizer.py b/Source/WebCore/WebCore.gyp/scripts/action_maketokenizer.py
new file mode 100644
index 0000000..f4a28ee
--- /dev/null
+++ b/Source/WebCore/WebCore.gyp/scripts/action_maketokenizer.py
@@ -0,0 +1,101 @@
+#!/usr/bin/python
+#
+# Copyright (C) 2009 Google Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# 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]
+ flexInput = inputs[1]
+
+ # Do it. check_call is new in 2.5, so simulate its behavior with call and
+ # assert.
+ outfile = open(output, 'wb')
+ p1 = subprocess.Popen(['flex', '-t', flexInput], stdout=subprocess.PIPE)
+ p2 = subprocess.Popen(['perl', maketokenizer], stdin=p1.stdout, stdout=outfile)
+
+ r1 = p1.wait()
+ r2 = p2.wait()
+ assert r1 == 0
+ assert r2 == 0
+
+ return 0
+
+
+if __name__ == '__main__':
+ sys.exit(main(sys.argv))
diff --git a/Source/WebCore/WebCore.gyp/scripts/action_useragentstylesheets.py b/Source/WebCore/WebCore.gyp/scripts/action_useragentstylesheets.py
new file mode 100644
index 0000000..6f017fc
--- /dev/null
+++ b/Source/WebCore/WebCore.gyp/scripts/action_useragentstylesheets.py
@@ -0,0 +1,102 @@
+#!/usr/bin/python
+#
+# Copyright (C) 2009 Google Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# 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
+ outputH = outputs[0]
+ outputCpp = outputs[1]
+
+ makeCssFileArrays = inputs[0]
+ styleSheets = inputs[1:]
+
+ # Build up the command.
+ command = ['perl', makeCssFileArrays, outputH, outputCpp]
+ command.extend(styleSheets)
+
+ # Do it. check_call is new in 2.5, so simulate its behavior with call and
+ # assert.
+ returnCode = subprocess.call(command)
+ assert returnCode == 0
+
+ return returnCode
+
+
+if __name__ == '__main__':
+ sys.exit(main(sys.argv))
diff --git a/Source/WebCore/WebCore.gyp/scripts/rule_binding.py b/Source/WebCore/WebCore.gyp/scripts/rule_binding.py
new file mode 100644
index 0000000..5a41808
--- /dev/null
+++ b/Source/WebCore/WebCore.gyp/scripts/rule_binding.py
@@ -0,0 +1,136 @@
+#!/usr/bin/python
+#
+# Copyright (C) 2009 Google Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# 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 shlex
+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, sections
+ (base, inputs, options) = sections
+
+ assert len(base) == 3, base
+ (input, cppdir, hdir) = base
+
+ assert len(inputs) > 1, inputs
+ generateBindings = inputs[0]
+ perlModules = inputs[1:]
+
+ includeDirs = []
+ for perlModule in perlModules:
+ includeDir = os.path.dirname(perlModule)
+ if not includeDir in includeDirs:
+ includeDirs.append(includeDir)
+
+ if '--prefix' in options:
+ prefixIndex = options.index('--prefix')
+ else:
+ prefixIndex = options.index('--generator')
+
+ fileName = ''
+ if '--filename' in options:
+ fileName = options[options.index('--filename') + 1]
+
+ if prefixIndex + 1 < len(options):
+ prefix = options[prefixIndex + 1]
+
+ # The defines come in as one flat string. Split it up into distinct arguments.
+ if '--defines' in options:
+ definesIndex = options.index('--defines')
+ if definesIndex + 1 < len(options):
+ splitOptions = shlex.split(options[definesIndex + 1])
+ if splitOptions:
+ options[definesIndex + 1] = ' '.join(splitOptions)
+
+ # Build up the command.
+ command = ['perl', '-w']
+ for includeDir in includeDirs:
+ command.extend(['-I', includeDir])
+ command.append(generateBindings)
+ command.extend(options)
+ command.extend(['--outputHeadersDir', hdir])
+ command.extend(['--outputDir', cppdir, input])
+
+ # Do it. check_call is new in 2.5, so simulate its behavior with call and
+ # assert.
+ returnCode = subprocess.call(command)
+ assert returnCode == 0
+
+ return returnCode
+
+
+if __name__ == '__main__':
+ sys.exit(main(sys.argv))
diff --git a/Source/WebCore/WebCore.gyp/scripts/rule_bison.py b/Source/WebCore/WebCore.gyp/scripts/rule_bison.py
new file mode 100644
index 0000000..eb85a4b
--- /dev/null
+++ b/Source/WebCore/WebCore.gyp/scripts/rule_bison.py
@@ -0,0 +1,102 @@
+#!/usr/bin/python
+#
+# Copyright (C) 2009 Google Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# 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
+
+inputFile = sys.argv[1]
+outputDir = sys.argv[2]
+
+inputName = os.path.basename(inputFile)
+assert inputName == 'CSSGrammar.y' or inputName == 'XPathGrammar.y'
+prefix = {'CSSGrammar.y': 'cssyy', 'XPathGrammar.y': 'xpathyy'}[inputName]
+
+(inputRoot, inputExt) = os.path.splitext(inputName)
+
+# The generated .h will be in a different location depending on the bison
+# version.
+outputHTries = [
+ os.path.join(outputDir, inputRoot + '.cpp.h'),
+ os.path.join(outputDir, inputRoot + '.hpp'),
+]
+
+for outputHTry in outputHTries:
+ try:
+ os.unlink(outputHTry)
+ except OSError, e:
+ if e.errno != errno.ENOENT:
+ raise
+
+outputCpp = os.path.join(outputDir, inputRoot + '.cpp')
+
+returnCode = subprocess.call(['bison', '-d', '-p', prefix, inputFile, '-o', outputCpp])
+assert returnCode == 0
+
+# Find the name that bison used for the generated header file.
+outputHTmp = None
+for outputHTry in outputHTries:
+ try:
+ os.stat(outputHTry)
+ outputHTmp = outputHTry
+ break
+ except OSError, e:
+ if e.errno != errno.ENOENT:
+ raise
+
+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.
+outputH = os.path.join(outputDir, inputRoot + '.h')
+
+outputHFile = open(outputH, 'w')
+print >>outputHFile, '#ifndef %sH' % inputRoot
+print >>outputHFile, '#define %sH' % inputRoot
+print >>outputHFile, outputHContents
+print >>outputHFile, '#endif'
+outputHFile.close()