forked from pytorch/executorch
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgtest_defs.bzl
More file actions
163 lines (152 loc) · 6.69 KB
/
Copy pathgtest_defs.bzl
File metadata and controls
163 lines (152 loc) · 6.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "get_aten_mode_options")
# Copied from fbsource/third-party/googletest
COMPILER_FLAGS = [
"-std=c++17",
]
COMPILER_FLAGS_ATEN = []
# define_gtest_targets
def define_gtest_targets():
# Library that defines the FRIEND_TEST macro.
# @lint-ignore BUCKLINT: native and fb_native are explicitly forbidden in fbcode.
native.cxx_library(
name = "gtest_prod",
public_system_include_directories = ["googletest/googletest/include"],
raw_headers = ["googletest/googletest/include/gtest/gtest_prod.h"],
visibility = ["PUBLIC"],
)
for aten_mode in get_aten_mode_options():
aten_suffix = "_aten" if aten_mode else ""
# # Google Test
# @lint-ignore BUCKLINT: native and fb_native are explicitly forbidden in fbcode.
native.cxx_library(
name = "gtest" + aten_suffix,
srcs = native.glob(
[
"googletest/googletest/src/*.cc",
],
exclude = [
"googletest/googletest/src/gtest-all.cc",
"googletest/googletest/src/gtest_main.cc",
],
),
include_directories = [
"googletest/googletest",
],
public_system_include_directories = [
"googletest/googletest/include",
],
raw_headers = native.glob([
"googletest/googletest/include/gtest/**/*.h",
"googletest/googletest/src/*.h",
]),
visibility = ["PUBLIC"],
compiler_flags = COMPILER_FLAGS_ATEN if aten_mode else COMPILER_FLAGS,
# TODO: gtest crashes after the test finishes when pthread is used, the root
# cause is unclear. So it's turned off here for now. The error is as follows:
# googletest/include/gtest/internal/gtest-port.h:1771:: pthread_key_delete(key_)failed with error 22
exported_preprocessor_flags = ["-DGTEST_HAS_PTHREAD=0"],
)
# @lint-ignore BUCKLINT: native and fb_native are explicitly forbidden in fbcode.
native.cxx_library(
name = "gmock" + aten_suffix,
srcs = native.glob(
[
"googletest/googlemock/src/*.cc",
],
exclude = [
"googletest/googlemock/src/gmock-all.cc",
"googletest/googlemock/src/gmock_main.cc",
],
),
include_directories = [
"googletest/googletest",
],
public_system_include_directories = [
"googletest/googlemock/include",
],
raw_headers = native.glob([
"googletest/googlemock/include/gmock/**/*.h",
]),
exported_deps = [":gtest" + aten_suffix],
visibility = ["PUBLIC"],
compiler_flags = COMPILER_FLAGS_ATEN if aten_mode else COMPILER_FLAGS,
)
# @lint-ignore BUCKLINT: native and fb_native are explicitly forbidden in fbcode.
native.cxx_library(
name = "gtest_headers" + aten_suffix,
include_directories = [
"googletest/googletest",
],
public_system_include_directories = [
"googletest/googlemock/include",
"googletest/googletest/include",
],
raw_headers = native.glob([
"googletest/googlemock/include/gmock/**/*.h",
"googletest/googletest/include/gtest/**/*.h",
"googletest/googletest/src/*.h",
]),
visibility = ["PUBLIC"],
compiler_flags = COMPILER_FLAGS_ATEN if aten_mode else COMPILER_FLAGS,
)
# @lint-ignore BUCKLINT: native and fb_native are explicitly forbidden in fbcode.
native.cxx_library(
name = "gtest_main" + aten_suffix,
srcs = ["googletest/googletest/src/gtest_main.cc"],
visibility = ["PUBLIC"],
exported_deps = [":gtest" + aten_suffix],
compiler_flags = COMPILER_FLAGS_ATEN if aten_mode else COMPILER_FLAGS,
)
# # The following rules build samples of how to use gTest.
# @lint-ignore BUCKLINT: native and fb_native are explicitly forbidden in fbcode.
native.cxx_library(
name = "gtest_sample_lib" + aten_suffix,
srcs = [
"googletest/googletest/samples/sample1.cc",
"googletest/googletest/samples/sample2.cc",
"googletest/googletest/samples/sample4.cc",
],
public_system_include_directories = [
"googletest/googletest/samples",
],
raw_headers = [
"googletest/googletest/samples/prime_tables.h",
"googletest/googletest/samples/sample1.h",
"googletest/googletest/samples/sample2.h",
"googletest/googletest/samples/sample3-inl.h",
"googletest/googletest/samples/sample4.h",
],
)
# @lint-ignore BUCKLINT: native and fb_native are explicitly forbidden in fbcode.
native.cxx_library(
name = "gtest_samples" + aten_suffix,
# All Samples except:
# sample9 (main)
# sample10 (main and takes a command line option and needs to be separate)
srcs = [
"googletest/googletest/samples/sample1_unittest.cc",
"googletest/googletest/samples/sample2_unittest.cc",
"googletest/googletest/samples/sample3_unittest.cc",
"googletest/googletest/samples/sample4_unittest.cc",
"googletest/googletest/samples/sample5_unittest.cc",
"googletest/googletest/samples/sample6_unittest.cc",
"googletest/googletest/samples/sample7_unittest.cc",
"googletest/googletest/samples/sample8_unittest.cc",
],
deps = [
":gtest_main" + aten_suffix,
":gtest_sample_lib" + aten_suffix,
],
)
# @lint-ignore BUCKLINT: native and fb_native are explicitly forbidden in fbcode.
native.cxx_library(
name = "sample9_unittest" + aten_suffix,
srcs = ["googletest/googletest/samples/sample9_unittest.cc"],
deps = [":gtest" + aten_suffix],
)
# @lint-ignore BUCKLINT: native and fb_native are explicitly forbidden in fbcode.
native.cxx_library(
name = "sample10_unittest" + aten_suffix,
srcs = ["googletest/googletest/samples/sample10_unittest.cc"],
deps = [":gtest" + aten_suffix],
)