tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

write_installer_json.py (2258B)


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