blob: e7f236ad38c1e8377713dc58e5730b7ae251ec83 [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"],
Brian Silverman4fe44ea2020-02-02 12:56:42 -0800103 deps = ["@opencv_contrib_nonfree_amd64//:python_opencv"],
104)
James Kuszmaulc91e4402020-05-10 18:47:20 -0700105
106py_test(
107 name = "python_jinja2",
108 srcs = ["python_jinja2.py"],
109 srcs_version = "PY2AND3",
Philipp Schraderdada1072020-11-24 11:34:46 -0800110 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaulc91e4402020-05-10 18:47:20 -0700111 deps = ["@python_jinja2"],
112)
Philipp Schrader73e56602021-12-06 21:37:30 -0800113
114go_binary(
115 name = "hello_go",
Philipp Schrader37fdbb62021-12-18 00:30:37 -0800116 embed = [":build_tests_lib"],
Philipp Schrader73e56602021-12-06 21:37:30 -0800117 target_compatible_with = ["@platforms//cpu:x86_64"],
Philipp Schrader37fdbb62021-12-18 00:30:37 -0800118 visibility = ["//visibility:public"],
119)
120
121go_library(
122 name = "build_tests_lib",
Brian Silvermanc270a4d2022-07-23 16:08:06 -0700123 srcs = [
124 "hello.go",
125 # Not sure why gazelle wants this here?
126 "hello_autocxx.h",
127 ],
Philipp Schrader37fdbb62021-12-18 00:30:37 -0800128 importpath = "github.com/frc971/971-Robot-Code/build_tests",
129 target_compatible_with = ["@platforms//cpu:x86_64"],
130 visibility = ["//visibility:private"],
Philipp Schrader69082a02022-01-22 16:49:38 -0800131 deps = ["//build_tests/go_greeter"],
Philipp Schrader73e56602021-12-06 21:37:30 -0800132)
Philipp Schraderd0e33a42022-01-22 21:55:15 -0800133
134py_binary(
135 name = "dummy_http_server",
136 srcs = ["dummy_http_server.py"],
137 target_compatible_with = ["@platforms//cpu:x86_64"],
138)
139
140apache_wrapper(
141 name = "apache_https_demo",
142 binary = ":dummy_http_server",
143 target_compatible_with = ["@platforms//cpu:x86_64"],
144)
Ravago Jones16809802021-11-18 20:40:03 -0800145
146rust_library(
147 name = "hello_lib",
148 srcs = ["hello_lib.rs"],
Brian Silvermana8ad1af2022-07-23 16:05:12 -0700149 target_compatible_with = ["//tools/platforms/rust:has_support"],
Ravago Jones16809802021-11-18 20:40:03 -0800150)
151
152rust_test(
153 name = "hello_lib_test",
Brian Silverman847121b2022-03-09 15:48:08 -0800154 crate = ":hello_lib",
Brian Silvermana8ad1af2022-07-23 16:05:12 -0700155 target_compatible_with = ["//tools/platforms/rust:has_support"],
Ravago Jones16809802021-11-18 20:40:03 -0800156)
157
158rust_binary(
159 name = "rust_hello",
160 srcs = ["rust_hello.rs"],
Brian Silvermana8ad1af2022-07-23 16:05:12 -0700161 target_compatible_with = ["//tools/platforms/rust:has_support"],
Ravago Jones16809802021-11-18 20:40:03 -0800162 deps = [":hello_lib"],
163)
Philipp Schrader54047962022-02-16 21:05:11 -0800164
165ts_library(
166 name = "build_tests_ts",
167 srcs = ["basic.ts"],
168)
169
170ts_library(
171 name = "ts_test",
172 testonly = True,
173 srcs = ["basic_test.ts"],
174 deps = [
175 ":build_tests_ts",
176 "@npm//@types/jasmine",
177 ],
178)
179
180karma_web_test_suite(
181 name = "karma",
182 testonly = True,
183 target_compatible_with = ["@platforms//os:linux"],
184 deps = [":ts_test"],
185)
Brian Silverman8751d482022-05-18 23:28:44 -0700186
187rust_library(
188 name = "rust_in_cc_rs",
189 srcs = ["rust_in_cc.rs"],
Brian Silvermana8ad1af2022-07-23 16:05:12 -0700190 target_compatible_with = ["//tools/platforms/rust:has_support"],
Brian Silverman8751d482022-05-18 23:28:44 -0700191)
192
193cc_test(
194 name = "rust_in_cc",
195 srcs = ["rust_in_cc.cc"],
196 target_compatible_with = ["@platforms//os:linux"],
197 deps = [":rust_in_cc_rs"],
198)
Brian Silvermanc270a4d2022-07-23 16:08:06 -0700199
200cc_library(
201 name = "hello_autocxx_cc",
202 hdrs = [
203 "hello_autocxx.h",
204 ],
205)
206
207autocxx_library(
208 name = "hello_autocxx",
209 srcs = ["hello_autocxx.rs"],
210 libs = [":hello_autocxx_cc"],
211 override_cc_toolchain = "@llvm_toolchain//:cc-clang-x86_64-linux",
212 target_compatible_with = ["//tools/platforms/rust:has_support"],
213)
214
215rust_test(
216 name = "hello_autocxx_test",
217 crate = ":hello_autocxx",
218 # TODO: Make Rust play happy with pic vs nopic. Details at:
219 # https://github.com/bazelbuild/rules_rust/issues/118
220 rustc_flags = ["-Crelocation-model=static"],
221 target_compatible_with = ["//tools/platforms/rust:has_support"],
222)