BUILD 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. # Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. # Exceptions. See /LICENSE for license information.
  3. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. #
  5. # Trivial, single-file testing libraries. More complex libraries should get
  6. # their own directory.
  7. load("//bazel/cc_rules:defs.bzl", "cc_binary", "cc_library", "cc_test")
  8. package(default_visibility = ["//visibility:public"])
  9. # This does extra initialization on top of googletest's gtest_main in order to
  10. # provide stack traces on unexpected exits, because we normally rely on LLVM
  11. # code for that.
  12. #
  13. # This replaces "@googletest//:gtest_main";
  14. # "@googletest//:gtest" should still be used directly.
  15. cc_library(
  16. name = "gtest_main",
  17. testonly = 1,
  18. srcs = ["gtest_main.cpp"],
  19. deps = [
  20. ":global_exe_path",
  21. "//common:init_llvm",
  22. "@googletest//:gtest",
  23. "@llvm-project//llvm:Support",
  24. ],
  25. )
  26. # This does extra initialization on top of Google benchmark's main in order to
  27. # provide stack traces and setup LLVM.
  28. #
  29. # This replaces `@google_benchmark//:benchmark_main`;
  30. # `@google_benchmark//:benchmark` should still be used directly.
  31. cc_library(
  32. name = "benchmark_main",
  33. testonly = 1,
  34. srcs = ["benchmark_main.cpp"],
  35. deps = [
  36. ":global_exe_path",
  37. "//common:init_llvm",
  38. "@abseil-cpp//absl/flags:parse",
  39. "@google_benchmark//:benchmark",
  40. "@llvm-project//llvm:Support",
  41. ],
  42. )
  43. cc_library(
  44. name = "capture_std_streams",
  45. testonly = 1,
  46. srcs = ["capture_std_streams.cpp"],
  47. hdrs = ["capture_std_streams.h"],
  48. deps = [
  49. "//common:ostream",
  50. "@googletest//:gtest",
  51. ],
  52. )
  53. cc_library(
  54. name = "source_gen_lib",
  55. testonly = 1,
  56. srcs = ["source_gen.cpp"],
  57. hdrs = ["source_gen.h"],
  58. deps = [
  59. "//common:check",
  60. "//common:map",
  61. "//common:raw_string_ostream",
  62. "//common:set",
  63. "//toolchain/lex:token_kind",
  64. "@abseil-cpp//absl/random",
  65. "@llvm-project//llvm:Support",
  66. ],
  67. )
  68. cc_test(
  69. name = "source_gen_test",
  70. size = "small",
  71. srcs = ["source_gen_test.cpp"],
  72. deps = [
  73. ":global_exe_path",
  74. ":gtest_main",
  75. ":source_gen_lib",
  76. "//common:all_llvm_targets",
  77. "//common:set",
  78. "//toolchain/driver",
  79. "//toolchain/install:install_paths_test_helpers",
  80. "@googletest//:gtest",
  81. "@llvm-project//llvm:Support",
  82. ],
  83. )
  84. cc_binary(
  85. name = "source_gen",
  86. testonly = 1,
  87. srcs = ["source_gen_main.cpp"],
  88. deps = [
  89. ":source_gen_lib",
  90. "//common:bazel_working_dir",
  91. "//common:command_line",
  92. "//common:init_llvm",
  93. "//common:ostream",
  94. "@llvm-project//llvm:Support",
  95. ],
  96. )
  97. cc_library(
  98. name = "file_helpers",
  99. testonly = 1,
  100. srcs = ["file_helpers.cpp"],
  101. hdrs = ["file_helpers.h"],
  102. deps = [
  103. "//common:error",
  104. "@googletest//:gtest",
  105. ],
  106. )
  107. cc_library(
  108. name = "global_exe_path",
  109. testonly = 1,
  110. srcs = ["global_exe_path.cpp"],
  111. hdrs = ["global_exe_path.h"],
  112. deps = [
  113. "//common:check",
  114. "//common:exe_path",
  115. "@llvm-project//llvm:Support",
  116. ],
  117. )
  118. cc_test(
  119. name = "global_exe_path_test",
  120. size = "small",
  121. srcs = ["global_exe_path_test.cpp"],
  122. deps = [
  123. ":global_exe_path",
  124. ":gtest_main",
  125. "@googletest//:gtest",
  126. "@llvm-project//llvm:Support",
  127. ],
  128. )