summaryrefslogtreecommitdiffstats
path: root/chromium/build/android/incremental_install/write_installer_json.py
blob: 75bd6d1aab7aed63db209b3c08b19ebfb1d6167e (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
#!/usr/bin/env python

# Copyright 2017 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.

"""Writes a .json file with the per-apk details for an incremental install."""

import argparse
import json
import os
import sys

sys.path.append(os.path.join(os.path.dirname(__file__), os.pardir, 'gyp'))

from util import build_utils


def _ParseArgs(args):
  args = build_utils.ExpandFileArgs(args)
  parser = argparse.ArgumentParser()
  parser.add_argument('--output-path',
                      help='Output path for .json file.',
                      required=True)
  parser.add_argument('--apk-path',
                      help='Path to .apk relative to output directory.',
                      required=True)
  parser.add_argument('--split',
                      action='append',
                      dest='split_globs',
                      default=[],
                      help='A glob matching the apk splits. '
                           'Can be specified multiple times.')
  parser.add_argument('--native-libs-list',
                      action='append',
                      default=[],
                      help='GN-list of paths to native libraries relative to '
                           'output directory. Can be repeated.')
  parser.add_argument('--dex-file',
                      action='append',
                      default=[],
                      dest='dex_files',
                      help='.dex file to include relative to output directory. '
                           'Can be repeated')
  parser.add_argument('--dex-file-list',
                      help='GN-list of dex paths relative to output directory.')
  parser.add_argument('--show-proguard-warning',
                      action='store_true',
                      default=False,
                      help='Print a warning about proguard being disabled')
  parser.add_argument('--dont-even-try',
                      help='Prints the given message and exits.')

  options = parser.parse_args(args)
  options.dex_files += build_utils.ParseGnList(options.dex_file_list)
  all_libs = []
  for gn_list in options.native_libs_list:
    all_libs.extend(build_utils.ParseGnList(gn_list))
  options.native_libs_list = all_libs
  return options


def main(args):
  options = _ParseArgs(args)

  data = {
      'apk_path': options.apk_path,
      'native_libs': options.native_libs_list,
      'dex_files': options.dex_files,
      'dont_even_try': options.dont_even_try,
      'show_proguard_warning': options.show_proguard_warning,
      'split_globs': options.split_globs,
  }

  with build_utils.AtomicOutput(options.output_path) as f:
    json.dump(data, f, indent=2, sort_keys=True)


if __name__ == '__main__':
  main(sys.argv[1:])