OLD | NEW |
1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 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 """Configures devil for use in chromium.""" | 5 """Configures devil for use in chromium.""" |
6 | 6 |
| 7 import logging |
7 import os | 8 import os |
8 import sys | 9 import sys |
9 | 10 |
10 from pylib.constants import host_paths | 11 from pylib.constants import host_paths |
11 | 12 |
12 if host_paths.DEVIL_PATH not in sys.path: | 13 if host_paths.DEVIL_PATH not in sys.path: |
13 sys.path.append(host_paths.DEVIL_PATH) | 14 sys.path.append(host_paths.DEVIL_PATH) |
14 | 15 |
15 from devil import devil_env | 16 from devil import devil_env |
16 | 17 |
17 _DEVIL_CONFIG = os.path.abspath( | |
18 os.path.join(os.path.dirname(__file__), 'devil_chromium.json')) | |
19 | |
20 _DEVIL_BUILD_PRODUCT_DEPS = { | |
21 'forwarder_device': [ | |
22 { | |
23 'platform': 'android', | |
24 'arch': 'armeabi-v7a', | |
25 'name': 'forwarder_dist', | |
26 }, | |
27 { | |
28 'platform': 'android', | |
29 'arch': 'arm64-v8a', | |
30 'name': 'forwarder_dist', | |
31 }, | |
32 { | |
33 'platform': 'android', | |
34 'arch': 'mips', | |
35 'name': 'forwarder_dist', | |
36 }, | |
37 { | |
38 'platform': 'android', | |
39 'arch': 'mips64', | |
40 'name': 'forwarder_dist', | |
41 }, | |
42 { | |
43 'platform': 'android', | |
44 'arch': 'x86', | |
45 'name': 'forwarder_dist', | |
46 }, | |
47 { | |
48 'platform': 'android', | |
49 'arch': 'x86_64', | |
50 'name': 'forwarder_dist', | |
51 }, | |
52 ], | |
53 'forwarder_host': [ | |
54 { | |
55 'platform': 'linux2', | |
56 'arch': 'x86_64', | |
57 'name': 'host_forwarder', | |
58 }, | |
59 ], | |
60 'md5sum_device': [ | |
61 { | |
62 'platform': 'android', | |
63 'arch': 'armeabi-v7a', | |
64 'name': 'md5sum_dist', | |
65 }, | |
66 { | |
67 'platform': 'android', | |
68 'arch': 'arm64-v8a', | |
69 'name': 'md5sum_dist', | |
70 }, | |
71 { | |
72 'platform': 'android', | |
73 'arch': 'mips', | |
74 'name': 'md5sum_dist', | |
75 }, | |
76 { | |
77 'platform': 'android', | |
78 'arch': 'mips64', | |
79 'name': 'md5sum_dist', | |
80 }, | |
81 { | |
82 'platform': 'android', | |
83 'arch': 'x86', | |
84 'name': 'md5sum_dist', | |
85 }, | |
86 { | |
87 'platform': 'android', | |
88 'arch': 'x86_64', | |
89 'name': 'md5sum_dist', | |
90 }, | |
91 ], | |
92 'md5sum_host': [ | |
93 { | |
94 'platform': 'linux2', | |
95 'arch': 'x86_64', | |
96 'name': 'md5sum_bin_host', | |
97 }, | |
98 ], | |
99 } | |
100 | |
101 | 18 |
102 def Initialize(output_directory=None, custom_deps=None): | 19 def Initialize(output_directory=None, custom_deps=None): |
103 """Initializes devil with chromium's binaries and third-party libraries. | 20 """Initializes devil with chromium's binaries and third-party libraries. |
104 | 21 |
105 This includes: | 22 This includes: |
106 - Libraries: | 23 - Libraries: |
107 - the android SDK ("android_sdk") | 24 - the android SDK ("android_sdk") |
108 - pymock ("pymock") | 25 - pymock ("pymock") |
109 - Build products: | 26 - Build products: |
110 - host & device forwarder binaries | 27 - host & device forwarder binaries |
111 ("forwarder_device" and "forwarder_host") | 28 ("forwarder_device" and "forwarder_host") |
112 - host & device md5sum binaries ("md5sum_device" and "md5sum_host") | 29 - host & device md5sum binaries ("md5sum_device" and "md5sum_host") |
113 | 30 |
114 Args: | 31 Args: |
115 output_directory: An optional path to the output directory. If not set, | 32 output_directory: An optional path to the output directory. If not set, |
116 no built dependencies are configured. | 33 no built dependencies are configured. |
117 custom_deps: An optional dictionary specifying custom dependencies. | 34 custom_deps: An optional dictionary specifying custom dependencies. |
118 This should be of the form: | 35 This should be of the form: |
119 | 36 |
120 { | 37 { |
121 'dependency_name': { | 38 'dependency_name': { |
122 'platform': 'path', | 39 'platform': 'path', |
123 ... | 40 ... |
124 }, | 41 }, |
125 ... | 42 ... |
126 } | 43 } |
127 """ | 44 """ |
| 45 config_files = None |
| 46 if output_directory: |
| 47 generated_config_file = os.path.abspath(os.path.join( |
| 48 output_directory, 'gen', 'devil_chromium.json')) |
| 49 if os.path.exists(generated_config_file): |
| 50 config_files = [generated_config_file] |
| 51 else: |
| 52 logging.warning('%s not found in output directory.', |
| 53 generated_config_file) |
128 | 54 |
129 devil_dynamic_config = { | 55 custom_config = { |
130 'config_type': 'BaseConfig', | 56 'config_type': 'BaseConfig', |
131 'dependencies': {}, | 57 'dependencies': {}, |
132 } | 58 } |
133 if output_directory: | |
134 output_directory = os.path.abspath(output_directory) | |
135 devil_dynamic_config['dependencies'] = { | |
136 dep_name: { | |
137 'file_info': { | |
138 '%s_%s' % (dep_config['platform'], dep_config['arch']): { | |
139 'local_paths': [ | |
140 os.path.join(output_directory, dep_config['name']), | |
141 ], | |
142 } | |
143 for dep_config in dep_configs | |
144 } | |
145 } | |
146 for dep_name, dep_configs in _DEVIL_BUILD_PRODUCT_DEPS.iteritems() | |
147 } | |
148 if custom_deps: | 59 if custom_deps: |
149 devil_dynamic_config['dependencies'].update(custom_deps) | 60 custom_config['dependencies'].update(custom_deps) |
150 | 61 |
151 devil_env.config.Initialize( | 62 devil_env.config.Initialize( |
152 configs=[devil_dynamic_config], config_files=[_DEVIL_CONFIG]) | 63 configs=[custom_config], config_files=config_files) |
153 | 64 |
OLD | NEW |