OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/python |
| 2 # |
| 3 # Copyright (C) 2011 Google Inc. All rights reserved. |
| 4 # |
| 5 # Redistribution and use in source and binary forms, with or without |
| 6 # modification, are permitted provided that the following conditions are |
| 7 # met: |
| 8 # |
| 9 # * Redistributions of source code must retain the above copyright |
| 10 # notice, this list of conditions and the following disclaimer. |
| 11 # * Redistributions in binary form must reproduce the above |
| 12 # copyright notice, this list of conditions and the following disclaimer |
| 13 # in the documentation and/or other materials provided with the |
| 14 # distribution. |
| 15 # * Neither the name of Google Inc. nor the names of its |
| 16 # contributors may be used to endorse or promote products derived from |
| 17 # this software without specific prior written permission. |
| 18 # |
| 19 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 20 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 21 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 22 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 23 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 24 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 25 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 26 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 27 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 28 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 29 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 30 # |
| 31 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 32 # Use of this source code is governed by a BSD-style license that can be |
| 33 # found in the LICENSE file. |
| 34 |
| 35 # dart_action_derivedsourceslist.py generates a single or several cpp files |
| 36 # that include all Dart bindings cpp files generated from idls. |
| 37 # |
| 38 # usage: dart_action_derivedsourceslist.py IDL_FILES_LIST -- OUTPUT_FILE1 OUTPUT
_FILE2 ... |
| 39 # |
| 40 # Note that IDL_FILES_LIST is a text file containing the IDL file paths. |
| 41 |
| 42 import os.path |
| 43 import re |
| 44 import sys |
| 45 |
| 46 v8scriptPath = os.path.join(sys.path[0], '../../../../WebCore.gyp/scripts') |
| 47 sys.path.append(v8scriptPath) |
| 48 |
| 49 # FIXME: there are couple of very ugly hacks like duplication of main code and |
| 50 # regexp to rewrite V8 prefix to Dart. It all can be easily solved with minimal |
| 51 # modifications to action_derivedsourcesallinone.py. |
| 52 import action_derivedsourcesallinone as base |
| 53 |
| 54 |
| 55 def main(args): |
| 56 assert(len(args) > 3) |
| 57 inOutBreakIndex = args.index('--') |
| 58 inputFileName = args[1] |
| 59 outputFileNames = args[inOutBreakIndex + 1:] |
| 60 |
| 61 inputFile = open(inputFileName, 'r') |
| 62 idlFileNames = inputFile.read().split('\n') |
| 63 inputFile.close() |
| 64 |
| 65 filesMetaData = base.extractMetaData(idlFileNames) |
| 66 for fileName in outputFileNames: |
| 67 partition = outputFileNames.index(fileName) |
| 68 fileContents = base.generateContent(filesMetaData, partition, len(output
FileNames)) |
| 69 # FIXME: ugly hack---change V8 prefix to Dart. |
| 70 fileContents = re.sub('\n#include "bindings/V8', '\n#include "bindings/D
art', fileContents) |
| 71 base.writeContent(fileContents, fileName) |
| 72 |
| 73 return 0 |
| 74 |
| 75 |
| 76 if __name__ == '__main__': |
| 77 sys.exit(main(sys.argv)) |
OLD | NEW |