| 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): |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 | 26 |
| 27 if self.build_dir is not None: | 27 if self.build_dir is not None: |
| 28 self.mojo_launcher_path = os.path.join(self.build_dir, "mojo_launcher") | 28 self.mojo_launcher_path = os.path.join(self.build_dir, "mojo_launcher") |
| 29 self.mojo_shell_path = os.path.join(self.build_dir, "mojo_shell") | 29 self.mojo_shell_path = os.path.join(self.build_dir, "mojo_shell") |
| 30 # TODO(vtl): Use the host OS here, since |config| may not be available. | 30 # TODO(vtl): Use the host OS here, since |config| may not be available. |
| 31 # In any case, if the target is Windows, but the host isn't, using | 31 # In any case, if the target is Windows, but the host isn't, using |
| 32 # |os.path| isn't correct.... | 32 # |os.path| isn't correct.... |
| 33 if Config.GetHostOS() == Config.OS_WINDOWS: | 33 if Config.GetHostOS() == Config.OS_WINDOWS: |
| 34 self.mojo_launcher_path += ".exe" | 34 self.mojo_launcher_path += ".exe" |
| 35 self.mojo_shell_path += ".exe" | 35 self.mojo_shell_path += ".exe" |
| 36 if config and config.target_os == Config.OS_ANDROID: | |
| 37 self.target_mojo_shell_path = os.path.join(self.build_dir, | |
| 38 "apks", | |
| 39 "MojoShell.apk") | |
| 40 else: | |
| 41 self.target_mojo_shell_path = self.mojo_shell_path | |
| 42 else: | 36 else: |
| 43 self.mojo_launcher_path = None | 37 self.mojo_launcher_path = None |
| 44 self.mojo_shell_path = None | 38 self.mojo_shell_path = None |
| 45 self.target_mojo_shell_path = None | |
| 46 | 39 |
| 47 def RelPath(self, path): | 40 def RelPath(self, path): |
| 48 """Returns the given path, relative to the current directory.""" | 41 """Returns the given path, relative to the current directory.""" |
| 49 return os.path.relpath(path) | 42 return os.path.relpath(path) |
| 50 | 43 |
| 51 def SrcRelPath(self, path): | 44 def SrcRelPath(self, path): |
| 52 """Returns the given path, relative to self.src_root.""" | 45 """Returns the given path, relative to self.src_root.""" |
| 53 return os.path.relpath(path, self.src_root) | 46 return os.path.relpath(path, self.src_root) |
| 54 | 47 |
| 55 def FileFromUrl(self, url): | 48 def FileFromUrl(self, url): |
| 56 """Given an app URL (<scheme>:<appname>), return 'build_dir/appname.mojo'. | 49 """Given an app URL (<scheme>:<appname>), return 'build_dir/appname.mojo'. |
| 57 If self.build_dir is None, just return appname.mojo | 50 If self.build_dir is None, just return appname.mojo |
| 58 """ | 51 """ |
| 59 (_, name) = url.split(':') | 52 (_, name) = url.split(':') |
| 60 if self.build_dir: | 53 if self.build_dir: |
| 61 return os.path.join(self.build_dir, name + '.mojo') | 54 return os.path.join(self.build_dir, name + '.mojo') |
| 62 return name + '.mojo' | 55 return name + '.mojo' |
| 63 | 56 |
| 64 @staticmethod | 57 @staticmethod |
| 65 def IsValidAppUrl(url): | 58 def IsValidAppUrl(url): |
| 66 """Returns False if url is malformed, True otherwise.""" | 59 """Returns False if url is malformed, True otherwise.""" |
| 67 try: | 60 try: |
| 68 return len(url.split(':')) == 2 | 61 return len(url.split(':')) == 2 |
| 69 except ValueError: | 62 except ValueError: |
| 70 return False | 63 return False |
| OLD | NEW |