1#!/usr/bin/env python
2#
3# Copyright 2019 The Chromium Authors. All rights reserved.
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6
7"""Creates an .apks from an .aab."""
8
9import argparse
10import os
11import sys
12
13sys.path.append(
14    os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir)))
15from pylib.utils import app_bundle_utils
16
17
18def main():
19  parser = argparse.ArgumentParser(description=__doc__)
20  parser.add_argument(
21      '--bundle', required=True, help='Path to input .aab file.')
22  parser.add_argument(
23      '--output', required=True, help='Path to output .apks file.')
24  parser.add_argument('--aapt2-path', required=True, help='Path to aapt2.')
25  parser.add_argument(
26      '--keystore-path', required=True, help='Path to keystore.')
27  parser.add_argument(
28      '--keystore-password', required=True, help='Keystore password.')
29  parser.add_argument(
30      '--keystore-name', required=True, help='Key name within keystore')
31  parser.add_argument(
32      '--minimal',
33      action='store_true',
34      help='Create APKs archive with minimal language support.')
35
36  args = parser.parse_args()
37
38  app_bundle_utils.GenerateBundleApks(
39      args.bundle,
40      args.output,
41      args.aapt2_path,
42      args.keystore_path,
43      args.keystore_password,
44      args.keystore_name,
45      minimal=args.minimal,
46      check_for_noop=False)
47
48
49if __name__ == '__main__':
50  main()
51