Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Side by Side Diff: build/android/pylib/utils/device_dependencies.py

Issue 2492123002: [android] Stop using isolate.py for data dependency management. (Closed)
Patch Set: handle None isolate file Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 # Copyright 2016 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 import ast
6 import os
7
8 from pylib import constants
9
10
11 def DevicePathComponentsFor(host_path, output_directory):
12 """Returns the device path components for a given host path.
13
14 This returns the device path as a list of joinable path compoents,
agrieve 2016/11/15 15:51:01 compoents
jbudorick 2016/11/15 19:33:15 Doe
15 with None as the first element to indicate that the path should be
16 rooted at $EXTERNAL_STORAGE.
17
18 e.g., given
19
20 '$CHROMIUM_SRC/foo/bar/baz.txt'
21
22 this would return
23
24 [None, 'foo', 'bar', 'baz.txt']
25
26 This handles a couple classes of paths differently than it otherwise would:
27 - All .pak files get mapped to top-level paks/
28 - Anything in the output directory gets mapped relative to the output
29 directory rather than the source directory.
30
31 e.g. given
32
33 '$CHROMIUM_SRC/out/Release/icu_fake_dir/icudtl.dat'
34
35 this would return
36
37 [None, 'icu_fake_dir', 'icudtl.dat']
38
39 Args:
40 host_path: The absolute path to the host file.
41 Returns:
42 A list of device path components.
43 """
44 if os.path.commonprefix([output_directory, host_path]) == output_directory:
agrieve 2016/11/15 15:51:01 commonprefix just does string comparison. So.. I t
jbudorick 2016/11/15 19:33:15 Done.
45 if os.path.splitext(host_path)[1] == '.pak':
46 return [None, 'paks', os.path.basename(host_path)]
47 rel_host_path = os.path.relpath(host_path, output_directory)
48 else:
49 rel_host_path = os.path.relpath(host_path, constants.DIR_SOURCE_ROOT)
50
51 device_path_components = [None]
52 p = rel_host_path
53 while p:
54 p, d = os.path.split(p)
55 if d:
56 device_path_components.insert(1, d)
57 return device_path_components
58
59
60 def GetDataDependencies(isolate_file_path):
61 """Returns a list of device data dependencies.
62
63 Args:
64 isolate_file_path: A str path to the isolate file.
65 Returns:
66 A list of (host_path, device_path) tuples.
67 """
68 if not isolate_file_path:
69 return []
70
71 with open(isolate_file_path, 'r') as isolate_file:
72 isolate_contents = ast.literal_eval(isolate_file.read())
73
74 isolate_file_dir = os.path.dirname(isolate_file_path)
75 rel_host_files = isolate_contents.get('variables', {}).get('files', [])
76 abs_host_files = [
77 os.path.abspath(os.path.join(isolate_file_dir, r))
78 for r in rel_host_files]
79
80 return [(a, DevicePathComponentsFor(a, constants.GetOutDirectory()))
81 for a in abs_host_files]
82
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698