OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import os | 5 import os |
6 | 6 |
7 from .config import Config | 7 from .config import Config |
8 from .gn import BuildDirectoryForConfig | 8 from .gn import BuildDirectoryForConfig |
9 | 9 |
10 class Paths(object): | 10 class Paths(object): |
11 """Provides commonly used paths""" | 11 """Provides commonly used paths""" |
12 | 12 |
13 def __init__(self, config=None, build_dir=None): | 13 def __init__(self, config=None, build_dir=None): |
14 """Specify either a config or a build_dir to generate paths to binary | 14 """Specify either a config or a build_dir to generate paths to binary |
15 artifacts.""" | 15 artifacts.""" |
16 self.src_root = os.path.abspath(os.path.join(__file__, | 16 self.src_root = os.path.abspath(os.path.join(__file__, |
17 os.pardir, os.pardir, os.pardir, os.pardir)) | 17 os.pardir, os.pardir, os.pardir, os.pardir)) |
18 self.mojo_dir = os.path.join(self.src_root, "mojo") | 18 self.mojo_dir = os.path.join(self.src_root, "mojo") |
19 self.adb_path = os.path.join(self.src_root, 'third_party', 'android_tools', | 19 self.adb_path = os.path.join(self.src_root, 'third_party', 'android_tools', |
20 'sdk', 'platform-tools', 'adb') | 20 'sdk', 'platform-tools', 'adb') |
21 | 21 |
22 if config: | 22 if config: |
23 self.build_dir = BuildDirectoryForConfig(config, self.src_root) | 23 self.build_dir = BuildDirectoryForConfig(config, self.src_root) |
24 elif build_dir is not None: | 24 elif build_dir is not None: |
25 self.build_dir = os.path.abspath(build_dir) | 25 self.build_dir = os.path.abspath(build_dir) |
26 else: | 26 else: |
27 self.build_dir = None | 27 self.build_dir = None |
28 | 28 |
29 if self.build_dir is not None: | 29 if self.build_dir is not None: |
30 self.mojo_shell_path = os.path.join(self.build_dir, "mojo_shell") | 30 self.mojo_shell_path = os.path.join(self.build_dir, "mojo_runner") |
31 # TODO(vtl): Use the host OS here, since |config| may not be available. | 31 # TODO(vtl): Use the host OS here, since |config| may not be available. |
32 # In any case, if the target is Windows, but the host isn't, using | 32 # In any case, if the target is Windows, but the host isn't, using |
33 # |os.path| isn't correct.... | 33 # |os.path| isn't correct.... |
34 if Config.GetHostOS() == Config.OS_WINDOWS: | 34 if Config.GetHostOS() == Config.OS_WINDOWS: |
35 self.mojo_shell_path += ".exe" | 35 self.mojo_shell_path += ".exe" |
36 if config and config.target_os == Config.OS_ANDROID: | 36 if config and config.target_os == Config.OS_ANDROID: |
37 self.target_mojo_shell_path = os.path.join(self.build_dir, | 37 self.target_mojo_shell_path = os.path.join(self.build_dir, |
38 "apks", | 38 "apks", |
39 "MojoShell.apk") | 39 "MojoShell.apk") |
40 else: | 40 else: |
(...skipping 19 matching lines...) Expand all Loading... |
60 return os.path.join(self.build_dir, name + '.mojo') | 60 return os.path.join(self.build_dir, name + '.mojo') |
61 return name + '.mojo' | 61 return name + '.mojo' |
62 | 62 |
63 @staticmethod | 63 @staticmethod |
64 def IsValidAppUrl(url): | 64 def IsValidAppUrl(url): |
65 """Returns False if url is malformed, True otherwise.""" | 65 """Returns False if url is malformed, True otherwise.""" |
66 try: | 66 try: |
67 return len(url.split(':')) == 2 | 67 return len(url.split(':')) == 2 |
68 except ValueError: | 68 except ValueError: |
69 return False | 69 return False |
OLD | NEW |