write_installer_json.py 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #!/usr/bin/env python3
  2. # Copyright 2017 The Chromium Authors. All rights reserved.
  3. # Use of this source code is governed by a BSD-style license that can be
  4. # found in the LICENSE file.
  5. """Writes a .json file with the per-apk details for an incremental install."""
  6. import argparse
  7. import json
  8. import os
  9. import sys
  10. sys.path.append(os.path.join(os.path.dirname(__file__), os.pardir, 'gyp'))
  11. from util import build_utils
  12. def _ParseArgs(args):
  13. args = build_utils.ExpandFileArgs(args)
  14. parser = argparse.ArgumentParser()
  15. parser.add_argument('--output-path',
  16. help='Output path for .json file.',
  17. required=True)
  18. parser.add_argument('--apk-path',
  19. help='Path to .apk relative to output directory.',
  20. required=True)
  21. parser.add_argument('--split',
  22. action='append',
  23. dest='split_globs',
  24. default=[],
  25. help='A glob matching the apk splits. '
  26. 'Can be specified multiple times.')
  27. parser.add_argument(
  28. '--native-libs',
  29. action='append',
  30. help='GN-list of paths to native libraries relative to '
  31. 'output directory. Can be repeated.')
  32. parser.add_argument(
  33. '--dex-files', help='GN-list of dex paths relative to output directory.')
  34. parser.add_argument('--show-proguard-warning',
  35. action='store_true',
  36. default=False,
  37. help='Print a warning about proguard being disabled')
  38. options = parser.parse_args(args)
  39. options.dex_files = build_utils.ParseGnList(options.dex_files)
  40. options.native_libs = build_utils.ParseGnList(options.native_libs)
  41. return options
  42. def main(args):
  43. options = _ParseArgs(args)
  44. data = {
  45. 'apk_path': options.apk_path,
  46. 'native_libs': options.native_libs,
  47. 'dex_files': options.dex_files,
  48. 'show_proguard_warning': options.show_proguard_warning,
  49. 'split_globs': options.split_globs,
  50. }
  51. with build_utils.AtomicOutput(options.output_path, mode='w+') as f:
  52. json.dump(data, f, indent=2, sort_keys=True)
  53. if __name__ == '__main__':
  54. main(sys.argv[1:])