OLD | NEW |
---|---|
1 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 # Copyright (c) 2012, 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 # This file contains a set of utilities functions used by other Python-based | 5 # This file contains a set of utilities functions used by other Python-based |
6 # scripts. | 6 # scripts. |
7 | 7 |
8 import commands | 8 import commands |
9 import datetime | 9 import datetime |
10 import json | 10 import json |
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
558 print 'Executing: ' + ' '.join(cmd) | 558 print 'Executing: ' + ' '.join(cmd) |
559 pipe = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, | 559 pipe = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, |
560 shell=IsWindows()) | 560 shell=IsWindows()) |
561 output = pipe.communicate() | 561 output = pipe.communicate() |
562 if pipe.returncode != 0: | 562 if pipe.returncode != 0: |
563 raise Exception('Execution failed: ' + str(output)) | 563 raise Exception('Execution failed: ' + str(output)) |
564 return pipe.returncode, output | 564 return pipe.returncode, output |
565 | 565 |
566 | 566 |
567 def DartBinary(): | 567 def DartBinary(): |
568 # TODO(24311): Replace all uses of this with CheckedInSdk[Fix]Executable(). | |
568 tools_dir = os.path.dirname(os.path.realpath(__file__)) | 569 tools_dir = os.path.dirname(os.path.realpath(__file__)) |
569 dart_binary_prefix = os.path.join(tools_dir, 'testing', 'bin') | 570 dart_binary_prefix = os.path.join(tools_dir, 'testing', 'bin') |
570 if IsWindows(): | 571 if IsWindows(): |
571 return os.path.join(dart_binary_prefix, 'windows', 'dart.exe') | 572 return os.path.join(dart_binary_prefix, 'windows', 'dart.exe') |
572 else: | 573 else: |
573 arch = GuessArchitecture() | 574 arch = GuessArchitecture() |
574 system = GuessOS() | 575 system = GuessOS() |
575 if arch == 'armv5te': | 576 if arch == 'armv5te': |
576 # TODO(zra): This binary does not exist, yet. Check one in once we have | 577 # TODO(zra): This binary does not exist, yet. Check one in once we have |
577 # sufficient stability. | 578 # sufficient stability. |
578 return os.path.join(dart_binary_prefix, system, 'dart-armv5te') | 579 return os.path.join(dart_binary_prefix, system, 'dart-armv5te') |
579 elif arch == 'arm': | 580 elif arch == 'arm': |
580 return os.path.join(dart_binary_prefix, system, 'dart-arm') | 581 return os.path.join(dart_binary_prefix, system, 'dart-arm') |
581 elif arch == 'arm64': | 582 elif arch == 'arm64': |
582 return os.path.join(dart_binary_prefix, system, 'dart-arm64') | 583 return os.path.join(dart_binary_prefix, system, 'dart-arm64') |
583 elif arch == 'mips': | 584 elif arch == 'mips': |
584 return os.path.join(dart_binary_prefix, system, 'dart-mips') | 585 return os.path.join(dart_binary_prefix, system, 'dart-mips') |
585 else: | 586 else: |
586 return os.path.join(dart_binary_prefix, system, 'dart') | 587 return os.path.join(dart_binary_prefix, system, 'dart') |
587 | 588 |
588 | 589 |
589 def DartSdkBinary(): | 590 def DartSdkBinary(): |
590 tools_dir = os.path.dirname(os.path.realpath(__file__)) | 591 tools_dir = os.path.dirname(os.path.realpath(__file__)) |
591 dart_binary_prefix = os.path.join(tools_dir, '..', 'sdk' , 'bin') | 592 dart_binary_prefix = os.path.join(tools_dir, '..', 'sdk' , 'bin') |
592 return os.path.join(dart_binary_prefix, 'dart') | 593 return os.path.join(dart_binary_prefix, 'dart') |
593 | 594 |
594 | 595 |
596 # The checked-in SDKs are documented at | |
597 # https://github.com/dart-lang/sdk/wiki/The-checked-in-SDK-in--tools | |
Ivan Posva
2015/09/15 17:01:42
ditto: --
Bill Hesse
2015/09/15 17:09:02
This is the URL of the page. I tracked it down, a
| |
595 def CheckedInSdkPath(): | 598 def CheckedInSdkPath(): |
596 # We don't use the normal macos, linux, win32 directory names here, instead, | 599 # We don't use the normal macos, linux, win32 directory names here, instead, |
597 # we use the names that the download_from_google_storage script uses. | 600 # we use the names that the download_from_google_storage script uses. |
598 osdict = {'Darwin':'mac', 'Linux':'linux', 'Windows':'win'} | 601 osdict = {'Darwin':'mac', 'Linux':'linux', 'Windows':'win'} |
599 system = platform.system() | 602 system = platform.system() |
600 try: | 603 try: |
601 osname = osdict[system] | 604 osname = osdict[system] |
602 except KeyError: | 605 except KeyError: |
603 print >>sys.stderr, ('WARNING: platform "%s" not supported') % (system) | 606 print >>sys.stderr, ('WARNING: platform "%s" not supported') % (system) |
604 return None; | 607 return None; |
605 tools_dir = os.path.dirname(os.path.realpath(__file__)) | 608 tools_dir = os.path.dirname(os.path.realpath(__file__)) |
606 return os.path.join(tools_dir, | 609 return os.path.join(tools_dir, |
607 'sdks', | 610 'sdks', |
608 osname, | 611 osname, |
609 'dart-sdk') | 612 'dart-sdk') |
610 | 613 |
611 | 614 |
615 def CheckedInSdkExecutable(): | |
616 return os.path.join(CheckedInSdkPath(), | |
617 'bin', | |
618 'dart.exe' if IsWindows() else 'dart') | |
619 | |
620 | |
621 def CheckedInSdkFixExecutable(): | |
Ivan Posva
2015/09/15 17:01:42
The documentation talks about a CheckedInSdkFixedE
Bill Hesse
2015/09/15 17:09:02
I like Fix, because it is an active verb, and this
Bill Hesse
2015/09/21 10:05:06
Changed to CheckedInSdkCheckExecutable, since it n
| |
622 executable = CheckedInSdkExecutable() | |
623 canary_script = os.path.join(os.path.dirname(os.path.realpath(__file__)), | |
624 'canary.dart') | |
625 try: | |
626 if 42 == subprocess.call([executable, canary_script]): | |
627 return True | |
628 except OSError as e: | |
629 pass | |
630 arch = GuessArchitecture() | |
631 system = GuessOS() | |
632 if system == 'linux' and (arch == 'mips' or arch == 'arm'): | |
633 try: | |
634 shutil.copy(os.path.join(CheckedInSdkPath(), 'bin', 'dart-%s' % arch), | |
635 executable) | |
Ivan Posva
2015/09/15 17:01:42
Here you are overwriting the ia32 executable which
Bill Hesse
2015/09/15 17:09:02
We are already changing the source repository by c
Bill Hesse
2015/09/15 22:37:05
We can avoid doing this, if you absolutely don't w
Bill Hesse
2015/09/15 22:37:05
For testing purposes, I added a dart-ia32 binary t
Ivan Posva
2015/09/15 23:32:59
Summarizing offline discussion here:
Specifying a
Bill Hesse
2015/09/21 10:05:06
Done.
| |
636 if 42 == subprocess.call([executable, canary_script]): | |
637 return True | |
638 except (OSError, IOError) as e: | |
639 pass | |
640 return False | |
641 | |
642 | |
612 def CheckedInPubPath(): | 643 def CheckedInPubPath(): |
613 executable_name = 'pub' | 644 executable_name = 'pub' |
614 if platform.system() == 'Windows': | 645 if platform.system() == 'Windows': |
615 executable_name = 'pub.bat' | 646 executable_name = 'pub.bat' |
616 return os.path.join(CheckedInSdkPath(), 'bin', executable_name) | 647 return os.path.join(CheckedInSdkPath(), 'bin', executable_name) |
617 | 648 |
618 | 649 |
619 class TempDir(object): | 650 class TempDir(object): |
620 def __init__(self, prefix=''): | 651 def __init__(self, prefix=''): |
621 self._temp_dir = None | 652 self._temp_dir = None |
(...skipping 16 matching lines...) Expand all Loading... | |
638 os.chdir(self._working_directory) | 669 os.chdir(self._working_directory) |
639 | 670 |
640 def __exit__(self, *_): | 671 def __exit__(self, *_): |
641 print "Enter directory = ", self._old_cwd | 672 print "Enter directory = ", self._old_cwd |
642 os.chdir(self._old_cwd) | 673 os.chdir(self._old_cwd) |
643 | 674 |
644 | 675 |
645 if __name__ == "__main__": | 676 if __name__ == "__main__": |
646 import sys | 677 import sys |
647 Main() | 678 Main() |
OLD | NEW |