diff options
Diffstat (limited to 'WebCore/WebCore.gyp/scripts')
-rw-r--r-- | WebCore/WebCore.gyp/scripts/action_csspropertynames.py | 166 | ||||
-rw-r--r-- | WebCore/WebCore.gyp/scripts/action_cssvaluekeywords.py | 172 | ||||
-rw-r--r-- | WebCore/WebCore.gyp/scripts/action_makenames.py | 174 | ||||
-rw-r--r-- | WebCore/WebCore.gyp/scripts/action_maketokenizer.py | 101 | ||||
-rw-r--r-- | WebCore/WebCore.gyp/scripts/action_useragentstylesheets.py | 102 | ||||
-rw-r--r-- | WebCore/WebCore.gyp/scripts/rule_binding.py | 135 | ||||
-rw-r--r-- | WebCore/WebCore.gyp/scripts/rule_bison.py | 102 | ||||
-rw-r--r-- | WebCore/WebCore.gyp/scripts/rule_gperf.py | 85 |
8 files changed, 1037 insertions, 0 deletions
diff --git a/WebCore/WebCore.gyp/scripts/action_csspropertynames.py b/WebCore/WebCore.gyp/scripts/action_csspropertynames.py new file mode 100644 index 0000000..60314d7 --- /dev/null +++ b/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/WebCore/WebCore.gyp/scripts/action_cssvaluekeywords.py b/WebCore/WebCore.gyp/scripts/action_cssvaluekeywords.py new file mode 100644 index 0000000..ebf895b --- /dev/null +++ b/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/WebCore/WebCore.gyp/scripts/action_makenames.py b/WebCore/WebCore.gyp/scripts/action_makenames.py new file mode 100644 index 0000000..ecf543f --- /dev/null +++ b/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/WebCore/WebCore.gyp/scripts/action_maketokenizer.py b/WebCore/WebCore.gyp/scripts/action_maketokenizer.py new file mode 100644 index 0000000..f4a28ee --- /dev/null +++ b/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/WebCore/WebCore.gyp/scripts/action_useragentstylesheets.py b/WebCore/WebCore.gyp/scripts/action_useragentstylesheets.py new file mode 100644 index 0000000..6f017fc --- /dev/null +++ b/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/WebCore/WebCore.gyp/scripts/rule_binding.py b/WebCore/WebCore.gyp/scripts/rule_binding.py new file mode 100644 index 0000000..24d178f --- /dev/null +++ b/WebCore/WebCore.gyp/scripts/rule_binding.py @@ -0,0 +1,135 @@ +#!/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) + + # 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(['--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 + + # 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: + inputBasename = os.path.basename(input) + (root, ext) = os.path.splitext(inputBasename) + 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 returnCode + + +if __name__ == '__main__': + sys.exit(main(sys.argv)) diff --git a/WebCore/WebCore.gyp/scripts/rule_bison.py b/WebCore/WebCore.gyp/scripts/rule_bison.py new file mode 100644 index 0000000..eb85a4b --- /dev/null +++ b/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() diff --git a/WebCore/WebCore.gyp/scripts/rule_gperf.py b/WebCore/WebCore.gyp/scripts/rule_gperf.py new file mode 100644 index 0000000..e76ed6f --- /dev/null +++ b/WebCore/WebCore.gyp/scripts/rule_gperf.py @@ -0,0 +1,85 @@ +#!/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_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 + +inputFile = sys.argv[1] +outputDir = sys.argv[2] + +gperfCommands = { + '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' + ], +} + +inputName = posixpath.basename(inputFile) +assert inputName in gperfCommands + +(inputRoot, inputExt) = posixpath.splitext(inputName) +outputCpp = posixpath.join(outputDir, inputRoot + '.cpp') + +#command = ['gperf', '--output-file', outputCpp] +command = ['gperf'] +command.extend(gperfCommands[inputName]) +command.append(inputFile) + +ofile = open(outputCpp, 'w') + +# Do it. check_call is new in 2.5, so simulate its behavior with call and +# assert. +returnCode = subprocess.call(command, stdout=ofile.fileno()) +assert returnCode == 0 + +outputC = posixpath.join(outputDir, inputRoot + '.c') +shutil.copyfile(outputCpp, outputC) |