xref: /aosp_15_r20/external/angle/build/config/android/create_unwind_table.gni (revision 8975f5c5ed3d1c378011245431ada316dfb6f244)
1# Copyright 2021 The Chromium Authors
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5import("//build/config/android/rules.gni")
6
7unwind_table_asset_v2_filename = "unwind_cfi_32_v2"
8
9_dump_syms_target =
10    "//third_party/breakpad:dump_syms($host_system_allocator_toolchain)"
11_dump_syms = get_label_info(_dump_syms_target, "root_out_dir") + "/dump_syms"
12_readobj_path = "$clang_base_path/bin/llvm-readobj"
13
14template("unwind_table_v2") {
15  action(target_name) {
16    forward_variables_from(invoker, TESTONLY_AND_VISIBILITY)
17    _output_path =
18        "$target_out_dir/$target_name/$unwind_table_asset_v2_filename"
19
20    # Strip the "lib" prefix, if present. Add and then remove a space because
21    # our ownly tool is "replace all".
22    _library_name = get_label_info(invoker.library_target, "name")
23    _library_name =
24        string_replace(string_replace(" $_library_name", " $shlib_prefix", ""),
25                       " ",
26                       "")
27    _library_path = "$root_out_dir/lib.unstripped/$shlib_prefix$_library_name$shlib_extension"
28
29    script = "//build/android/gyp/create_unwind_table.py"
30    outputs = [ _output_path ]
31    inputs = [
32      _dump_syms,
33      _library_path,
34    ]
35    deps = [
36      _dump_syms_target,
37      invoker.library_target,
38    ]
39
40    args = [
41      "--input_path",
42      rebase_path(_library_path, root_build_dir),
43      "--output_path",
44      rebase_path(_output_path, root_build_dir),
45      "--dump_syms_path",
46      rebase_path(_dump_syms, root_build_dir),
47      "--readobj_path",
48      rebase_path(_readobj_path, root_build_dir),
49    ]
50  }
51}
52