Commit f85138bc authored by Mohamed Heikal's avatar Mohamed Heikal Committed by Commit Bot

Add support for android_native_prebuilt

Add a new gn template that allows depending on a prebuilt native library
in chrome's build rules.

Bug: 1135175
Change-Id: I98b442862afe3bed6c48a7fa48ced5aa77522362
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2448666
Commit-Queue: Mohamed Heikal <mheikal@chromium.org>
Reviewed-by: default avatarAndrew Grieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#814220}
parent f3780538
...@@ -1350,6 +1350,7 @@ _GENERIC_PYDEPS_FILES = [ ...@@ -1350,6 +1350,7 @@ _GENERIC_PYDEPS_FILES = [
'build/android/gyp/main_dex_list.pydeps', 'build/android/gyp/main_dex_list.pydeps',
'build/android/gyp/merge_manifest.pydeps', 'build/android/gyp/merge_manifest.pydeps',
'build/android/gyp/prepare_resources.pydeps', 'build/android/gyp/prepare_resources.pydeps',
'build/android/gyp/process_native_prebuilt.pydeps',
'build/android/gyp/proguard.pydeps', 'build/android/gyp/proguard.pydeps',
'build/android/gyp/turbine.pydeps', 'build/android/gyp/turbine.pydeps',
'build/android/gyp/validate_static_library_dex_references.pydeps', 'build/android/gyp/validate_static_library_dex_references.pydeps',
......
#!/usr/bin/env python
#
# Copyright 2020 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.
import argparse
import os
import shutil
import sys
from util import build_utils
def main(args):
parser = argparse.ArgumentParser(args)
parser.add_argument('--strip-path', required=True, help='')
parser.add_argument('--input-path', required=True, help='')
parser.add_argument('--stripped-output-path', required=True, help='')
parser.add_argument('--unstripped-output-path', required=True, help='')
options = parser.parse_args(args)
cmd = [
options.strip_path,
options.input_path,
'-o',
options.stripped_output_path,
]
build_utils.CheckOutput(cmd)
shutil.copyfile(options.input_path, options.unstripped_output_path)
if __name__ == '__main__':
main(sys.argv[1:])
# Generated by running:
# build/print_python_deps.py --root build/android/gyp --output build/android/gyp/process_native_prebuilt.pydeps build/android/gyp/process_native_prebuilt.py
../../gn_helpers.py
process_native_prebuilt.py
util/__init__.py
util/build_utils.py
...@@ -938,6 +938,63 @@ if (enable_java_templates) { ...@@ -938,6 +938,63 @@ if (enable_java_templates) {
} }
} }
# Declare a prebuilt android native library.
#
# This takes a base directory and library name and then looks for the library
# in <base dir>/$android_app_abi/<library name>.
#
# If you depend on this target, the library is stripped and output to the
# same locations non-prebuilt libraries are output.
#
# Variables
# base_dir: Directory where all ABIs of the library live.
# library_name: Name of the library .so file.
#
# Example
# android_native_prebuilt("elements_native") {
# base_dir = "//third_party/elements"
# lib_name = "elements.so"
# }
template("android_native_prebuilt") {
action_with_pydeps(target_name) {
forward_variables_from(invoker,
[
"deps",
"testonly",
])
script = "//build/android/gyp/process_native_prebuilt.py"
_lib_path = "${invoker.base_dir}/$android_app_abi/${invoker.lib_name}"
_stripped_output_path = "$root_out_dir/${invoker.lib_name}"
_unstripped_output_path =
"$root_out_dir/lib.unstripped/${invoker.lib_name}"
inputs = [ _lib_path ]
outputs = [
_stripped_output_path,
_unstripped_output_path,
]
# Add unstripped output to runtime deps for use by bots during stacktrace
# symbolization.
data = [ _unstripped_output_path ]
_rebased_lib_path = rebase_path(_lib_path, root_build_dir)
_rebased_stripped_ouput_path =
rebase_path(_stripped_output_path, root_build_dir)
_rebased_unstripped_ouput_path =
rebase_path(_unstripped_output_path, root_build_dir)
_strip_tool_path =
rebase_path("//buildtools/third_party/eu-strip/bin/eu-strip",
root_build_dir)
args = [
"--strip-path=$_strip_tool_path",
"--input-path=$_rebased_lib_path",
"--stripped-output-path=$_rebased_stripped_ouput_path",
"--unstripped-output-path=$_rebased_unstripped_ouput_path",
]
}
}
# Declare an Android resources target # Declare an Android resources target
# #
# This creates a resources zip file that will be used when building an Android # This creates a resources zip file that will be used when building an Android
......
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