BUILD 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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("@rules_cc//cc: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 = "source_gen_lib",
  45. testonly = 1,
  46. srcs = ["source_gen.cpp"],
  47. hdrs = ["source_gen.h"],
  48. deps = [
  49. "//common:check",
  50. "//common:map",
  51. "//common:raw_string_ostream",
  52. "//common:set",
  53. "//toolchain/lex:token_kind",
  54. "@abseil-cpp//absl/random",
  55. "@llvm-project//llvm:Support",
  56. ],
  57. )
  58. cc_test(
  59. name = "source_gen_test",
  60. size = "small",
  61. srcs = ["source_gen_test.cpp"],
  62. deps = [
  63. ":global_exe_path",
  64. ":gtest_main",
  65. ":source_gen_lib",
  66. "//common:set",
  67. "//toolchain/driver",
  68. "//toolchain/install:install_paths_test_helpers",
  69. "@googletest//:gtest",
  70. "@llvm-project//llvm:Support",
  71. ],
  72. )
  73. cc_binary(
  74. name = "source_gen",
  75. testonly = 1,
  76. srcs = ["source_gen_main.cpp"],
  77. deps = [
  78. ":source_gen_lib",
  79. "//common:bazel_working_dir",
  80. "//common:command_line",
  81. "//common:init_llvm",
  82. "//common:ostream",
  83. "@llvm-project//llvm:Support",
  84. ],
  85. )
  86. cc_library(
  87. name = "global_exe_path",
  88. testonly = 1,
  89. srcs = ["global_exe_path.cpp"],
  90. hdrs = ["global_exe_path.h"],
  91. deps = [
  92. "//common:check",
  93. "//common:exe_path",
  94. "@llvm-project//llvm:Support",
  95. ],
  96. )
  97. cc_test(
  98. name = "global_exe_path_test",
  99. size = "small",
  100. srcs = ["global_exe_path_test.cpp"],
  101. deps = [
  102. ":global_exe_path",
  103. ":gtest_main",
  104. "@googletest//:gtest",
  105. "@llvm-project//llvm:Support",
  106. ],
  107. )