Move CheckedInSdkPath helpers to utils

BUG=
R=ricow@google.com

Review URL: https://codereview.chromium.org//1342493003 .
This commit is contained in:
John McCutchan
2015-09-14 07:05:51 -07:00
parent dc6b09a6d7
commit 28a2239289
2 changed files with 27 additions and 20 deletions
+2 -20
View File
@@ -10,6 +10,7 @@ import platform
import shutil
import subprocess
import sys
import utils
SCRIPT_DIR = os.path.dirname(sys.argv[0])
DART_ROOT = os.path.realpath(os.path.join(SCRIPT_DIR, '..'))
@@ -27,25 +28,6 @@ IGNORE_PATTERNS = shutil.ignore_patterns(
usage = """obs_tool.py [options]"""
def GetDartSdkPubExecutablePath():
osdict = {'Darwin':'mac', 'Linux':'linux', 'Windows':'win'}
system = platform.system()
executable_name = 'pub'
if system == 'Windows':
executable_name = 'pub.bat'
try:
osname = osdict[system]
except KeyError:
print >>sys.stderr, ('WARNING: platform "%s" not supported') % (system)
return None;
return os.path.join(DART_ROOT,
'tools',
'sdks',
osname,
'dart-sdk',
'bin',
executable_name)
def BuildArguments():
result = argparse.ArgumentParser(usage=usage)
result.add_argument("--package-root", help="package root", default=None)
@@ -66,7 +48,7 @@ def ProcessOptions(options, args):
return True
if (options.sdk != None):
# Use the checked in pub executable by default.
options.pub_executable = GetDartSdkPubExecutablePath()
options.pub_executable = utils.CheckedInPubPath()
return True
# Otherwise, we need a dart executable and a package root.
return ((options.package_root != None) and
+25
View File
@@ -591,6 +591,31 @@ def DartSdkBinary():
dart_binary_prefix = os.path.join(tools_dir, '..', 'sdk' , 'bin')
return os.path.join(dart_binary_prefix, 'dart')
def CheckedInSdkPath():
# We don't use the normal macos, linux, win32 directory names here, instead,
# we use the names that the download_from_google_storage script uses.
osdict = {'Darwin':'mac', 'Linux':'linux', 'Windows':'win'}
system = platform.system()
try:
osname = osdict[system]
except KeyError:
print >>sys.stderr, ('WARNING: platform "%s" not supported') % (system)
return None;
tools_dir = os.path.dirname(os.path.realpath(__file__))
return os.path.join(tools_dir,
'sdks',
osname,
'dart-sdk')
def CheckedInPubPath():
executable_name = 'pub'
if platform.system() == 'Windows':
executable_name = 'pub.bat'
return os.path.join(CheckedInSdkPath(), 'bin', executable_name)
class TempDir(object):
def __init__(self, prefix=''):
self._temp_dir = None