Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(166)

Side by Side Diff: tools/testing/frogpad/frogpad.py

Issue 9677020: fix directory ambiguity problem in frogpad (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/testing/frogpad/frogpad.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 2
3 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 3 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
4 # for details. All rights reserved. Use of this source code is governed by a 4 # for details. All rights reserved. Use of this source code is governed by a
5 # BSD-style license that can be found in the LICENSE file. 5 # BSD-style license that can be found in the LICENSE file.
6 # 6 #
7 7
8 """ 8 """
9 Frogpad is used to compile .dart files to javascript. 9 Frogpad is used to compile .dart files to javascript.
10 10
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 112
113 # Regex that finds #import, #source and #native directives in .dart files. 113 # Regex that finds #import, #source and #native directives in .dart files.
114 # match.group(1) = "import", "source" or "native" 114 # match.group(1) = "import", "source" or "native"
115 # match.group(2) = url of file being imported 115 # match.group(2) = url of file being imported
116 DIRECTIVE_RE = re.compile(r"^#(import|source|native)\([\"']([^\"']*)[\"']") 116 DIRECTIVE_RE = re.compile(r"^#(import|source|native)\([\"']([^\"']*)[\"']")
117 117
118 # id of script tag that holds name of the top dart file to be compiled, 118 # id of script tag that holds name of the top dart file to be compiled,
119 # (This file name passed will be passed to the frog compiler by frogpad.dart.) 119 # (This file name passed will be passed to the frog compiler by frogpad.dart.)
120 MAIN_ID = "main_id" 120 MAIN_ID = "main_id"
121 121
122 # id of the script tag that holds the name of the frog directory
123 FROGDIR_ID = "frogdir_id"
124
122 DART_LIBRARIES = { 125 DART_LIBRARIES = {
123 "core": "lib/corelib.dart", 126 "core": "lib/corelib.dart",
124 "coreimpl": "lib/corelib_impl.dart", 127 "coreimpl": "lib/corelib_impl.dart",
125 "dom": "../client/dom/frog/dom_frog.dart", 128 "dom": "../client/dom/frog/dom_frog.dart",
126 "html": "../client/html/frog/html_frog.dart", 129 "html": "../client/html/frog/html_frog.dart",
127 "isolate": "../lib/isolate/isolate_frog.dart", 130 "isolate": "../lib/isolate/isolate_frog.dart",
128 "json": "../lib/json/json_frog.dart" 131 "json": "../lib/json/json_frog.dart"
129 } 132 }
130 133
131 class Pad(object): 134 class Pad(object):
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 219
217 match = COMPILATION_ERROR_REGEX.match(js) 220 match = COMPILATION_ERROR_REGEX.match(js)
218 if match: 221 if match:
219 sys.exit(1) 222 sys.exit(1)
220 223
221 def generate_html(self): 224 def generate_html(self):
222 tags = [] 225 tags = []
223 for f in self.id_to_file.values(): 226 for f in self.id_to_file.values():
224 tags.append(self._create_tag(f.id, f.contents)) 227 tags.append(self._create_tag(f.id, f.contents))
225 tags.append(self._create_tag(MAIN_ID, self.main_file)) 228 tags.append(self._create_tag(MAIN_ID, self.main_file))
229 tags.append(self._create_tag(FROGDIR_ID, self.frog_dir))
226 html = HTML.replace("{{script_tags}}", "".join(tags)) 230 html = HTML.replace("{{script_tags}}", "".join(tags))
227 html = html.replace("{{FROGPAD_JS}}", read_file(self.frogpad_js)) 231 html = html.replace("{{FROGPAD_JS}}", read_file(self.frogpad_js))
228 return html 232 return html
229 233
230 def generate_js(self): 234 def generate_js(self):
231 drt = os.path.join(self.dart_dir, "client/tests/drt/DumpRenderTree") 235 drt = os.path.join(self.dart_dir, "client/tests/drt/DumpRenderTree")
232 if platform.system() == 'Darwin': 236 if platform.system() == 'Darwin':
233 drt += ".app" 237 drt += ".app"
234 elif platform.system() == 'Windows': 238 elif platform.system() == 'Windows':
235 raise Exception("frogpad does not run on Windows") 239 raise Exception("frogpad does not run on Windows")
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 self.id = self._make_id() 285 self.id = self._make_id()
282 check_exists(name) 286 check_exists(name)
283 with open(self.name, "r") as f: 287 with open(self.name, "r") as f:
284 self.contents = f.read() 288 self.contents = f.read()
285 289
286 def _make_id(self): 290 def _make_id(self):
287 """ 291 """
288 Generates an id (based on the file name) for the <script> tag that will 292 Generates an id (based on the file name) for the <script> tag that will
289 hold the contents of this file. 293 hold the contents of this file.
290 """ 294 """
291 (dirname, name) = os.path.split(self.name) 295 return self.name.replace("/", "_").replace(".", "_")
292 dirname = os.path.basename(dirname)
293 name = name.replace(".", "_")
294 return dirname + "_" + name
295 296
296 def directives(self): 297 def directives(self):
297 """Load files referenced by #source, #import and #native directives.""" 298 """Load files referenced by #source, #import and #native directives."""
298 lines = self.contents.split("\n") 299 lines = self.contents.split("\n")
299 self.line_number = 0 300 self.line_number = 0
300 for line in lines: 301 for line in lines:
301 self.line_number += 1 302 self.line_number += 1
302 self._directive(line) 303 self._directive(line)
303 304
304 def _directive(self, line): 305 def _directive(self, line):
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 raise CommandFailedException(msg) 361 raise CommandFailedException(msg)
361 logging.debug("SUCCEEDED (%d bytes)" % len(stdout)) 362 logging.debug("SUCCEEDED (%d bytes)" % len(stdout))
362 return stdout 363 return stdout
363 364
364 365
365 def main(argv): 366 def main(argv):
366 Pad(argv) 367 Pad(argv)
367 368
368 if __name__ == "__main__": 369 if __name__ == "__main__":
369 sys.exit(main(sys.argv)) 370 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « tools/testing/frogpad/frogpad.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698