extract_symbols.gni 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. if (host_os == "win" && target_cpu == "x86") {
  24. dump_syms_label = "//third_party/breakpad:dump_syms(//build/toolchain/win:win_clang_x64)"
  25. } else {
  26. dump_syms_label = "//third_party/breakpad:dump_syms($host_toolchain)"
  27. }
  28. dump_syms_binary = get_label_info(dump_syms_label, "root_out_dir") +
  29. "/dump_syms$_host_executable_suffix"
  30. script = "//electron/build/dump_syms.py"
  31. inputs = [
  32. invoker.binary,
  33. dump_syms_binary,
  34. ]
  35. stamp_file = "${target_gen_dir}/${target_name}.stamp"
  36. outputs = [ stamp_file ]
  37. args = [
  38. "./" + rebase_path(dump_syms_binary, root_build_dir),
  39. rebase_path(invoker.binary, root_build_dir),
  40. rebase_path(invoker.symbol_dir, root_build_dir),
  41. rebase_path(stamp_file, root_build_dir),
  42. ]
  43. if (defined(invoker.dsym_file)) {
  44. args += [ rebase_path(invoker.dsym_file, root_build_dir) ]
  45. }
  46. if (!defined(deps)) {
  47. deps = []
  48. }
  49. deps += [ dump_syms_label ]
  50. }
  51. }