Chromium Code Reviews| Index: build/android/gyp/aar.py |
| diff --git a/build/android/gyp/aar.py b/build/android/gyp/aar.py |
| index 503f9e56a15591cf795bda3f1b61b86124d4d960..f6ebac43d66b09aeab9a3782f5470826c3dad5ef 100755 |
| --- a/build/android/gyp/aar.py |
| +++ b/build/android/gyp/aar.py |
| @@ -8,8 +8,11 @@ |
| import argparse |
| import os |
| +import posixpath |
| +import re |
| import shutil |
| import sys |
| +from xml.etree import ElementTree |
| import zipfile |
| from util import build_utils |
| @@ -19,6 +22,22 @@ sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), |
| import gn_helpers |
| +def _IsManifestEmpty(manifest_str): |
| + """Returns whether the given manifest has merge-worthy elements. |
| + |
| + E.g.: <activity>, <service>, etc. |
| + """ |
| + doc = ElementTree.fromstring(manifest_str) |
| + for node in doc: |
| + if node.tag == 'application': |
| + if len(node): |
| + return False |
| + elif node.tag != 'uses-sdk': |
| + return False |
| + |
| + return True |
| + |
| + |
| def main(): |
| parser = argparse.ArgumentParser(description=__doc__) |
| parser.add_argument('--input-file', |
| @@ -50,14 +69,36 @@ def main(): |
| if args.list: |
| data = {} |
| + data['assets'] = [] |
| data['resources'] = [] |
| - data['jars'] = [] |
| + data['subjars'] = [] |
| + data['subjar_labels'] = [] |
| + data['has_classes_jar'] = False |
| + data['has_proguard_flags'] = False |
| + data['has_native_libraries'] = False |
| with zipfile.ZipFile(aar_file) as z: |
| + data['is_manifest_empty'] = ( |
| + _IsManifestEmpty(z.read('AndroidManifest.xml'))) |
| + |
| for name in z.namelist(): |
| - if name.startswith('res/') and not name.endswith('/'): |
| + if name.endswith('/'): |
| + continue |
| + if name.startswith('res/'): |
| data['resources'].append(name) |
| - if name.endswith('.jar'): |
| - data['jars'].append(name) |
| + elif name.startswith('libs/') and name.endswith('.jar'): |
| + label = posixpath.basename(name)[:-4] |
| + label = re.sub(r'[^a-zA-Z0-9._]', '_', label) |
| + data['subjars'].append(name) |
|
Ian Wen
2016/09/06 19:09:59
One way to simplify the code a bit, is to still us
agrieve
2016/09/06 21:00:51
I originally separated this from the main classes.
Ian Wen
2016/09/06 21:38:34
Okay sg. :)
|
| + data['subjar_labels'].append(label) |
| + elif name.startswith('assets/'): |
| + data['assets'].append(name) |
| + elif name.startswith('jni/'): |
| + data['has_native_libraries'] = True |
|
Ian Wen
2016/09/06 19:09:59
Instead of outputting a boolean, have you consider
agrieve
2016/09/06 21:00:51
I did consider it. The tricky bit is that the ther
Ian Wen
2016/09/06 21:38:34
Hmm if we are not going to support native librarie
agrieve
2016/09/07 02:19:30
Much of the motivation behind these flags is that
|
| + elif name == 'classes.jar': |
| + data['has_classes_jar'] = True |
| + elif name == 'proguard.txt': |
| + data['has_proguard_flags'] = True |
|
Ian Wen
2016/09/06 19:09:59
How about AIDLs and annotations?
AIDLs are includ
agrieve
2016/09/06 21:00:51
Was going by the list here: http://tools.android.c
|
| + |
| print gn_helpers.ToGNString(data) |