BUILD.bazel 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. # Tool for listening on Bazel actions and generate compile commands database.
  2. #
  3. # Using Bazel aspect to generate compile commands would be faster. Also Bazel
  4. # action listeners are deprecated. We can switch to that if a stable solution
  5. # exists, e.g. https://github.com/grailbio/bazel-compilation-database
  6. cc_binary(
  7. name = "extract_compile_command",
  8. srcs = ["extract_compile_command.cc"],
  9. # Build fails on Windows, and not part of Ray either.
  10. tags = ["manual"],
  11. deps = [
  12. "//:extra_actions_cc_proto_lib",
  13. "@com_google_protobuf//:protobuf",
  14. "@rapidjson",
  15. ],
  16. )
  17. action_listener(
  18. name = "compile_command_listener",
  19. extra_actions = [":compile_command_action"],
  20. mnemonics = ["CppCompile"],
  21. )
  22. extra_action(
  23. name = "compile_command_action",
  24. cmd = "$(location :extract_compile_command) \
  25. $(EXTRA_ACTION_FILE) \
  26. $(output $(ACTION_ID).compile_command.json)",
  27. out_templates = ["$(ACTION_ID).compile_command.json"],
  28. tools = [":extract_compile_command"],
  29. )