Commit 8c9c56e5 authored by Aidan Wolter's avatar Aidan Wolter Committed by Commit Bot

Add exclude-shared-libraries option to android_apk

This will allow Android APK targets to provide a list of shared
libraries to not link into Java. This can occur when a native
dependency includes a .so file as a runtime dep but does not
actually depend on it at link time.

BUG=b:73008622
TEST=Build and run release target with specific exclude

Change-Id: I5bd7e5a061420fafcafed7001767499d4326a269
Reviewed-on: https://chromium-review.googlesource.com/905695Reviewed-by: default avataragrieve <agrieve@chromium.org>
Commit-Queue: Aidan Wolter <awolter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#535151}
parent 0edfdc90
...@@ -69,6 +69,8 @@ def main(): ...@@ -69,6 +69,8 @@ def main():
parser.add_option('--readelf', help='Path to the readelf binary.') parser.add_option('--readelf', help='Path to the readelf binary.')
parser.add_option('--runtime-deps', parser.add_option('--runtime-deps',
help='A file created for the target using write_runtime_deps.') help='A file created for the target using write_runtime_deps.')
parser.add_option('--exclude-shared-libraries',
help='List of shared libraries to exclude from the output.')
parser.add_option('--output', help='Path to the generated .json file.') parser.add_option('--output', help='Path to the generated .json file.')
parser.add_option('--stamp', help='Path to touch on success.') parser.add_option('--stamp', help='Path to touch on success.')
...@@ -77,10 +79,15 @@ def main(): ...@@ -77,10 +79,15 @@ def main():
SetReadelfPath(options.readelf) SetReadelfPath(options.readelf)
unsorted_lib_paths = [] unsorted_lib_paths = []
exclude_shared_libraries = []
if options.exclude_shared_libraries:
exclude_shared_libraries = options.exclude_shared_libraries.split(',')
for f in open(options.runtime_deps): for f in open(options.runtime_deps):
f = f[:-1] f = f[:-1]
if f.endswith('.so'): if f.endswith('.so'):
p = f.replace('lib.unstripped/', '') p = f.replace('lib.unstripped/', '')
if os.path.basename(p) in exclude_shared_libraries:
continue
unsorted_lib_paths.append(p) unsorted_lib_paths.append(p)
_library_path_map[os.path.basename(p)] = p _library_path_map[os.path.basename(p)] = p
......
...@@ -2055,6 +2055,10 @@ if (enable_java_templates) { ...@@ -2055,6 +2055,10 @@ if (enable_java_templates) {
"--output=$_rebased_ordered_libraries_json", "--output=$_rebased_ordered_libraries_json",
"--runtime-deps=" + rebase_path(_runtime_deps_file, root_build_dir), "--runtime-deps=" + rebase_path(_runtime_deps_file, root_build_dir),
] ]
if (defined(invoker.dont_load_shared_libraries)) {
args += [ "--exclude-shared-libraries=" +
invoker.dont_load_shared_libraries ]
}
} }
java_cpp_template("${_template_name}__native_libraries_java") { java_cpp_template("${_template_name}__native_libraries_java") {
......
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