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