Reland #3 "Android: Refactor stack_unwinder GN targets"

This reverts commit 54424e93a703d05190df6e77517a2e48758c8a61.

Reason for reland: I had inadvertently created a secondary abi
android_assets for libchrome unwind info, which didn't exist before
(only libmonochrome exists for secondary abi), and it turns out
that explicit our jni registration code doesn't work under a
secondary ABI due to using a generated header under
$default_toolcahin, but not having an -I flag telling the compiler
to look under the default toolchain's gen/ directory.

I've stopped creating this asset target, and verified locally that
building all targets doesn't fail.

Original change's description:
> > > > > > Android: Refactor stack_unwinder GN targets
> > > > > >
> > > > > > Generate the unwind file alongside the native library, and put the
> > > > > > android_asset() alongside the apk/bundle templates.
> > > > > >
> > > > > > This will make it easy to move the asset into the stack_unwinder split.
> > > > > >
> > > > > > Bug: 1362495
> > > > > > Change-Id: Ib197d9fe7ec0f9e8047438a4f72336521c42aae4
> > > > > > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3905083
> > > > > > Reviewed-by: Mohamed Heikal <[email protected]>
> > > > > > Commit-Queue: Andrew Grieve <[email protected]>
> > > > > > Cr-Commit-Position: refs/heads/main@{#1049755}
> > > > >
> > > > > Bug: 1362495
> > > > > Change-Id: I30ebde93901d4575d785bd7ec4e813b219868d2e
> > > > > No-Presubmit: true
> > > > > No-Tree-Checks: true
> > > > > No-Try: true
> > > > > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3910392
> > > > > Bot-Commit: Rubber Stamper <[email protected]>
> > > > > Owners-Override: Nina Satragno <[email protected]>
> > > > > Commit-Queue: Nina Satragno <[email protected]>
> > > > > Cr-Commit-Position: refs/heads/main@{#1049804}
> > > >
> > > > Bug: 1362495
> > > > Change-Id: Id7c5a7a807af02816b8d40752d2189f144c575a3
> > > > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3909643
> > > > Commit-Queue: Andrew Grieve <[email protected]>
> > > > Reviewed-by: Mohamed Heikal <[email protected]>
> > > > Cr-Commit-Position: refs/heads/main@{#1050163}

Bug: 1362495, 1367194
Change-Id: I94fd17735d4a2dfb7aa748f0570819b6e219d82a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3916431
Auto-Submit: Andrew Grieve <[email protected]>
Reviewed-by: Mohamed Heikal <[email protected]>
Commit-Queue: Mohamed Heikal <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1050700}
diff --git a/testing/test.gni b/testing/test.gni
index 3331a41..c4199b224 100644
--- a/testing/test.gni
+++ b/testing/test.gni
@@ -252,9 +252,9 @@
         }
       }
     } else {
-      _library_target = "${target_name}__library"
+      _library_target_name = "${target_name}__library"
       _library_crate_name = "${target_name}_library"
-      _apk_target = "${target_name}__apk"
+      _apk_target_name = "${target_name}__apk"
       _apk_specific_vars = [
         "allow_cleartext_traffic",
         "android_manifest",
@@ -275,30 +275,40 @@
         "use_native_activity",
       ]
 
-      _add_unwind_tables_in_apk = defined(invoker.add_unwind_tables_in_apk) &&
-                                  invoker.add_unwind_tables_in_apk
+      _add_unwind_tables_in_apk =
+          defined(invoker.add_unwind_tables_in_apk) &&
+          invoker.add_unwind_tables_in_apk && target_cpu == "arm"
 
       # Adds the unwind tables from unstripped binary as an asset file in the
       # apk, if |add_unwind_tables_in_apk| is specified by the test.
       if (_add_unwind_tables_in_apk) {
+        # TODO(crbug.com/1315603): Remove generation of v1 unwind asset when
+        # `CFIBacktraceAndroid` is replaced with `ChromeUnwinderAndroidV2`.
+        _unwind_table_name = "${_library_target_name}_unwind_v1"
+        unwind_table_v1(_unwind_table_name) {
+          library_target = ":$_library_target_name"
+        }
+
         if (use_android_unwinder_v2) {
-          _unwind_table_asset_v2_name = "${target_name}_v2_unwind_assets"
-          unwind_table_asset_v2(_unwind_table_asset_v2_name) {
-            library_target = _library_target
-            deps = [ ":$_library_target" ]
+          _unwind_table_v2_name = "${_library_target_name}_unwind_v2"
+          unwind_table_v2(_unwind_table_v2_name) {
+            library_target = ":$_library_target_name"
           }
         }
 
-        # TODO(crbug.com/1315603): Remove generation of v1 unwind asset when
-        # `CFIBacktraceAndroid` is replaced with `ChromeUnwinderAndroidV2`.
-        _unwind_table_asset_name = "${target_name}_unwind_assets"
-        unwind_table_asset(_unwind_table_asset_name) {
-          library_target = _library_target
-          deps = [ ":$_library_target" ]
+        _unwind_table_asset_name = "${target_name}__unwind_assets"
+        android_assets(_unwind_table_asset_name) {
+          sources = [ "$target_out_dir/$_unwind_table_name/$unwind_table_asset_v1_filename" ]
+          disable_compression = true
+          deps = [ ":$_unwind_table_name" ]
+          if (use_android_unwinder_v2) {
+            sources += [ "$target_out_dir/$_unwind_table_v2_name/$unwind_table_asset_v2_filename" ]
+            deps += [ ":$_unwind_table_v2_name" ]
+          }
         }
       }
 
-      mixed_test(_library_target) {
+      mixed_test(_library_target_name) {
         target_type = "shared_library"
 
         # Configs will always be defined since we set_defaults in
@@ -338,9 +348,9 @@
           deps += [ "//testing/android/native_test:native_test_native_code" ]
         }
       }
-      unittest_apk(_apk_target) {
+      unittest_apk(_apk_target_name) {
         forward_variables_from(invoker, _apk_specific_vars)
-        shared_library = ":$_library_target"
+        shared_library = ":$_library_target_name"
         apk_name = invoker.target_name
         if (defined(invoker.output_name)) {
           apk_name = invoker.output_name
@@ -365,10 +375,6 @@
           deps += [ ":${_unwind_table_asset_name}" ]
         }
 
-        if (defined(_unwind_table_asset_v2_name)) {
-          deps += [ ":${_unwind_table_asset_v2_name}" ]
-        }
-
         if (use_rts) {
           data_deps = [ ":${invoker.target_name}__rts_filters" ]
         }
@@ -382,12 +388,12 @@
         executable_dist_dir = "$root_out_dir/$_dist_target"
         data_deps = [ ":$_exec_target" ]
       } else {
-        apk_target = ":$_apk_target"
+        apk_target = ":$_apk_target_name"
         incremental_apk = incremental_install
 
         # Dep needed for the test runner .runtime_deps file to pick up data
         # deps from the forward_variables_from(invoker, "*") on the library.
-        data_deps = [ ":$_library_target" ]
+        data_deps = [ ":$_library_target_name" ]
       }
       test_name = _output_name
       test_suite = _output_name
@@ -414,8 +420,8 @@
         # Dep needed for the swarming .isolate file to pick up data
         # deps from the forward_variables_from(invoker, "*") on the library.
         deps += [
-          ":$_apk_target",
-          ":$_library_target",
+          ":$_apk_target_name",
+          ":$_library_target_name",
         ]
       }