|
| 1 | +# Copied from fbsource/third-party/googletest |
| 2 | + |
| 3 | +COMPILER_FLAGS = [ |
| 4 | + "-std=c++17", |
| 5 | +] |
| 6 | + |
| 7 | +# define_gtest_targets |
| 8 | +def define_gtest_targets(): |
| 9 | + # Library that defines the FRIEND_TEST macro. |
| 10 | + # @lint-ignore BUCKLINT: native and fb_native are explicitly forbidden in fbcode. |
| 11 | + native.cxx_library( |
| 12 | + name = "gtest_prod", |
| 13 | + public_system_include_directories = ["googletest/googletest/include"], |
| 14 | + raw_headers = ["googletest/googletest/include/gtest/gtest_prod.h"], |
| 15 | + visibility = ["PUBLIC"], |
| 16 | + ) |
| 17 | + |
| 18 | + # # Google Test |
| 19 | + # @lint-ignore BUCKLINT: native and fb_native are explicitly forbidden in fbcode. |
| 20 | + native.cxx_library( |
| 21 | + name = "gtest", |
| 22 | + srcs = native.glob( |
| 23 | + [ |
| 24 | + "googletest/googletest/src/*.cc", |
| 25 | + ], |
| 26 | + exclude = [ |
| 27 | + "googletest/googletest/src/gtest-all.cc", |
| 28 | + "googletest/googletest/src/gtest_main.cc", |
| 29 | + ], |
| 30 | + ), |
| 31 | + include_directories = [ |
| 32 | + "googletest/googletest", |
| 33 | + ], |
| 34 | + public_system_include_directories = [ |
| 35 | + "googletest/googletest/include", |
| 36 | + ], |
| 37 | + raw_headers = native.glob([ |
| 38 | + "googletest/googletest/include/gtest/**/*.h", |
| 39 | + "googletest/googletest/src/*.h", |
| 40 | + ]), |
| 41 | + visibility = ["PUBLIC"], |
| 42 | + compiler_flags = COMPILER_FLAGS, |
| 43 | + ) |
| 44 | + |
| 45 | + # @lint-ignore BUCKLINT: native and fb_native are explicitly forbidden in fbcode. |
| 46 | + native.cxx_library( |
| 47 | + name = "gmock", |
| 48 | + srcs = native.glob( |
| 49 | + [ |
| 50 | + "googletest/googlemock/src/*.cc", |
| 51 | + ], |
| 52 | + exclude = [ |
| 53 | + "googletest/googlemock/src/gmock-all.cc", |
| 54 | + "googletest/googlemock/src/gmock_main.cc", |
| 55 | + ], |
| 56 | + ), |
| 57 | + include_directories = [ |
| 58 | + "googletest/googletest", |
| 59 | + ], |
| 60 | + public_system_include_directories = [ |
| 61 | + "googletest/googlemock/include", |
| 62 | + ], |
| 63 | + raw_headers = native.glob([ |
| 64 | + "googletest/googlemock/include/gmock/**/*.h", |
| 65 | + ]), |
| 66 | + exported_deps = [":gtest"], |
| 67 | + visibility = ["PUBLIC"], |
| 68 | + compiler_flags = COMPILER_FLAGS, |
| 69 | + ) |
| 70 | + |
| 71 | + # @lint-ignore BUCKLINT: native and fb_native are explicitly forbidden in fbcode. |
| 72 | + native.cxx_library( |
| 73 | + name = "gtest_headers", |
| 74 | + include_directories = [ |
| 75 | + "googletest/googletest", |
| 76 | + ], |
| 77 | + public_system_include_directories = [ |
| 78 | + "googletest/googlemock/include", |
| 79 | + "googletest/googletest/include", |
| 80 | + ], |
| 81 | + raw_headers = native.glob([ |
| 82 | + "googletest/googlemock/include/gmock/**/*.h", |
| 83 | + "googletest/googletest/include/gtest/**/*.h", |
| 84 | + "googletest/googletest/src/*.h", |
| 85 | + ]), |
| 86 | + visibility = ["PUBLIC"], |
| 87 | + compiler_flags = COMPILER_FLAGS, |
| 88 | + ) |
| 89 | + |
| 90 | + # @lint-ignore BUCKLINT: native and fb_native are explicitly forbidden in fbcode. |
| 91 | + native.cxx_library( |
| 92 | + name = "gtest_main", |
| 93 | + srcs = ["googletest/googletest/src/gtest_main.cc"], |
| 94 | + visibility = ["PUBLIC"], |
| 95 | + exported_deps = [":gtest"], |
| 96 | + compiler_flags = COMPILER_FLAGS, |
| 97 | + ) |
| 98 | + |
| 99 | + # # The following rules build samples of how to use gTest. |
| 100 | + # @lint-ignore BUCKLINT: native and fb_native are explicitly forbidden in fbcode. |
| 101 | + native.cxx_library( |
| 102 | + name = "gtest_sample_lib", |
| 103 | + srcs = [ |
| 104 | + "googletest/googletest/samples/sample1.cc", |
| 105 | + "googletest/googletest/samples/sample2.cc", |
| 106 | + "googletest/googletest/samples/sample4.cc", |
| 107 | + ], |
| 108 | + public_system_include_directories = [ |
| 109 | + "googletest/googletest/samples", |
| 110 | + ], |
| 111 | + raw_headers = [ |
| 112 | + "googletest/googletest/samples/prime_tables.h", |
| 113 | + "googletest/googletest/samples/sample1.h", |
| 114 | + "googletest/googletest/samples/sample2.h", |
| 115 | + "googletest/googletest/samples/sample3-inl.h", |
| 116 | + "googletest/googletest/samples/sample4.h", |
| 117 | + ], |
| 118 | + ) |
| 119 | + |
| 120 | + # @lint-ignore BUCKLINT: native and fb_native are explicitly forbidden in fbcode. |
| 121 | + native.cxx_library( |
| 122 | + name = "gtest_samples", |
| 123 | + # All Samples except: |
| 124 | + # sample9 (main) |
| 125 | + # sample10 (main and takes a command line option and needs to be separate) |
| 126 | + srcs = [ |
| 127 | + "googletest/googletest/samples/sample1_unittest.cc", |
| 128 | + "googletest/googletest/samples/sample2_unittest.cc", |
| 129 | + "googletest/googletest/samples/sample3_unittest.cc", |
| 130 | + "googletest/googletest/samples/sample4_unittest.cc", |
| 131 | + "googletest/googletest/samples/sample5_unittest.cc", |
| 132 | + "googletest/googletest/samples/sample6_unittest.cc", |
| 133 | + "googletest/googletest/samples/sample7_unittest.cc", |
| 134 | + "googletest/googletest/samples/sample8_unittest.cc", |
| 135 | + ], |
| 136 | + deps = [ |
| 137 | + ":gtest_main", |
| 138 | + ":gtest_sample_lib", |
| 139 | + ], |
| 140 | + ) |
| 141 | + |
| 142 | + # @lint-ignore BUCKLINT: native and fb_native are explicitly forbidden in fbcode. |
| 143 | + native.cxx_library( |
| 144 | + name = "sample9_unittest", |
| 145 | + srcs = ["googletest/googletest/samples/sample9_unittest.cc"], |
| 146 | + deps = [":gtest"], |
| 147 | + ) |
| 148 | + |
| 149 | + # @lint-ignore BUCKLINT: native and fb_native are explicitly forbidden in fbcode. |
| 150 | + native.cxx_library( |
| 151 | + name = "sample10_unittest", |
| 152 | + srcs = ["googletest/googletest/samples/sample10_unittest.cc"], |
| 153 | + deps = [":gtest"], |
| 154 | + ) |
0 commit comments