Commit 65c55035 authored by Clark DuVall's avatar Clark DuVall Committed by Commit Bot

[WebLayer] Remove unnecessary files from aar

We were including build config and android support library files in the
weblayer aar. We really only want to include the weblayer files in the
aar, since the app including it will provide the support library and
other things we need. This adds arguments to the dist_aar rule to
filter what goes into the jar files, similar to other java rules.

Change-Id: Id5393d06dac8b0d957469a3279c74199088f3732
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1825567
Commit-Queue: Clark DuVall <cduvall@chromium.org>
Reviewed-by: default avatarAndrew Grieve <agrieve@chromium.org>
Reviewed-by: default avatarRichard Coles <torne@chromium.org>
Cr-Commit-Position: refs/heads/master@{#700338}
parent e109347b
......@@ -14,6 +14,7 @@ import sys
import tempfile
import zipfile
from filter_zip import CreatePathTransform
from util import build_utils
......@@ -77,8 +78,12 @@ def main(args):
'ABI must be specified.')
parser.add_argument('--abi',
help='ABI (e.g. armeabi-v7a) for native libraries.')
parser.add_argument('--input-zips-excluded-globs',
help='GN-list of globs for paths to exclude.')
parser.add_argument(
'--jar-excluded-globs',
help='GN-list of globs for paths to exclude in jar.')
parser.add_argument(
'--jar-included-globs',
help='GN-list of globs for paths to include in jar.')
options = parser.parse_args(args)
......@@ -91,6 +96,10 @@ def main(args):
options.r_text_files = build_utils.ParseGnList(options.r_text_files)
options.proguard_configs = build_utils.ParseGnList(options.proguard_configs)
options.native_libraries = build_utils.ParseGnList(options.native_libraries)
options.jar_excluded_globs = build_utils.ParseGnList(
options.jar_excluded_globs)
options.jar_included_globs = build_utils.ParseGnList(
options.jar_included_globs)
with tempfile.NamedTemporaryFile(delete=False) as staging_file:
try:
......@@ -98,12 +107,9 @@ def main(args):
build_utils.AddToZipHermetic(
z, 'AndroidManifest.xml', src_path=options.android_manifest)
path_transform = CreatePathTransform(options.jar_excluded_globs,
options.jar_included_globs, [])
with tempfile.NamedTemporaryFile() as jar_file:
path_transform = None
if options.input_zips_excluded_globs:
globs = build_utils.ParseGnList(options.input_zips_excluded_globs)
path_transform = (
lambda p: None if build_utils.MatchesGlob(p, globs) else p)
build_utils.MergeZips(
jar_file.name, options.jars, path_transform=path_transform)
build_utils.AddToZipHermetic(z, 'classes.jar', src_path=jar_file.name)
......
......@@ -2,6 +2,7 @@
# build/print_python_deps.py --root build/android/gyp --output build/android/gyp/dist_aar.pydeps build/android/gyp/dist_aar.py
../../gn_helpers.py
dist_aar.py
filter_zip.py
util/__init__.py
util/build_utils.py
util/md5_check.py
......@@ -18,7 +18,7 @@ _RESOURCE_CLASSES = [
]
def _CreatePathTransform(exclude_globs, include_globs,
def CreatePathTransform(exclude_globs, include_globs,
strip_resource_classes_for):
exclude_globs = list(exclude_globs or [])
if strip_resource_classes_for:
......@@ -60,8 +60,8 @@ def main():
args.strip_resource_classes_for = build_utils.ParseGnList(
args.strip_resource_classes_for)
path_transform = _CreatePathTransform(
args.exclude_globs, args.include_globs, args.strip_resource_classes_for)
path_transform = CreatePathTransform(args.exclude_globs, args.include_globs,
args.strip_resource_classes_for)
with build_utils.AtomicOutput(args.output) as f:
build_utils.MergeZips(
f.name, [args.input], path_transform=path_transform)
......
......@@ -1758,7 +1758,8 @@ if (enable_java_templates) {
# android_manifest: Path to AndroidManifest.xml (optional).
# native_libraries: list of native libraries (optional).
# direct_deps_only: Do not recurse on deps. (optional, defaults false).
# jar_excluded_patterns: List of patterns of .class files to exclude.
# jar_excluded_patterns (optional): List of globs for paths to exclude.
# jar_included_patterns (optional): List of globs for paths to include.
#
# Example
# dist_aar("my_aar") {
......@@ -1844,7 +1845,10 @@ if (enable_java_templates) {
]
}
if (defined(invoker.jar_excluded_patterns)) {
args += [ "--input-zips-excluded-globs=${invoker.jar_excluded_patterns}" ]
args += [ "--jar-excluded-globs=${invoker.jar_excluded_patterns}" ]
}
if (defined(invoker.jar_included_patterns)) {
args += [ "--jar-included-globs=${invoker.jar_included_patterns}" ]
}
}
}
......
......@@ -39,8 +39,8 @@ android_library("java") {
deps = [
":client_resources",
"//weblayer/browser/java:client_java",
"//third_party/android_deps:com_android_support_support_fragment_java",
"//weblayer/browser/java:client_java",
]
# Needed for android.webkit.WebViewDelegate.
......@@ -54,11 +54,11 @@ dist_aar("client_aar") {
":weblayer_client_manifest",
]
jar_excluded_patterns = [
"*android/support/*",
"*android/arch/*",
"*androidx/*",
"*_support*",
# The aar should only include weblayer files. The client will provide the
# support library.
jar_included_patterns = [
"org/chromium/weblayer/*",
"org/chromium/weblayer_private/*",
]
# dist_aar does not take the manifest from libraries in deps, so we have to
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment