OLD | NEW |
1 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
2 # for details. All rights reserved. Use of this source code is governed by a | 2 # for details. All rights reserved. Use of this source code is governed by a |
3 # BSD-style license that can be found in the LICENSE file. | 3 # BSD-style license that can be found in the LICENSE file. |
4 # | 4 # |
5 | 5 |
6 import os | 6 import os |
7 import platform | 7 import platform |
8 import re | 8 import re |
9 import shutil | 9 import shutil |
10 import subprocess | 10 import subprocess |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 """Returns the name of the output .js file to create.""" | 339 """Returns the name of the output .js file to create.""" |
340 path = self.GetTestScriptFile() | 340 path = self.GetTestScriptFile() |
341 return os.path.abspath(os.path.join(self.temp_dir, | 341 return os.path.abspath(os.path.join(self.temp_dir, |
342 os.path.basename(path) + '.js')) | 342 os.path.basename(path) + '.js')) |
343 | 343 |
344 def GetHtmlName(self): | 344 def GetHtmlName(self): |
345 """Returns the name of the output .html file to create.""" | 345 """Returns the name of the output .html file to create.""" |
346 relpath = os.path.relpath(self.test, self.root_path) | 346 relpath = os.path.relpath(self.test, self.root_path) |
347 return relpath.replace(os.sep, '_') + '.html' | 347 return relpath.replace(os.sep, '_') + '.html' |
348 | 348 |
| 349 def Compile(self): |
| 350 return ExecuteCommand(self.GetCompileCommand()) |
| 351 |
| 352 class DartcChromiumArchitecture(ChromiumArchitecture): |
| 353 """ChromiumArchitecture that compiles code using dartc.""" |
| 354 |
| 355 def __init__(self, root_path, arch, mode, component, test): |
| 356 super(DartcChromiumArchitecture, self).__init__( |
| 357 root_path, arch, mode, component, test) |
| 358 |
349 def GetCompileCommand(self, fatal_static_type_errors=False): | 359 def GetCompileCommand(self, fatal_static_type_errors=False): |
350 """Returns cmdline as an array to invoke the compiler on this test.""" | 360 """Returns cmdline as an array to invoke the compiler on this test.""" |
351 | 361 |
352 # We need an absolute path because the compilation will run | 362 # We need an absolute path because the compilation will run |
353 # in a temporary directory. | 363 # in a temporary directory. |
354 build_root = utils.GetBuildRoot(OS_GUESS, self.mode, 'ia32') | 364 build_root = utils.GetBuildRoot(OS_GUESS, self.mode, 'ia32') |
355 dartc = os.path.abspath(os.path.join(build_root, 'compiler', 'bin', | 365 dartc = os.path.abspath(os.path.join(build_root, 'compiler', 'bin', |
356 'dartc')) | 366 'dartc')) |
357 if utils.IsWindows(): dartc += '.exe' | 367 if utils.IsWindows(): dartc += '.exe' |
358 cmd = [dartc, '--work', self.temp_dir] | 368 cmd = [dartc, '--work', self.temp_dir] |
359 if self.mode == 'release': | 369 if self.mode == 'release': |
360 cmd += ['--optimize'] | 370 cmd += ['--optimize'] |
361 cmd += self.vm_options | 371 cmd += self.vm_options |
362 cmd += ['--out', self.GetScriptPath()] | 372 cmd += ['--out', self.GetScriptPath()] |
363 if fatal_static_type_errors: | 373 if fatal_static_type_errors: |
364 # TODO(zundel): update to --fatal_type_errors for both VM and Compiler | 374 # TODO(zundel): update to --fatal_type_errors for both VM and Compiler |
365 cmd.append('-fatal-type-errors') | 375 cmd.append('-fatal-type-errors') |
366 cmd.append(self.GetTestScriptFile()) | 376 cmd.append(self.GetTestScriptFile()) |
367 return cmd | 377 return cmd |
368 | 378 |
369 def Compile(self): | 379 |
370 return ExecuteCommand(self.GetCompileCommand()) | 380 class FrogChromiumArchitecture(ChromiumArchitecture): |
| 381 """ChromiumArchitecture that compiles code using frog.""" |
| 382 |
| 383 def __init__(self, root_path, arch, mode, component, test): |
| 384 super(FrogChromiumArchitecture, self).__init__( |
| 385 root_path, arch, mode, component, test) |
| 386 |
| 387 def GetCompileCommand(self, fatal_static_type_errors=False): |
| 388 """Returns cmdline as an array to invoke the compiler on this test.""" |
| 389 |
| 390 # We need an absolute path because the compilation will run |
| 391 # in a temporary directory. |
| 392 |
| 393 frog = os.path.abspath(utils.GetDartRunner(self.mode, self.arch, 'frogsh')) |
| 394 cmd = [frog, '--out=' + self.GetScriptPath(), '--compile-only', |
| 395 '--libdir=' + os.path.abspath( |
| 396 os.path.join(self.root_path, 'frog', 'lib'))] |
| 397 cmd.extend(self.vm_options) |
| 398 cmd.append(self.GetTestScriptFile()) |
| 399 return cmd |
371 | 400 |
372 | 401 |
373 class DartiumArchitecture(BrowserArchitecture): | 402 class DartiumArchitecture(BrowserArchitecture): |
374 """Architecture that runs dart in an VM embedded in DumpRenderTree.""" | 403 """Architecture that runs dart in an VM embedded in DumpRenderTree.""" |
375 | 404 |
376 def __init__(self, root_path, arch, mode, component, test): | 405 def __init__(self, root_path, arch, mode, component, test): |
377 super(DartiumArchitecture, self).__init__(root_path, arch, mode, component,
test) | 406 super(DartiumArchitecture, self).__init__(root_path, arch, mode, component,
test) |
378 | 407 |
379 def GetScriptType(self): | 408 def GetScriptType(self): |
380 return 'application/dart' | 409 return 'application/dart' |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 | 514 |
486 def ExecuteCommand(cmd, verbose=False): | 515 def ExecuteCommand(cmd, verbose=False): |
487 """Execute a command in a subprocess.""" | 516 """Execute a command in a subprocess.""" |
488 if verbose: print 'Executing: ' + ' '.join(cmd) | 517 if verbose: print 'Executing: ' + ' '.join(cmd) |
489 return subprocess.call(cmd) | 518 return subprocess.call(cmd) |
490 | 519 |
491 | 520 |
492 def GetArchitecture(arch, mode, component, test): | 521 def GetArchitecture(arch, mode, component, test): |
493 root_path = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), '..')) | 522 root_path = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), '..')) |
494 if component == 'chromium': | 523 if component == 'chromium': |
495 return ChromiumArchitecture(root_path, arch, mode, component, test) | 524 return DartcChromiumArchitecture(root_path, arch, mode, component, test) |
496 | 525 |
497 elif component == 'dartium': | 526 elif component == 'dartium': |
498 return DartiumArchitecture(root_path, arch, mode, component, test) | 527 return DartiumArchitecture(root_path, arch, mode, component, test) |
499 | 528 |
| 529 elif component == 'frogium': |
| 530 return FrogChromiumArchitecture(root_path, arch, mode, component, test) |
| 531 |
500 elif component in ['vm', 'frog', 'frogsh']: | 532 elif component in ['vm', 'frog', 'frogsh']: |
501 return StandaloneArchitecture(root_path, arch, mode, component, test) | 533 return StandaloneArchitecture(root_path, arch, mode, component, test) |
502 | 534 |
503 elif component == 'leg': | 535 elif component == 'leg': |
504 return LegArchitecture(root_path, arch, mode, component, test) | 536 return LegArchitecture(root_path, arch, mode, component, test) |
505 | 537 |
506 elif component == 'dartc': | 538 elif component == 'dartc': |
507 return DartcArchitecture(root_path, arch, mode, component, test) | 539 return DartcArchitecture(root_path, arch, mode, component, test) |
OLD | NEW |