blob: bfdd76e4e9894856eb21fc24db9a21c9db710eb6 [file] [log] [blame]
Philipp Schrader3de4dfc2023-02-15 20:18:25 -08001load("//tools/build_rules:js.bzl", "ts_project")
Austin Schuhf9724442018-10-28 20:30:21 -07002load("@com_google_protobuf//:protobuf.bzl", "cc_proto_library")
Alex Perry0d0aae32022-02-09 21:10:17 -08003load("@com_github_google_flatbuffers//:build_defs.bzl", "flatbuffer_go_library", "flatbuffer_py_library")
Philipp Schrader37fdbb62021-12-18 00:30:37 -08004load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
Philipp Schraderd0e33a42022-01-22 21:55:15 -08005load("//tools/build_rules:apache.bzl", "apache_wrapper")
Ravago Jones16809802021-11-18 20:40:03 -08006load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_library", "rust_test")
Brian Silvermanc270a4d2022-07-23 16:08:06 -07007load("//tools/build_rules:autocxx.bzl", "autocxx_library")
James Kuszmaul27da8142019-07-21 16:13:55 -07008
Brian Silvermanfbe79b82015-09-12 15:10:54 -04009cc_test(
Austin Schuhf9724442018-10-28 20:30:21 -070010 name = "gflags_build_test",
11 size = "small",
12 srcs = [
13 "gflags.cc",
14 ],
Philipp Schraderdada1072020-11-24 11:34:46 -080015 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhf9724442018-10-28 20:30:21 -070016 deps = [
Brian Silverman16a923c2018-10-31 19:40:51 -070017 "@com_github_gflags_gflags//:gflags",
Austin Schuhf9724442018-10-28 20:30:21 -070018 ],
Brian Silvermanfbe79b82015-09-12 15:10:54 -040019)
Brian Silvermanb67da232015-09-12 23:50:30 -040020
Brian Silverman516ceb22015-11-27 01:29:05 -050021cc_binary(
Austin Schuhf9724442018-10-28 20:30:21 -070022 name = "tcmalloc_build_test_binary",
23 srcs = [
24 "tcmalloc.cc",
25 ],
Philipp Schraderdada1072020-11-24 11:34:46 -080026 target_compatible_with = ["@platforms//os:linux"],
Brian Silverman516ceb22015-11-27 01:29:05 -050027)
28
29sh_test(
Austin Schuhf9724442018-10-28 20:30:21 -070030 name = "tcmalloc_build_test",
31 size = "small",
32 srcs = [
33 "tcmalloc_test.sh",
34 ],
35 data = [
36 ":tcmalloc_build_test_binary",
37 ],
Philipp Schraderdada1072020-11-24 11:34:46 -080038 target_compatible_with = ["@platforms//os:linux"],
Brian Silverman516ceb22015-11-27 01:29:05 -050039)
Brian Silvermaneb16fa42016-02-20 15:29:56 -050040
Austin Schuhf9724442018-10-28 20:30:21 -070041cc_proto_library(
42 name = "proto_build_test_library",
43 srcs = ["proto.proto"],
Philipp Schraderdada1072020-11-24 11:34:46 -080044 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhf9724442018-10-28 20:30:21 -070045 deps = [
46 ":proto_build_test_library_base",
47 "@com_google_protobuf//:cc_wkt_protos",
48 ],
Parker Schuh971588a2017-03-01 22:15:04 -080049)
50
Austin Schuhf9724442018-10-28 20:30:21 -070051cc_proto_library(
52 name = "proto_build_test_library_base",
53 srcs = ["proto_base.proto"],
Philipp Schraderdada1072020-11-24 11:34:46 -080054 target_compatible_with = ["@platforms//os:linux"],
Brian Silvermaneb16fa42016-02-20 15:29:56 -050055)
56
57cc_test(
Austin Schuhf9724442018-10-28 20:30:21 -070058 name = "proto_build_test",
59 size = "small",
60 srcs = [
61 "proto.cc",
62 ],
Philipp Schraderdada1072020-11-24 11:34:46 -080063 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhf9724442018-10-28 20:30:21 -070064 deps = [
65 ":proto_build_test_library",
66 "//aos/testing:googletest",
67 ],
Brian Silvermaneb16fa42016-02-20 15:29:56 -050068)
James Kuszmaulf385c462019-12-24 09:37:34 -080069
Brian Silverman28760272020-02-02 13:21:51 -080070flatbuffer_py_library(
James Kuszmaulf385c462019-12-24 09:37:34 -080071 name = "test_python_fbs",
72 srcs = ["test.fbs"],
73 namespace = "aos.examples",
74 tables = [
75 "Foo",
76 "Bar",
77 ],
Philipp Schraderdada1072020-11-24 11:34:46 -080078 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaulf385c462019-12-24 09:37:34 -080079 visibility = ["//visibility:public"],
80)
81
Alex Perry0d0aae32022-02-09 21:10:17 -080082flatbuffer_go_library(
83 name = "test_go_fbs",
84 srcs = ["test.fbs"],
85 importpath = "github.com/frc971/971-Robot-Code/build_tests/fbs",
86 target_compatible_with = ["@platforms//cpu:x86_64"],
87 visibility = ["//visibility:public"],
88)
89
James Kuszmaulf385c462019-12-24 09:37:34 -080090py_test(
91 name = "python_fbs",
92 srcs = ["python_fbs.py"],
Philipp Schraderdada1072020-11-24 11:34:46 -080093 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaulf385c462019-12-24 09:37:34 -080094 deps = [":test_python_fbs"],
95)
Brian Silverman4fe44ea2020-02-02 12:56:42 -080096
97py_test(
98 name = "python3_opencv",
99 srcs = ["python_opencv.py"],
Brian Silverman4fe44ea2020-02-02 12:56:42 -0800100 main = "python_opencv.py",
Philipp Schraderdada1072020-11-24 11:34:46 -0800101 target_compatible_with = ["@platforms//os:linux"],
Philipp Schraderebb658f2022-09-17 17:31:09 -0700102 deps = ["@pip//opencv_python"],
Brian Silverman4fe44ea2020-02-02 12:56:42 -0800103)
James Kuszmaulc91e4402020-05-10 18:47:20 -0700104
105py_test(
106 name = "python_jinja2",
107 srcs = ["python_jinja2.py"],
Philipp Schraderdada1072020-11-24 11:34:46 -0800108 target_compatible_with = ["@platforms//os:linux"],
Philipp Schraderebb658f2022-09-17 17:31:09 -0700109 deps = ["@pip//jinja2"],
James Kuszmaulc91e4402020-05-10 18:47:20 -0700110)
Philipp Schrader73e56602021-12-06 21:37:30 -0800111
112go_binary(
113 name = "hello_go",
Philipp Schrader37fdbb62021-12-18 00:30:37 -0800114 embed = [":build_tests_lib"],
Philipp Schrader73e56602021-12-06 21:37:30 -0800115 target_compatible_with = ["@platforms//cpu:x86_64"],
Philipp Schrader37fdbb62021-12-18 00:30:37 -0800116 visibility = ["//visibility:public"],
117)
118
119go_library(
120 name = "build_tests_lib",
Brian Silvermanc270a4d2022-07-23 16:08:06 -0700121 srcs = [
122 "hello.go",
123 # Not sure why gazelle wants this here?
124 "hello_autocxx.h",
125 ],
Philipp Schrader37fdbb62021-12-18 00:30:37 -0800126 importpath = "github.com/frc971/971-Robot-Code/build_tests",
127 target_compatible_with = ["@platforms//cpu:x86_64"],
128 visibility = ["//visibility:private"],
Philipp Schrader69082a02022-01-22 16:49:38 -0800129 deps = ["//build_tests/go_greeter"],
Philipp Schrader73e56602021-12-06 21:37:30 -0800130)
Philipp Schraderd0e33a42022-01-22 21:55:15 -0800131
132py_binary(
133 name = "dummy_http_server",
134 srcs = ["dummy_http_server.py"],
135 target_compatible_with = ["@platforms//cpu:x86_64"],
136)
137
138apache_wrapper(
139 name = "apache_https_demo",
140 binary = ":dummy_http_server",
141 target_compatible_with = ["@platforms//cpu:x86_64"],
142)
Ravago Jones16809802021-11-18 20:40:03 -0800143
144rust_library(
145 name = "hello_lib",
146 srcs = ["hello_lib.rs"],
Brian Silvermana8ad1af2022-07-23 16:05:12 -0700147 target_compatible_with = ["//tools/platforms/rust:has_support"],
Ravago Jones16809802021-11-18 20:40:03 -0800148)
149
150rust_test(
151 name = "hello_lib_test",
Brian Silverman847121b2022-03-09 15:48:08 -0800152 crate = ":hello_lib",
Brian Silvermana8ad1af2022-07-23 16:05:12 -0700153 target_compatible_with = ["//tools/platforms/rust:has_support"],
Ravago Jones16809802021-11-18 20:40:03 -0800154)
155
156rust_binary(
157 name = "rust_hello",
158 srcs = ["rust_hello.rs"],
Brian Silvermana8ad1af2022-07-23 16:05:12 -0700159 target_compatible_with = ["//tools/platforms/rust:has_support"],
Ravago Jones16809802021-11-18 20:40:03 -0800160 deps = [":hello_lib"],
161)
Philipp Schrader54047962022-02-16 21:05:11 -0800162
Philipp Schrader3de4dfc2023-02-15 20:18:25 -0800163ts_project(
Philipp Schrader54047962022-02-16 21:05:11 -0800164 name = "build_tests_ts",
165 srcs = ["basic.ts"],
166)
167
Brian Silverman8751d482022-05-18 23:28:44 -0700168rust_library(
169 name = "rust_in_cc_rs",
170 srcs = ["rust_in_cc.rs"],
Brian Silvermana8ad1af2022-07-23 16:05:12 -0700171 target_compatible_with = ["//tools/platforms/rust:has_support"],
Brian Silverman8751d482022-05-18 23:28:44 -0700172)
173
174cc_test(
175 name = "rust_in_cc",
176 srcs = ["rust_in_cc.cc"],
177 target_compatible_with = ["@platforms//os:linux"],
178 deps = [":rust_in_cc_rs"],
179)
Brian Silvermanc270a4d2022-07-23 16:08:06 -0700180
181cc_library(
182 name = "hello_autocxx_cc",
183 hdrs = [
184 "hello_autocxx.h",
185 ],
186)
187
188autocxx_library(
189 name = "hello_autocxx",
190 srcs = ["hello_autocxx.rs"],
191 libs = [":hello_autocxx_cc"],
192 override_cc_toolchain = "@llvm_toolchain//:cc-clang-x86_64-linux",
193 target_compatible_with = ["//tools/platforms/rust:has_support"],
194)
195
196rust_test(
197 name = "hello_autocxx_test",
198 crate = ":hello_autocxx",
199 # TODO: Make Rust play happy with pic vs nopic. Details at:
200 # https://github.com/bazelbuild/rules_rust/issues/118
201 rustc_flags = ["-Crelocation-model=static"],
202 target_compatible_with = ["//tools/platforms/rust:has_support"],
203)
Philipp Schrader9e1b9bd2021-12-28 00:15:12 -0800204
205py_test(
206 name = "upstream_python_test",
207 srcs = [
208 "upstream_python_test.py",
209 ],
210 deps = [
211 "@pip//matplotlib",
212 "@pip//numpy",
213 "@pip//scipy",
214 ],
215)
Philipp Schrader7520ee62022-12-10 14:04:40 -0800216
217py_binary(
218 name = "pygobject_example",
219 srcs = ["pygobject_example.py"],
220 deps = [
221 "@pip//pygobject",
222 ],
223)
224
225py_binary(
226 name = "matplotlib_example",
227 srcs = ["matplotlib_example.py"],
228 deps = [
229 "@pip//matplotlib",
230 "@pip//pygobject",
231 ],
232)