summaryrefslogtreecommitdiffstats
path: root/chromium/build/android/incremental_install/write_installer_json.py
blob: df6cfdf734ca0f65da5f0cc48c4808461ff5ce3f (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
#!/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',
      action='append',
      help='GN-list of paths to native libraries relative to '
      'output directory. Can be repeated.')
  parser.add_argument(
      '--dex-files', 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_files)
  options.native_libs = build_utils.ParseGnList(options.native_libs)
  return options


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

  data = {
      'apk_path': options.apk_path,
      'native_libs': options.native_libs,
      '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:])