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

Unified 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: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | build/config/android/internal_rules.gni » ('j') | build/config/android/rules.gni » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/gyp/aar.py
diff --git a/build/android/gyp/aar.py b/build/android/gyp/aar.py
new file mode 100755
index 0000000000000000000000000000000000000000..abf944f3d5a860e1fd5ff6af1de5b70b5c225973
--- /dev/null
+++ b/build/android/gyp/aar.py
@@ -0,0 +1,51 @@
+#!/usr/bin/env python
+#
+# Copyright 2016 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.
+
+"""Processes an Android AAR file."""
+
+import argparse
+import os
+import shutil
+import sys
+import zipfile
+
+from util import build_utils
+
agrieve 2016/07/15 14:34:40 nit: 2 blank lines between top-level things
Ian Wen 2016/07/17 02:08:09 Done.
+def main():
+ parser = argparse.ArgumentParser(description=__doc__)
+ parser.add_argument('--extract',
+ help=('Extract the files to output directory.'),
agrieve 2016/07/15 14:34:41 these braces are not required.
Ian Wen 2016/07/17 02:08:08 Done.
+ action='store_true')
+ parser.add_argument('--list_res',
agrieve 2016/07/15 14:34:41 use - rather than _ in flags. --list-resources
Ian Wen 2016/07/17 02:08:09 Done.
+ help=('List all files in res folder.'),
+ action='store_true')
+ parser.add_argument('--input_file',
+ help=('Name and path of the AAR file.'),
agrieve 2016/07/15 14:34:41 nit: path implies name. Just say "Path to the .aar
Ian Wen 2016/07/17 02:08:09 Done.
+ required=True,
+ metavar='FILE')
+ parser.add_argument('--output_dir',
+ help=('Output dir for the extracted files.'),
agrieve 2016/07/15 14:34:41 nit: don't use abbreviations in help when possible
Ian Wen 2016/07/17 02:08:09 Done.
+ required=True,
agrieve 2016/07/15 14:34:40 This shouldn't be required for --list
Ian Wen 2016/07/17 02:08:08 Done.
+ metavar='PATH')
agrieve 2016/07/15 14:34:41 It would make more sense to say 'DIR' since your o
Ian Wen 2016/07/17 02:08:09 Done.
+
+ args = parser.parse_args()
+
+ aar_file = args.input_file # e.g. library.aar
+ output_dir = args.output_dir # e.g. path/to/output
+
+ if (args.extract):
agrieve 2016/07/15 14:34:41 nit: drop parentheses.
Ian Wen 2016/07/17 02:08:08 Done.
+ # Clear previously extracted versions of the AAR
agrieve 2016/07/15 14:34:41 nit: missing . at end of sentence.
Ian Wen 2016/07/17 02:08:09 Done.
+ shutil.rmtree(output_dir, True)
+ build_utils.ExtractAll(aar_file, path=output_dir)
+
+ if (args.list_res):
+ with zipfile.ZipFile(aar_file) as z:
+ for name in z.namelist():
+ if name.startswith('res/') and not name.endswith('/'):
+ print os.path.join(output_dir, name)
agrieve 2016/07/15 14:34:41 I think it would make more sense to just output na
Ian Wen 2016/07/17 02:08:09 Done.
+
+if __name__ == '__main__':
+ sys.exit(main())
« 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