summaryrefslogtreecommitdiffstats
path: root/build/android/devil_chromium.py
blob: c7142ed63a0200ec1c8d59e90661b2bc7471bf8b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# Copyright 2015 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

"""Configures devil for use in chromium."""

import os

from devil import devil_env


_DEVIL_CONFIG = os.path.abspath(
    os.path.join(os.path.dirname(__file__), 'devil_chromium.json'))

_DEVIL_BUILD_PRODUCT_DEPS = {
  'forwarder_device': [
    {
      'platform': 'android',
      'arch': 'armeabi-v7a',
      'name': 'forwarder_dist',
    },
    {
      'platform': 'android',
      'arch': 'arm64-v8a',
      'name': 'forwarder_dist',
    },
    {
      'platform': 'android',
      'arch': 'mips',
      'name': 'forwarder_dist',
    },
    {
      'platform': 'android',
      'arch': 'mips64',
      'name': 'forwarder_dist',
    },
    {
      'platform': 'android',
      'arch': 'x86',
      'name': 'forwarder_dist',
    },
    {
      'platform': 'android',
      'arch': 'x86_64',
      'name': 'forwarder_dist',
    },
  ],
  'forwarder_host': [
    {
      'platform': 'linux2',
      'arch': 'x86_64',
      'name': 'host_forwarder',
    },
  ],
  'md5sum_device': [
    {
      'platform': 'android',
      'arch': 'armeabi-v7a',
      'name': 'md5sum_dist',
    },
    {
      'platform': 'android',
      'arch': 'arm64-v8a',
      'name': 'md5sum_dist',
    },
    {
      'platform': 'android',
      'arch': 'mips',
      'name': 'md5sum_dist',
    },
    {
      'platform': 'android',
      'arch': 'mips64',
      'name': 'md5sum_dist',
    },
    {
      'platform': 'android',
      'arch': 'x86',
      'name': 'md5sum_dist',
    },
    {
      'platform': 'android',
      'arch': 'x86_64',
      'name': 'md5sum_dist',
    },
  ],
  'md5sum_host': [
    {
      'platform': 'linux2',
      'arch': 'x86_64',
      'name': 'md5sum_bin_host',
    },
  ],
}


def Initialize(output_directory=None, custom_deps=None):
  """Initializes devil with chromium's binaries and third-party libraries.

  This includes:
    - Libraries:
      - the android SDK ("android_sdk")
      - pymock ("pymock")
    - Build products:
      - host & device forwarder binaries
          ("forwarder_device" and "forwarder_host")
      - host & device md5sum binaries ("md5sum_device" and "md5sum_host")

  Args:
    output_directory: An optional path to the output directory. If not set,
      no built dependencies are configured.
    custom_deps: An optional dictionary specifying custom dependencies.
      This should be of the form:

        {
          'dependency_name': {
            'platform': 'path',
            ...
          },
          ...
        }
  """

  devil_dynamic_config = {
    'config_type': 'BaseConfig',
    'dependencies': {},
  }
  if output_directory:
    devil_dynamic_config['dependencies'] = {
      dep_name: {
        'file_info': {
          '%s_%s' % (dep_config['platform'], dep_config['arch']): {
            'local_paths': [
              os.path.join(output_directory, dep_config['name']),
            ],
          }
          for dep_config in dep_configs
        }
      }
      for dep_name, dep_configs in _DEVIL_BUILD_PRODUCT_DEPS.iteritems()
    }
  if custom_deps:
    devil_dynamic_config['dependencies'].update(custom_deps)

  devil_env.config.Initialize(
      configs=[devil_dynamic_config], config_files=[_DEVIL_CONFIG])