blob: ea05c0bdd68c9148233da9525c83c0b4e192bf89 [file] [log] [blame]
Austin Schuhf9724442018-10-28 20:30:21 -07001load("@com_google_protobuf//:protobuf.bzl", "cc_proto_library")
Alex Perry0d0aae32022-02-09 21:10:17 -08002load("@com_github_google_flatbuffers//:build_defs.bzl", "flatbuffer_go_library", "flatbuffer_py_library")
Philipp Schrader37fdbb62021-12-18 00:30:37 -08003load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
Philipp Schraderd0e33a42022-01-22 21:55:15 -08004load("//tools/build_rules:apache.bzl", "apache_wrapper")
Ravago Jones16809802021-11-18 20:40:03 -08005load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_library", "rust_test")
Philipp Schrader54047962022-02-16 21:05:11 -08006load("@npm//@bazel/typescript:index.bzl", "ts_library")
7load("@npm//@bazel/concatjs:index.bzl", "karma_web_test_suite")
Brian Silvermanc270a4d2022-07-23 16:08:06 -07008load("//tools/build_rules:autocxx.bzl", "autocxx_library")
James Kuszmaul27da8142019-07-21 16:13:55 -07009
Brian Silvermanfbe79b82015-09-12 15:10:54 -040010cc_test(
Austin Schuhf9724442018-10-28 20:30:21 -070011 name = "gflags_build_test",
12 size = "small",
13 srcs = [
14 "gflags.cc",
15 ],
Philipp Schraderdada1072020-11-24 11:34:46 -080016 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhf9724442018-10-28 20:30:21 -070017 deps = [
Brian Silverman16a923c2018-10-31 19:40:51 -070018 "@com_github_gflags_gflags//:gflags",
Austin Schuhf9724442018-10-28 20:30:21 -070019 ],
Brian Silvermanfbe79b82015-09-12 15:10:54 -040020)
Brian Silvermanb67da232015-09-12 23:50:30 -040021
Brian Silverman516ceb22015-11-27 01:29:05 -050022cc_binary(
Austin Schuhf9724442018-10-28 20:30:21 -070023 name = "tcmalloc_build_test_binary",
24 srcs = [
25 "tcmalloc.cc",
26 ],
Philipp Schraderdada1072020-11-24 11:34:46 -080027 target_compatible_with = ["@platforms//os:linux"],
Brian Silverman516ceb22015-11-27 01:29:05 -050028)
29
30sh_test(
Austin Schuhf9724442018-10-28 20:30:21 -070031 name = "tcmalloc_build_test",
32 size = "small",
33 srcs = [
34 "tcmalloc_test.sh",
35 ],
36 data = [
37 ":tcmalloc_build_test_binary",
38 ],
Philipp Schraderdada1072020-11-24 11:34:46 -080039 target_compatible_with = ["@platforms//os:linux"],
Brian Silverman516ceb22015-11-27 01:29:05 -050040)
Brian Silvermaneb16fa42016-02-20 15:29:56 -050041
Austin Schuhf9724442018-10-28 20:30:21 -070042cc_proto_library(
43 name = "proto_build_test_library",
44 srcs = ["proto.proto"],
Philipp Schraderdada1072020-11-24 11:34:46 -080045 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhf9724442018-10-28 20:30:21 -070046 deps = [
47 ":proto_build_test_library_base",
48 "@com_google_protobuf//:cc_wkt_protos",
49 ],
Parker Schuh971588a2017-03-01 22:15:04 -080050)
51
Austin Schuhf9724442018-10-28 20:30:21 -070052cc_proto_library(
53 name = "proto_build_test_library_base",
54 srcs = ["proto_base.proto"],
Philipp Schraderdada1072020-11-24 11:34:46 -080055 target_compatible_with = ["@platforms//os:linux"],
Brian Silvermaneb16fa42016-02-20 15:29:56 -050056)
57
58cc_test(
Austin Schuhf9724442018-10-28 20:30:21 -070059 name = "proto_build_test",
60 size = "small",
61 srcs = [
62 "proto.cc",
63 ],
Philipp Schraderdada1072020-11-24 11:34:46 -080064 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhf9724442018-10-28 20:30:21 -070065 deps = [
66 ":proto_build_test_library",
67 "//aos/testing:googletest",
68 ],
Brian Silvermaneb16fa42016-02-20 15:29:56 -050069)
James Kuszmaulf385c462019-12-24 09:37:34 -080070
Brian Silverman28760272020-02-02 13:21:51 -080071flatbuffer_py_library(
James Kuszmaulf385c462019-12-24 09:37:34 -080072 name = "test_python_fbs",
73 srcs = ["test.fbs"],
74 namespace = "aos.examples",
75 tables = [
76 "Foo",
77 "Bar",
78 ],
Philipp Schraderdada1072020-11-24 11:34:46 -080079 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaulf385c462019-12-24 09:37:34 -080080 visibility = ["//visibility:public"],
81)
82
Alex Perry0d0aae32022-02-09 21:10:17 -080083flatbuffer_go_library(
84 name = "test_go_fbs",
85 srcs = ["test.fbs"],
86 importpath = "github.com/frc971/971-Robot-Code/build_tests/fbs",
87 target_compatible_with = ["@platforms//cpu:x86_64"],
88 visibility = ["//visibility:public"],
89)
90
James Kuszmaulf385c462019-12-24 09:37:34 -080091py_test(
92 name = "python_fbs",
93 srcs = ["python_fbs.py"],
Philipp Schraderdada1072020-11-24 11:34:46 -080094 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaulf385c462019-12-24 09:37:34 -080095 deps = [":test_python_fbs"],
96)
Brian Silverman4fe44ea2020-02-02 12:56:42 -080097
98py_test(
99 name = "python3_opencv",
100 srcs = ["python_opencv.py"],
Brian Silverman4fe44ea2020-02-02 12:56:42 -0800101 main = "python_opencv.py",
Philipp Schraderdada1072020-11-24 11:34:46 -0800102 target_compatible_with = ["@platforms//os:linux"],
Philipp Schraderebb658f2022-09-17 17:31:09 -0700103 deps = ["@pip//opencv_python"],
Brian Silverman4fe44ea2020-02-02 12:56:42 -0800104)
James Kuszmaulc91e4402020-05-10 18:47:20 -0700105
106py_test(
107 name = "python_jinja2",
108 srcs = ["python_jinja2.py"],
Philipp Schraderdada1072020-11-24 11:34:46 -0800109 target_compatible_with = ["@platforms//os:linux"],
Philipp Schraderebb658f2022-09-17 17:31:09 -0700110 deps = ["@pip//jinja2"],
James Kuszmaulc91e4402020-05-10 18:47:20 -0700111)
Philipp Schrader73e56602021-12-06 21:37:30 -0800112
113go_binary(
114 name = "hello_go",
Philipp Schrader37fdbb62021-12-18 00:30:37 -0800115 embed = [":build_tests_lib"],
Philipp Schrader73e56602021-12-06 21:37:30 -0800116 target_compatible_with = ["@platforms//cpu:x86_64"],
Philipp Schrader37fdbb62021-12-18 00:30:37 -0800117 visibility = ["//visibility:public"],
118)
119
120go_library(
121 name = "build_tests_lib",
Brian Silvermanc270a4d2022-07-23 16:08:06 -0700122 srcs = [
123 "hello.go",
124 # Not sure why gazelle wants this here?
125 "hello_autocxx.h",
126 ],
Philipp Schrader37fdbb62021-12-18 00:30:37 -0800127 importpath = "github.com/frc971/971-Robot-Code/build_tests",
128 target_compatible_with = ["@platforms//cpu:x86_64"],
129 visibility = ["//visibility:private"],
Philipp Schrader69082a02022-01-22 16:49:38 -0800130 deps = ["//build_tests/go_greeter"],
Philipp Schrader73e56602021-12-06 21:37:30 -0800131)
Philipp Schraderd0e33a42022-01-22 21:55:15 -0800132
133py_binary(
134 name = "dummy_http_server",
135 srcs = ["dummy_http_server.py"],
136 target_compatible_with = ["@platforms//cpu:x86_64"],
137)
138
139apache_wrapper(
140 name = "apache_https_demo",
141 binary = ":dummy_http_server",
142 target_compatible_with = ["@platforms//cpu:x86_64"],
143)
Ravago Jones16809802021-11-18 20:40:03 -0800144
145rust_library(
146 name = "hello_lib",
147 srcs = ["hello_lib.rs"],
Brian Silvermana8ad1af2022-07-23 16:05:12 -0700148 target_compatible_with = ["//tools/platforms/rust:has_support"],
Ravago Jones16809802021-11-18 20:40:03 -0800149)
150
151rust_test(
152 name = "hello_lib_test",
Brian Silverman847121b2022-03-09 15:48:08 -0800153 crate = ":hello_lib",
Brian Silvermana8ad1af2022-07-23 16:05:12 -0700154 target_compatible_with = ["//tools/platforms/rust:has_support"],
Ravago Jones16809802021-11-18 20:40:03 -0800155)
156
157rust_binary(
158 name = "rust_hello",
159 srcs = ["rust_hello.rs"],
Brian Silvermana8ad1af2022-07-23 16:05:12 -0700160 target_compatible_with = ["//tools/platforms/rust:has_support"],
Ravago Jones16809802021-11-18 20:40:03 -0800161 deps = [":hello_lib"],
162)
Philipp Schrader54047962022-02-16 21:05:11 -0800163
164ts_library(
165 name = "build_tests_ts",
166 srcs = ["basic.ts"],
167)
168
169ts_library(
170 name = "ts_test",
171 testonly = True,
172 srcs = ["basic_test.ts"],
173 deps = [
174 ":build_tests_ts",
175 "@npm//@types/jasmine",
176 ],
177)
178
179karma_web_test_suite(
180 name = "karma",
181 testonly = True,
182 target_compatible_with = ["@platforms//os:linux"],
183 deps = [":ts_test"],
184)
Brian Silverman8751d482022-05-18 23:28:44 -0700185
186rust_library(
187 name = "rust_in_cc_rs",
188 srcs = ["rust_in_cc.rs"],
Brian Silvermana8ad1af2022-07-23 16:05:12 -0700189 target_compatible_with = ["//tools/platforms/rust:has_support"],
Brian Silverman8751d482022-05-18 23:28:44 -0700190)
191
192cc_test(
193 name = "rust_in_cc",
194 srcs = ["rust_in_cc.cc"],
195 target_compatible_with = ["@platforms//os:linux"],
196 deps = [":rust_in_cc_rs"],
197)
Brian Silvermanc270a4d2022-07-23 16:08:06 -0700198
199cc_library(
200 name = "hello_autocxx_cc",
201 hdrs = [
202 "hello_autocxx.h",
203 ],
204)
205
206autocxx_library(
207 name = "hello_autocxx",
208 srcs = ["hello_autocxx.rs"],
209 libs = [":hello_autocxx_cc"],
210 override_cc_toolchain = "@llvm_toolchain//:cc-clang-x86_64-linux",
211 target_compatible_with = ["//tools/platforms/rust:has_support"],
212)
213
214rust_test(
215 name = "hello_autocxx_test",
216 crate = ":hello_autocxx",
217 # TODO: Make Rust play happy with pic vs nopic. Details at:
218 # https://github.com/bazelbuild/rules_rust/issues/118
219 rustc_flags = ["-Crelocation-model=static"],
220 target_compatible_with = ["//tools/platforms/rust:has_support"],
221)
Philipp Schrader9e1b9bd2021-12-28 00:15:12 -0800222
223py_test(
224 name = "upstream_python_test",
225 srcs = [
226 "upstream_python_test.py",
227 ],
228 deps = [
229 "@pip//matplotlib",
230 "@pip//numpy",
231 "@pip//scipy",
232 ],
233)
Philipp Schrader7520ee62022-12-10 14:04:40 -0800234
235py_binary(
236 name = "pygobject_example",
237 srcs = ["pygobject_example.py"],
238 deps = [
239 "@pip//pygobject",
240 ],
241)
242
243py_binary(
244 name = "matplotlib_example",
245 srcs = ["matplotlib_example.py"],
246 deps = [
247 "@pip//matplotlib",
248 "@pip//pygobject",
249 ],
250)