forked from Igalia/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add AAR support to Chrome and convert support libraries to using AARs
Chrome has been using Jar and resources from support library for years. In Q1 2016, Android team stops shipping jars/res for support libray. Instead, AAR is promoted, which is a zip that wraps jars and resources. This CL introduces a utility python script that processes an AAR file. In GN gen time, it lists all files in the AAR, yet it does not extract it. Actual unpacking is postponed until compilation. Two other things to notice: 1. In the old jar we depended on, support-v13 contains support-v4 and support-annotations. After converting to AAR, these two libraries are no longer part of support-v13. Thus this change needs to be reflected. 2. In the new AAR format, support-v4 now contains two jars instead of one. All public classes are in classes.jar, and all hidden classes are in libs/internal_impl-$VERSION.jar. This work is not possible without bajones@'s pioneering work in https://chromiumcodereview.appspot.com/2069273002/ BUG=611171 Review-Url: https://codereview.chromium.org/2156453002 Cr-Commit-Position: refs/heads/master@{#406603}
- Loading branch information
1 parent
0e8ac09
commit c84b975
Showing
17 changed files
with
237 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#!/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 | ||
|
||
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), | ||
os.pardir, os.pardir))) | ||
import gn_helpers | ||
|
||
|
||
def main(): | ||
parser = argparse.ArgumentParser(description=__doc__) | ||
parser.add_argument('--input-file', | ||
help='Path to the AAR file.', | ||
required=True, | ||
metavar='FILE') | ||
parser.add_argument('--extract', | ||
help='Extract the files to output directory.', | ||
action='store_true') | ||
parser.add_argument('--list', | ||
help='List all the resource and jar files.', | ||
action='store_true') | ||
parser.add_argument('--output-dir', | ||
help='Output directory for the extracted files. Must ' | ||
'be set if --extract is set.', | ||
metavar='DIR') | ||
|
||
args = parser.parse_args() | ||
if not args.extract and not args.list: | ||
parser.error('Either --extract or --list has to be specified.') | ||
|
||
aar_file = args.input_file | ||
output_dir = args.output_dir | ||
|
||
if args.extract: | ||
# Clear previously extracted versions of the AAR. | ||
shutil.rmtree(output_dir, True) | ||
build_utils.ExtractAll(aar_file, path=output_dir) | ||
|
||
if args.list: | ||
data = {} | ||
data['resources'] = [] | ||
data['jars'] = [] | ||
with zipfile.ZipFile(aar_file) as z: | ||
for name in z.namelist(): | ||
if name.startswith('res/') and not name.endswith('/'): | ||
data['resources'].append(name) | ||
if name.endswith('.jar'): | ||
data['jars'].append(name) | ||
print gn_helpers.ToGNString(data) | ||
|
||
|
||
if __name__ == '__main__': | ||
sys.exit(main()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.