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 | |
8 import os | 7 import os |
9 import sys | 8 import sys |
10 | 9 |
11 from pylib.constants import host_paths | 10 from pylib.constants import host_paths |
12 | 11 |
13 if host_paths.DEVIL_PATH not in sys.path: | 12 if host_paths.DEVIL_PATH not in sys.path: |
14 sys.path.append(host_paths.DEVIL_PATH) | 13 sys.path.append(host_paths.DEVIL_PATH) |
15 | 14 |
16 from devil import devil_env | 15 from devil import devil_env |
17 | 16 |
| 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 |
18 | 101 |
19 def Initialize(output_directory=None, custom_deps=None): | 102 def Initialize(output_directory=None, custom_deps=None): |
20 """Initializes devil with chromium's binaries and third-party libraries. | 103 """Initializes devil with chromium's binaries and third-party libraries. |
21 | 104 |
22 This includes: | 105 This includes: |
23 - Libraries: | 106 - Libraries: |
24 - the android SDK ("android_sdk") | 107 - the android SDK ("android_sdk") |
25 - pymock ("pymock") | 108 - pymock ("pymock") |
26 - Build products: | 109 - Build products: |
27 - host & device forwarder binaries | 110 - host & device forwarder binaries |
28 ("forwarder_device" and "forwarder_host") | 111 ("forwarder_device" and "forwarder_host") |
29 - host & device md5sum binaries ("md5sum_device" and "md5sum_host") | 112 - host & device md5sum binaries ("md5sum_device" and "md5sum_host") |
30 | 113 |
31 Args: | 114 Args: |
32 output_directory: An optional path to the output directory. If not set, | 115 output_directory: An optional path to the output directory. If not set, |
33 no built dependencies are configured. | 116 no built dependencies are configured. |
34 custom_deps: An optional dictionary specifying custom dependencies. | 117 custom_deps: An optional dictionary specifying custom dependencies. |
35 This should be of the form: | 118 This should be of the form: |
36 | 119 |
37 { | 120 { |
38 'dependency_name': { | 121 'dependency_name': { |
39 'platform': 'path', | 122 'platform': 'path', |
40 ... | 123 ... |
41 }, | 124 }, |
42 ... | 125 ... |
43 } | 126 } |
44 """ | 127 """ |
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) | |
54 | 128 |
55 custom_config = { | 129 devil_dynamic_config = { |
56 'config_type': 'BaseConfig', | 130 'config_type': 'BaseConfig', |
57 'dependencies': {}, | 131 'dependencies': {}, |
58 } | 132 } |
| 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 } |
59 if custom_deps: | 148 if custom_deps: |
60 custom_config['dependencies'].update(custom_deps) | 149 devil_dynamic_config['dependencies'].update(custom_deps) |
61 | 150 |
62 devil_env.config.Initialize( | 151 devil_env.config.Initialize( |
63 configs=[custom_config], config_files=config_files) | 152 configs=[devil_dynamic_config], config_files=[_DEVIL_CONFIG]) |
64 | 153 |
OLD | NEW |