extract_symbols.gni 1.6 KB

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