OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # | 2 # |
3 # Copyright (C) 2009 Google Inc. All rights reserved. | 3 # Copyright (C) 2009 Google Inc. All rights reserved. |
4 # | 4 # |
5 # Redistribution and use in source and binary forms, with or without | 5 # Redistribution and use in source and binary forms, with or without |
6 # modification, are permitted provided that the following conditions are | 6 # modification, are permitted provided that the following conditions are |
7 # met: | 7 # met: |
8 # | 8 # |
9 # * Redistributions of source code must retain the above copyright | 9 # * Redistributions of source code must retain the above copyright |
10 # notice, this list of conditions and the following disclaimer. | 10 # notice, this list of conditions and the following disclaimer. |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 # following the final '--'. | 80 # following the final '--'. |
81 args = [] | 81 args = [] |
82 sections.append(args) | 82 sections.append(args) |
83 else: | 83 else: |
84 args = args[dashes + 1:] | 84 args = args[dashes + 1:] |
85 | 85 |
86 return sections | 86 return sections |
87 | 87 |
88 | 88 |
89 def main(args): | 89 def main(args): |
90 sections = SplitArgsIntoSections(args[1:]) | 90 if args[1] != "--idlToPathFile" or len(args) < 3: |
| 91 print "FATAL: Missing --idlToPathFile argument: " + str(args) |
| 92 return 1 |
| 93 idlToPathFile = args[2] |
| 94 sections = SplitArgsIntoSections(args[3:]) |
91 assert len(sections) == 2 or len(sections) == 3 | 95 assert len(sections) == 2 or len(sections) == 3 |
92 (outputs, inputs) = sections[:2] | 96 (outputs, inputs) = sections[:2] |
93 if len(sections) == 3: | 97 if len(sections) == 3: |
94 options = sections[2] | 98 options = sections[2] |
95 else: | 99 else: |
96 options = [] | 100 options = [] |
97 | 101 |
98 # Make all output pathnames absolute so that they can be accessed after | 102 # Make all output pathnames absolute so that they can be accessed after |
99 # changing directory. | 103 # changing directory. |
100 for index in xrange(0, len(outputs)): | 104 for index in xrange(0, len(outputs)): |
(...skipping 23 matching lines...) Expand all Loading... |
124 assert tagInput == None | 128 assert tagInput == None |
125 tagInput = inputAbsPosix | 129 tagInput = inputAbsPosix |
126 elif inputBasename.endswith('AttributeNames.in') or inputBasename.endswi
th('attrs.in'): | 130 elif inputBasename.endswith('AttributeNames.in') or inputBasename.endswi
th('attrs.in'): |
127 assert attrInput == None | 131 assert attrInput == None |
128 attrInput = inputAbsPosix | 132 attrInput = inputAbsPosix |
129 elif (inputBasename.endswith('EventTargetFactory.in') or inputBasename.e
ndswith('EventNames.in') | 133 elif (inputBasename.endswith('EventTargetFactory.in') or inputBasename.e
ndswith('EventNames.in') |
130 or inputBasename.endswith('DOMExceptions.in') or inputBasename.endsw
ith('Settings.in')): | 134 or inputBasename.endswith('DOMExceptions.in') or inputBasename.endsw
ith('Settings.in')): |
131 eventsInput = inputAbsPosix | 135 eventsInput = inputAbsPosix |
132 elif inputBasename.endswith('Names.in'): | 136 elif inputBasename.endswith('Names.in'): |
133 options.append(inputAbsPosix) | 137 options.append(inputAbsPosix) |
134 elif inputBasename.endswith('.pm'): | 138 elif inputBasename.endswith('.pm') or inputBasename.endswith('.py'): |
135 continue | 139 continue |
136 else: | 140 else: |
137 assert False | 141 assert False, "Unexcepted file type "+ inputeBasename |
138 | 142 |
139 assert makeNamesInput != None | 143 assert makeNamesInput != None |
140 assert tagInput != None or attrInput != None or eventsInput != None or ('--f
onts' in options) | 144 assert tagInput != None or attrInput != None or eventsInput != None or ('--f
onts' in options) |
141 | 145 |
142 # scriptsPath is a Perl include directory, located relative to | 146 # scriptsPath is a Perl include directory, located relative to |
143 # makeNamesInput. | 147 # makeNamesInput. |
144 scriptsPath = os.path.normpath( | 148 scriptsPath = os.path.normpath( |
145 os.path.join(os.path.dirname(makeNamesInput), os.pardir, 'scripts')) | 149 os.path.join(os.path.dirname(makeNamesInput), os.pardir, 'scripts')) |
146 | 150 |
| 151 # bindingsScriptPath is a Perl include directory for some helper libraries m
ake_names.pl uses. |
| 152 bindingsScriptPath = os.path.normpath( |
| 153 os.path.join(os.path.dirname(makeNamesInput), os.pardir, os.pardir, 'bin
dings', 'scripts')) |
| 154 |
147 # Change to the output directory because make_names.pl puts output in its | 155 # Change to the output directory because make_names.pl puts output in its |
148 # working directory. | 156 # working directory. |
149 os.chdir(outputDir) | 157 os.chdir(outputDir) |
150 | 158 |
151 # Build up the command. | 159 # Build up the command. |
152 command = ['perl', '-I', scriptsPath, makeNamesInput] | 160 command = ['perl', '-I', scriptsPath, '-I', bindingsScriptPath, makeNamesInp
ut] |
153 if tagInput != None: | 161 if tagInput != None: |
154 command.extend(['--tags', tagInput]) | 162 command.extend(['--tags', tagInput]) |
155 if attrInput != None: | 163 if attrInput != None: |
156 command.extend(['--attrs', attrInput]) | 164 command.extend(['--attrs', attrInput]) |
157 if eventsInput != None: | 165 if eventsInput != None: |
158 command.extend(['--input', eventsInput]) | 166 command.extend(['--input', eventsInput]) |
| 167 command.extend(['--idltopathfile', idlToPathFile]) |
159 command.extend(options) | 168 command.extend(options) |
160 | 169 |
161 # Do it. check_call is new in 2.5, so simulate its behavior with call and | 170 # Do it. check_call is new in 2.5, so simulate its behavior with call and |
162 # assert. | 171 # assert. |
163 returnCode = subprocess.call(command) | 172 returnCode = subprocess.call(command) |
164 assert returnCode == 0 | 173 assert returnCode == 0 |
165 | 174 |
166 # Go through the outputs. Any output that belongs in a different directory | 175 # Go through the outputs. Any output that belongs in a different directory |
167 # is moved. Do a copy and delete instead of rename for maximum portability. | 176 # is moved. Do a copy and delete instead of rename for maximum portability. |
168 # Note that all paths used in this section are still absolute. | 177 # Note that all paths used in this section are still absolute. |
169 for output in outputs: | 178 for output in outputs: |
170 thisOutputDir = os.path.dirname(output) | 179 thisOutputDir = os.path.dirname(output) |
171 if thisOutputDir != outputDir: | 180 if thisOutputDir != outputDir: |
172 outputBasename = os.path.basename(output) | 181 outputBasename = os.path.basename(output) |
173 src = os.path.join(outputDir, outputBasename) | 182 src = os.path.join(outputDir, outputBasename) |
174 dst = os.path.join(thisOutputDir, outputBasename) | 183 dst = os.path.join(thisOutputDir, outputBasename) |
175 shutil.copyfile(src, dst) | 184 shutil.copyfile(src, dst) |
176 os.unlink(src) | 185 os.unlink(src) |
177 | 186 |
178 return returnCode | 187 return returnCode |
179 | 188 |
180 | 189 |
181 if __name__ == '__main__': | 190 if __name__ == '__main__': |
182 sys.exit(main(sys.argv)) | 191 sys.exit(main(sys.argv)) |
OLD | NEW |