Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 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 |
| 3 | # found in the LICENSE file. |
| 4 | |
| 5 | """Configures devil for use in chromium.""" |
| 6 | |
| 7 | import os |
| 8 | import sys |
| 9 | |
| 10 | from pylib.constants import host_paths |
| 11 | |
| 12 | if host_paths.DEVIL_PATH not in sys.path: |
| 13 | sys.path.append(host_paths.DEVIL_PATH) |
| 14 | |
| 15 | from devil import devil_env |
| 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 | |
| 101 | |
| 102 | def Initialize(output_directory=None, custom_deps=None): |
| 103 | """Initializes devil with chromium's binaries and third-party libraries. |
| 104 | |
| 105 | This includes: |
| 106 | - Libraries: |
| 107 | - the android SDK ("android_sdk") |
| 108 | - pymock ("pymock") |
| 109 | - Build products: |
| 110 | - host & device forwarder binaries |
| 111 | ("forwarder_device" and "forwarder_host") |
| 112 | - host & device md5sum binaries ("md5sum_device" and "md5sum_host") |
| 113 | |
| 114 | Args: |
| 115 | output_directory: An optional path to the output directory. If not set, |
| 116 | no built dependencies are configured. |
| 117 | custom_deps: An optional dictionary specifying custom dependencies. |
| 118 | This should be of the form: |
| 119 | |
| 120 | { |
| 121 | 'dependency_name': { |
| 122 | 'platform': 'path', |
| 123 | ... |
| 124 | }, |
| 125 | ... |
| 126 | } |
| 127 | """ |
| 128 | |
| 129 | devil_dynamic_config = { |
| 130 | 'config_type': 'BaseConfig', |
| 131 | 'dependencies': {}, |
| 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 | } |
| 148 | if custom_deps: |
| 149 | devil_dynamic_config['dependencies'].update(custom_deps) |
| 150 | |
| 151 | devil_env.config.Initialize( |
| 152 | configs=[devil_dynamic_config], config_files=[_DEVIL_CONFIG]) |
| 153 | |