Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Side by Side Diff: build/android/gyp/aar.py

Issue 2156453002: Add AAR support to Chrome and convert support libraries to using AARs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix recompile issue Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | build/config/android/internal_rules.gni » ('j') | build/config/android/rules.gni » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 #
3 # Copyright 2016 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 """Processes an Android AAR file."""
8
9 import argparse
10 import os
11 import shutil
12 import sys
13 import zipfile
14
15 from util import build_utils
16
17 sys.path.append(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir))
jbudorick 2016/07/19 13:14:06 nit: sys.path.append(os.path.abspath(...))
Ian Wen 2016/07/19 18:36:48 Done.
18 import gn_helpers
19
20
21 def main():
22 parser = argparse.ArgumentParser(description=__doc__)
23 parser.add_argument('--input-file',
24 help='Path to the AAR file.',
25 required=True,
26 metavar='FILE')
27 parser.add_argument('--extract',
28 help='Extract the files to output directory.',
29 action='store_true')
30 parser.add_argument('--list',
31 help='List all the resource and jar files.',
32 action='store_true')
33 parser.add_argument('--output-dir',
34 help='Output directory for the extracted files. Must '
35 'be set if --extract is set.',
36 metavar='DIR')
37
38 args = parser.parse_args()
39 assert args.extract is not None or args.list is not None
jbudorick 2016/07/19 13:14:06 nit: this should be calling parser.error if neithe
Ian Wen 2016/07/19 18:36:48 Done.
40
41 aar_file = args.input_file # e.g. library.aar
jbudorick 2016/07/19 13:14:06 nit: move these examples up into the help text.
Ian Wen 2016/07/19 18:36:48 These comments are very basic. I will simply remov
42 output_dir = args.output_dir # e.g. path/to/output
43
44 if args.extract:
45 # Clear previously extracted versions of the AAR.
46 shutil.rmtree(output_dir, True)
47 build_utils.ExtractAll(aar_file, path=output_dir)
48
49 if args.list:
50 data = {}
51 data['resources'] = []
52 data['jars'] = []
53 with zipfile.ZipFile(aar_file) as z:
54 for name in z.namelist():
55 if name.startswith('res/') and not name.endswith('/'):
56 data['resources'].append(name)
57 if name.endswith('.jar'):
58 data['jars'].append(name)
59 print gn_helpers.ToGNString(data)
60
61
62 if __name__ == '__main__':
63 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | build/config/android/internal_rules.gni » ('j') | build/config/android/rules.gni » ('J')

Powered by Google App Engine
This is Rietveld 408576698