extract_symbols.gni 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import("//build/toolchain/toolchain.gni")
  2. # Extracts symbols from a binary into a symbol file using dump_syms.
  3. #
  4. # Args:
  5. # binary: Path to the binary containing symbols to extract, e.g.:
  6. # "$root_out_dir/electron"
  7. # symbol_dir: Desired output directory for symbols, e.g.:
  8. # "$root_out_dir/breakpad_symbols"
  9. if (host_os == "win") {
  10. _host_executable_suffix = ".exe"
  11. } else {
  12. _host_executable_suffix = ""
  13. }
  14. template("extract_symbols") {
  15. action(target_name) {
  16. forward_variables_from(invoker,
  17. [
  18. "deps",
  19. "testonly",
  20. ])
  21. assert(defined(invoker.binary), "Need binary to dump")
  22. assert(defined(invoker.symbol_dir), "Need directory for symbol output")
  23. dump_syms_label =
  24. "//third_party/breakpad:dump_syms($host_system_allocator_toolchain)"
  25. dump_syms_binary = get_label_info(dump_syms_label, "root_out_dir") +
  26. "/dump_syms$_host_executable_suffix"
  27. script = "//electron/build/dump_syms.py"
  28. inputs = [
  29. invoker.binary,
  30. dump_syms_binary,
  31. ]
  32. stamp_file = "${target_gen_dir}/${target_name}.stamp"
  33. outputs = [ stamp_file ]
  34. args = [
  35. "./" + rebase_path(dump_syms_binary, root_build_dir),
  36. rebase_path(invoker.binary, root_build_dir),
  37. rebase_path(invoker.symbol_dir, root_build_dir),
  38. rebase_path(stamp_file, root_build_dir),
  39. ]
  40. if (defined(invoker.dsym_file)) {
  41. args += [ rebase_path(invoker.dsym_file, root_build_dir) ]
  42. }
  43. if (!defined(deps)) {
  44. deps = []
  45. }
  46. deps += [ dump_syms_label ]
  47. }
  48. }