| Index: build/config/android/rules.gni
|
| diff --git a/build/config/android/rules.gni b/build/config/android/rules.gni
|
| index ac6fe5aaff2b78637c24a0aacf53a152fb7e6fad..2db732acd73d9a99c40ac406266a22ce14444fac 100644
|
| --- a/build/config/android/rules.gni
|
| +++ b/build/config/android/rules.gni
|
| @@ -2,13 +2,14 @@
|
| # Use of this source code is governed by a BSD-style license that can be
|
| # found in the LICENSE file.
|
|
|
| +import("//base/android/linker/config.gni")
|
| import("//build/config/android/config.gni")
|
| import("//build/config/android/internal_rules.gni")
|
| import("//tools/grit/grit_rule.gni")
|
| +import("//tools/relocation_packer/config.gni")
|
|
|
| assert(is_android)
|
|
|
| -
|
| # Declare a jni target
|
| #
|
| # This target generates the native jni bindings for a set of .java files.
|
| @@ -186,6 +187,9 @@ template("generate_jar_jni") {
|
|
|
| # Declare a target for c-preprocessor-generated java files
|
| #
|
| +# NOTE: For generating Java conterparts to enums prefer using the java_cpp_enum
|
| +# rule instead.
|
| +#
|
| # This target generates java files using the host C pre-processor. Each file in
|
| # sources will be compiled using the C pre-processor. If include_path is
|
| # specified, it will be passed (with --I) to the pre-processor.
|
| @@ -732,6 +736,68 @@ template("android_library") {
|
| }
|
| }
|
|
|
| +template("java_library") {
|
| + if (defined(invoker.testonly)) { testonly = invoker.testonly }
|
| +
|
| + assert(defined(invoker.java_files) || defined(invoker.DEPRECATED_java_in_dir)
|
| + || defined(invoker.srcjars))
|
| +
|
| + _srcjar_deps = []
|
| + if (defined(invoker.srcjar_deps)) {
|
| + _srcjar_deps = invoker.srcjar_deps
|
| + }
|
| +
|
| + _srcjars = []
|
| + if (defined(invoker.srcjars)) {
|
| + _srcjars = invoker.srcjars
|
| + }
|
| +
|
| + _java_files = []
|
| + if (defined(invoker.java_files)) {
|
| + _java_files = invoker.java_files
|
| + } else if (defined(invoker.DEPRECATED_java_in_dir)) {
|
| + _src_dir = invoker.DEPRECATED_java_in_dir + "/src"
|
| + _src_dir_exists = exec_script("//build/dir_exists.py",
|
| + [ rebase_path(_src_dir, root_build_dir) ],
|
| + "string")
|
| + assert(_src_dir_exists == "False",
|
| + "In GN, java_in_dir should be the fully specified java directory " +
|
| + "(i.e. including the trailing \"/src\")")
|
| +
|
| + _java_files_build_rel = exec_script(
|
| + "//build/android/gyp/find.py",
|
| + [
|
| + "--pattern",
|
| + "*.java",
|
| + rebase_path(invoker.DEPRECATED_java_in_dir, root_build_dir)
|
| + ],
|
| + "list lines"
|
| + )
|
| + _java_files = rebase_path(_java_files_build_rel, ".", root_build_dir)
|
| + }
|
| + assert(_java_files != [] || _srcjar_deps != [] || _srcjars != [])
|
| +
|
| + # TODO(cjhopman): Write a proper build config so that java library
|
| + # dependencies work correctly.
|
| + _build_config = "$target_gen_dir/$target_name.build_config"
|
| + write_file(
|
| + _build_config,
|
| + "{ \"javac\": { \"classpath\": [], \"srcjars\": [] } }")
|
| +
|
| + _jar_path = "$root_build_dir/lib.java/$target_name.jar"
|
| + if (defined(invoker.jar_path)) {
|
| + _jar_path = invoker.jar_path
|
| + }
|
| +
|
| + compile_java(target_name) {
|
| + build_config = _build_config
|
| + jar_path = _jar_path
|
| + java_files = _java_files
|
| + srcjar_deps = _srcjar_deps
|
| + srcjars = _srcjars
|
| + }
|
| +}
|
| +
|
|
|
| # Declare an Android library target for a prebuilt jar
|
| #
|
| @@ -875,17 +941,44 @@ template("android_apk") {
|
| _dist_jar_path = _dist_jar_path_list[0]
|
|
|
| _native_libs = []
|
| +
|
| + _keystore_path = android_default_keystore_path
|
| + _keystore_name = android_default_keystore_name
|
| + _keystore_password = android_default_keystore_password
|
| +
|
| + if (defined(invoker.keystore_path)) {
|
| + _keystore_path = invoker.keystore_path
|
| + _keystore_name = invoker.keystore_name
|
| + _keystore_password = invoker.keystore_password
|
| + }
|
| +
|
| + _srcjar_deps = []
|
| + if (defined(invoker.srcjar_deps)) {
|
| + _srcjar_deps += invoker.srcjar_deps
|
| + }
|
| +
|
| + _load_library_from_apk = false
|
| +
|
| if (defined(invoker.native_libs)) {
|
| _use_chromium_linker = false
|
| if (defined(invoker.use_chromium_linker)) {
|
| - _use_chromium_linker = invoker.use_chromium_linker
|
| + _use_chromium_linker = (invoker.use_chromium_linker &&
|
| + chromium_linker_supported)
|
| + }
|
| +
|
| + if (defined(invoker.load_library_from_apk) &&
|
| + invoker.load_library_from_apk) {
|
| + _load_library_from_apk = true
|
| + assert(_use_chromium_linker, "Loading library from the apk requires use" +
|
| + " of the Chromium linker.")
|
| }
|
|
|
| - # TODO(GYP) add "|| profiling_full_stack_frames
|
| - # Only enable the chromium linker on regular builds, since the
|
| - # component build crashes on Android 4.4. See b/11379966
|
| - if (is_component_build || cpu_arch == "arm64" || cpu_arch == "x64") {
|
| - _use_chromium_linker = false
|
| + _enable_relocation_packing = false
|
| + if (defined(invoker.enable_relocation_packing) &&
|
| + invoker.enable_relocation_packing) {
|
| + _enable_relocation_packing = relocation_packing_supported
|
| + assert(_use_chromium_linker, "Relocation packing requires use of the" +
|
| + " Chromium linker.")
|
| }
|
|
|
| _native_libs = invoker.native_libs
|
| @@ -898,21 +991,6 @@ template("android_apk") {
|
| }
|
| }
|
|
|
| - _keystore_path = android_default_keystore_path
|
| - _keystore_name = android_default_keystore_name
|
| - _keystore_password = android_default_keystore_password
|
| -
|
| - if (defined(invoker.keystore_path)) {
|
| - _keystore_path = invoker.keystore_path
|
| - _keystore_name = invoker.keystore_name
|
| - _keystore_password = invoker.keystore_password
|
| - }
|
| -
|
| - _srcjar_deps = []
|
| - if (defined(invoker.srcjar_deps)) {
|
| - _srcjar_deps += invoker.srcjar_deps
|
| - }
|
| -
|
| _rebased_build_config = rebase_path(build_config, root_build_dir)
|
|
|
| write_build_config("${_template_name}__build_config") {
|
| @@ -945,7 +1023,6 @@ template("android_apk") {
|
| _enable_chromium_linker_tests = invoker.enable_chromium_linker_tests
|
| }
|
|
|
| - _load_library_from_apk = false
|
| _native_lib_version_name = ""
|
|
|
| java_cpp_template("${_template_name}__native_libraries_java") {
|
| @@ -1025,19 +1102,48 @@ template("android_apk") {
|
| }
|
|
|
| if (_native_libs != []) {
|
| - copy_ex("${_template_name}__prepare_native") {
|
| - clear_dir = true
|
| + action("${_template_name}__prepare_native") {
|
| + script = "//build/android/gyp/pack_arm_relocations.py"
|
| + packed_libraries_dir = "$_native_libs_dir/$android_app_abi"
|
| + depfile = "$target_gen_dir/$target_name.d"
|
| + outputs = [
|
| + depfile
|
| + ]
|
| inputs = [
|
| build_config
|
| ]
|
| - dest = "$_native_libs_dir/$android_app_abi"
|
| + deps = []
|
| + skip_packing_list = [
|
| + "gdbserver",
|
| + "libchromium_android_linker.so",
|
| + ]
|
| +
|
| + enable_packing_arg = 0
|
| + if (_enable_relocation_packing) {
|
| + enable_packing_arg = 1
|
| + deps += [
|
| + relocation_packer_target
|
| + ]
|
| + }
|
| +
|
| args = [
|
| - "--files=@FileArg(${_rebased_build_config}:native:libraries)",
|
| + "--depfile", rebase_path(depfile, root_build_dir),
|
| + "--enable-packing=$enable_packing_arg",
|
| + "--has-relocations-with-addends=$relocations_have_addends",
|
| + "--exclude-packing-list=$skip_packing_list",
|
| + "--android-pack-relocations", rebase_path(relocation_packer_exe, root_build_dir),
|
| + "--android-objcopy", rebase_path(android_objcopy, root_build_dir),
|
| + "--stripped-libraries-dir", rebase_path(root_build_dir, root_build_dir),
|
| + "--packed-libraries-dir", rebase_path(packed_libraries_dir, root_build_dir),
|
| + "--libraries=@FileArg(${_rebased_build_config}:native:libraries)",
|
| + "--clear-dir"
|
| ]
|
| +
|
| if (is_debug) {
|
| - rebased_gdbserver = rebase_path(android_gdbserver, root_build_dir)
|
| + rebased_gdbserver = rebase_path([ android_gdbserver ], root_build_dir)
|
| + inputs += [ android_gdbserver ]
|
| args += [
|
| - "--files=[\"$rebased_gdbserver\"]"
|
| + "--libraries=$rebased_gdbserver"
|
| ]
|
| }
|
| }
|
| @@ -1049,6 +1155,7 @@ template("android_apk") {
|
| android_manifest = invoker.android_manifest
|
| resources_zip = all_resources_zip_path
|
| dex_path = final_dex_path
|
| + load_library_from_apk = _load_library_from_apk
|
|
|
| if (defined(invoker.asset_location)) {
|
| asset_location = invoker.asset_location
|
|
|