LevelDB project 1 10225501460 林子骥 10211900416 郭夏辉
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

200 lines
5.8 KiB

1 month ago
  1. # Copyright 2017 Google Inc.
  2. # All Rights Reserved.
  3. #
  4. #
  5. # Redistribution and use in source and binary forms, with or without
  6. # modification, are permitted provided that the following conditions are
  7. # met:
  8. #
  9. # * Redistributions of source code must retain the above copyright
  10. # notice, this list of conditions and the following disclaimer.
  11. # * Redistributions in binary form must reproduce the above
  12. # copyright notice, this list of conditions and the following disclaimer
  13. # in the documentation and/or other materials provided with the
  14. # distribution.
  15. # * Neither the name of Google Inc. nor the names of its
  16. # contributors may be used to endorse or promote products derived from
  17. # this software without specific prior written permission.
  18. #
  19. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  20. # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  21. # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  22. # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  23. # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  24. # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  25. # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  26. # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  27. # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  28. # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  29. # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30. #
  31. # Bazel Build for Google C++ Testing Framework(Google Test)
  32. load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
  33. package(default_visibility = ["//visibility:public"])
  34. licenses(["notice"])
  35. exports_files(["LICENSE"])
  36. config_setting(
  37. name = "windows",
  38. constraint_values = ["@platforms//os:windows"],
  39. )
  40. config_setting(
  41. name = "msvc_compiler",
  42. flag_values = {
  43. "@bazel_tools//tools/cpp:compiler": "msvc-cl",
  44. },
  45. visibility = [":__subpackages__"],
  46. )
  47. config_setting(
  48. name = "has_absl",
  49. values = {"define": "absl=1"},
  50. )
  51. config_setting(
  52. name = "ios",
  53. values = {"apple_platform_type": "ios"},
  54. visibility = [":__subpackages__"],
  55. )
  56. # Library that defines the FRIEND_TEST macro.
  57. cc_library(
  58. name = "gtest_prod",
  59. hdrs = ["googletest/include/gtest/gtest_prod.h"],
  60. includes = ["googletest/include"],
  61. )
  62. # Google Test including Google Mock
  63. cc_library(
  64. name = "gtest",
  65. srcs = glob(
  66. include = [
  67. "googletest/src/*.cc",
  68. "googletest/src/*.h",
  69. "googletest/include/gtest/**/*.h",
  70. "googlemock/src/*.cc",
  71. "googlemock/include/gmock/**/*.h",
  72. ],
  73. exclude = [
  74. "googletest/src/gtest-all.cc",
  75. "googletest/src/gtest_main.cc",
  76. "googlemock/src/gmock-all.cc",
  77. "googlemock/src/gmock_main.cc",
  78. ],
  79. ),
  80. hdrs = glob([
  81. "googletest/include/gtest/*.h",
  82. "googlemock/include/gmock/*.h",
  83. ]),
  84. copts = select({
  85. ":ios": [
  86. "-xobjective-c++",
  87. "-pthread",
  88. ],
  89. ":windows": [],
  90. "//conditions:default": ["-pthread"],
  91. }),
  92. defines = select({
  93. ":has_absl": ["GTEST_HAS_ABSL=1"],
  94. "//conditions:default": [],
  95. }),
  96. features = select({
  97. ":windows": ["windows_export_all_symbols"],
  98. "//conditions:default": [],
  99. }),
  100. includes = [
  101. "googlemock",
  102. "googlemock/include",
  103. "googletest",
  104. "googletest/include",
  105. ],
  106. linkopts = select({
  107. ":windows": [],
  108. "//conditions:default": ["-pthread"],
  109. }),
  110. deps = select({
  111. ":has_absl": [
  112. "@com_google_absl//absl/debugging:failure_signal_handler",
  113. "@com_google_absl//absl/debugging:stacktrace",
  114. "@com_google_absl//absl/debugging:symbolize",
  115. "@com_google_absl//absl/strings",
  116. "@com_google_absl//absl/types:any",
  117. "@com_google_absl//absl/types:optional",
  118. "@com_google_absl//absl/types:variant",
  119. ],
  120. "//conditions:default": [],
  121. }),
  122. )
  123. cc_library(
  124. name = "gtest_main",
  125. srcs = ["googlemock/src/gmock_main.cc"],
  126. features = select({
  127. ":windows": ["windows_export_all_symbols"],
  128. "//conditions:default": [],
  129. }),
  130. deps = [":gtest"],
  131. )
  132. # The following rules build samples of how to use gTest.
  133. cc_library(
  134. name = "gtest_sample_lib",
  135. srcs = [
  136. "googletest/samples/sample1.cc",
  137. "googletest/samples/sample2.cc",
  138. "googletest/samples/sample4.cc",
  139. ],
  140. hdrs = [
  141. "googletest/samples/prime_tables.h",
  142. "googletest/samples/sample1.h",
  143. "googletest/samples/sample2.h",
  144. "googletest/samples/sample3-inl.h",
  145. "googletest/samples/sample4.h",
  146. ],
  147. features = select({
  148. ":windows": ["windows_export_all_symbols"],
  149. "//conditions:default": [],
  150. }),
  151. )
  152. cc_test(
  153. name = "gtest_samples",
  154. size = "small",
  155. # All Samples except:
  156. # sample9 (main)
  157. # sample10 (main and takes a command line option and needs to be separate)
  158. srcs = [
  159. "googletest/samples/sample1_unittest.cc",
  160. "googletest/samples/sample2_unittest.cc",
  161. "googletest/samples/sample3_unittest.cc",
  162. "googletest/samples/sample4_unittest.cc",
  163. "googletest/samples/sample5_unittest.cc",
  164. "googletest/samples/sample6_unittest.cc",
  165. "googletest/samples/sample7_unittest.cc",
  166. "googletest/samples/sample8_unittest.cc",
  167. ],
  168. linkstatic = 0,
  169. deps = [
  170. "gtest_sample_lib",
  171. ":gtest_main",
  172. ],
  173. )
  174. cc_test(
  175. name = "sample9_unittest",
  176. size = "small",
  177. srcs = ["googletest/samples/sample9_unittest.cc"],
  178. deps = [":gtest"],
  179. )
  180. cc_test(
  181. name = "sample10_unittest",
  182. size = "small",
  183. srcs = ["googletest/samples/sample10_unittest.cc"],
  184. deps = [":gtest"],
  185. )