Austin Schuh | f972444 | 2018-10-28 20:30:21 -0700 | [diff] [blame] | 1 | load("@com_google_protobuf//:protobuf.bzl", "cc_proto_library") |
Alex Perry | 0d0aae3 | 2022-02-09 21:10:17 -0800 | [diff] [blame] | 2 | load("@com_github_google_flatbuffers//:build_defs.bzl", "flatbuffer_go_library", "flatbuffer_py_library") |
Philipp Schrader | 37fdbb6 | 2021-12-18 00:30:37 -0800 | [diff] [blame] | 3 | load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") |
Philipp Schrader | d0e33a4 | 2022-01-22 21:55:15 -0800 | [diff] [blame] | 4 | load("//tools/build_rules:apache.bzl", "apache_wrapper") |
Ravago Jones | 1680980 | 2021-11-18 20:40:03 -0800 | [diff] [blame] | 5 | load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_library", "rust_test") |
Philipp Schrader | 5404796 | 2022-02-16 21:05:11 -0800 | [diff] [blame] | 6 | load("@npm//@bazel/typescript:index.bzl", "ts_library") |
| 7 | load("@npm//@bazel/concatjs:index.bzl", "karma_web_test_suite") |
Brian Silverman | c270a4d | 2022-07-23 16:08:06 -0700 | [diff] [blame] | 8 | load("//tools/build_rules:autocxx.bzl", "autocxx_library") |
James Kuszmaul | 27da814 | 2019-07-21 16:13:55 -0700 | [diff] [blame] | 9 | |
Brian Silverman | fbe79b8 | 2015-09-12 15:10:54 -0400 | [diff] [blame] | 10 | cc_test( |
Austin Schuh | f972444 | 2018-10-28 20:30:21 -0700 | [diff] [blame] | 11 | name = "gflags_build_test", |
| 12 | size = "small", |
| 13 | srcs = [ |
| 14 | "gflags.cc", |
| 15 | ], |
Philipp Schrader | dada107 | 2020-11-24 11:34:46 -0800 | [diff] [blame] | 16 | target_compatible_with = ["@platforms//os:linux"], |
Austin Schuh | f972444 | 2018-10-28 20:30:21 -0700 | [diff] [blame] | 17 | deps = [ |
Brian Silverman | 16a923c | 2018-10-31 19:40:51 -0700 | [diff] [blame] | 18 | "@com_github_gflags_gflags//:gflags", |
Austin Schuh | f972444 | 2018-10-28 20:30:21 -0700 | [diff] [blame] | 19 | ], |
Brian Silverman | fbe79b8 | 2015-09-12 15:10:54 -0400 | [diff] [blame] | 20 | ) |
Brian Silverman | b67da23 | 2015-09-12 23:50:30 -0400 | [diff] [blame] | 21 | |
Brian Silverman | 516ceb2 | 2015-11-27 01:29:05 -0500 | [diff] [blame] | 22 | cc_binary( |
Austin Schuh | f972444 | 2018-10-28 20:30:21 -0700 | [diff] [blame] | 23 | name = "tcmalloc_build_test_binary", |
| 24 | srcs = [ |
| 25 | "tcmalloc.cc", |
| 26 | ], |
Philipp Schrader | dada107 | 2020-11-24 11:34:46 -0800 | [diff] [blame] | 27 | target_compatible_with = ["@platforms//os:linux"], |
Brian Silverman | 516ceb2 | 2015-11-27 01:29:05 -0500 | [diff] [blame] | 28 | ) |
| 29 | |
| 30 | sh_test( |
Austin Schuh | f972444 | 2018-10-28 20:30:21 -0700 | [diff] [blame] | 31 | name = "tcmalloc_build_test", |
| 32 | size = "small", |
| 33 | srcs = [ |
| 34 | "tcmalloc_test.sh", |
| 35 | ], |
| 36 | data = [ |
| 37 | ":tcmalloc_build_test_binary", |
| 38 | ], |
Philipp Schrader | dada107 | 2020-11-24 11:34:46 -0800 | [diff] [blame] | 39 | target_compatible_with = ["@platforms//os:linux"], |
Brian Silverman | 516ceb2 | 2015-11-27 01:29:05 -0500 | [diff] [blame] | 40 | ) |
Brian Silverman | eb16fa4 | 2016-02-20 15:29:56 -0500 | [diff] [blame] | 41 | |
Austin Schuh | f972444 | 2018-10-28 20:30:21 -0700 | [diff] [blame] | 42 | cc_proto_library( |
| 43 | name = "proto_build_test_library", |
| 44 | srcs = ["proto.proto"], |
Philipp Schrader | dada107 | 2020-11-24 11:34:46 -0800 | [diff] [blame] | 45 | target_compatible_with = ["@platforms//os:linux"], |
Austin Schuh | f972444 | 2018-10-28 20:30:21 -0700 | [diff] [blame] | 46 | deps = [ |
| 47 | ":proto_build_test_library_base", |
| 48 | "@com_google_protobuf//:cc_wkt_protos", |
| 49 | ], |
Parker Schuh | 971588a | 2017-03-01 22:15:04 -0800 | [diff] [blame] | 50 | ) |
| 51 | |
Austin Schuh | f972444 | 2018-10-28 20:30:21 -0700 | [diff] [blame] | 52 | cc_proto_library( |
| 53 | name = "proto_build_test_library_base", |
| 54 | srcs = ["proto_base.proto"], |
Philipp Schrader | dada107 | 2020-11-24 11:34:46 -0800 | [diff] [blame] | 55 | target_compatible_with = ["@platforms//os:linux"], |
Brian Silverman | eb16fa4 | 2016-02-20 15:29:56 -0500 | [diff] [blame] | 56 | ) |
| 57 | |
| 58 | cc_test( |
Austin Schuh | f972444 | 2018-10-28 20:30:21 -0700 | [diff] [blame] | 59 | name = "proto_build_test", |
| 60 | size = "small", |
| 61 | srcs = [ |
| 62 | "proto.cc", |
| 63 | ], |
Philipp Schrader | dada107 | 2020-11-24 11:34:46 -0800 | [diff] [blame] | 64 | target_compatible_with = ["@platforms//os:linux"], |
Austin Schuh | f972444 | 2018-10-28 20:30:21 -0700 | [diff] [blame] | 65 | deps = [ |
| 66 | ":proto_build_test_library", |
| 67 | "//aos/testing:googletest", |
| 68 | ], |
Brian Silverman | eb16fa4 | 2016-02-20 15:29:56 -0500 | [diff] [blame] | 69 | ) |
James Kuszmaul | f385c46 | 2019-12-24 09:37:34 -0800 | [diff] [blame] | 70 | |
Brian Silverman | 2876027 | 2020-02-02 13:21:51 -0800 | [diff] [blame] | 71 | flatbuffer_py_library( |
James Kuszmaul | f385c46 | 2019-12-24 09:37:34 -0800 | [diff] [blame] | 72 | name = "test_python_fbs", |
| 73 | srcs = ["test.fbs"], |
| 74 | namespace = "aos.examples", |
| 75 | tables = [ |
| 76 | "Foo", |
| 77 | "Bar", |
| 78 | ], |
Philipp Schrader | dada107 | 2020-11-24 11:34:46 -0800 | [diff] [blame] | 79 | target_compatible_with = ["@platforms//os:linux"], |
James Kuszmaul | f385c46 | 2019-12-24 09:37:34 -0800 | [diff] [blame] | 80 | visibility = ["//visibility:public"], |
| 81 | ) |
| 82 | |
Alex Perry | 0d0aae3 | 2022-02-09 21:10:17 -0800 | [diff] [blame] | 83 | flatbuffer_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 Kuszmaul | f385c46 | 2019-12-24 09:37:34 -0800 | [diff] [blame] | 91 | py_test( |
| 92 | name = "python_fbs", |
| 93 | srcs = ["python_fbs.py"], |
Philipp Schrader | dada107 | 2020-11-24 11:34:46 -0800 | [diff] [blame] | 94 | target_compatible_with = ["@platforms//os:linux"], |
James Kuszmaul | f385c46 | 2019-12-24 09:37:34 -0800 | [diff] [blame] | 95 | deps = [":test_python_fbs"], |
| 96 | ) |
Brian Silverman | 4fe44ea | 2020-02-02 12:56:42 -0800 | [diff] [blame] | 97 | |
| 98 | py_test( |
| 99 | name = "python3_opencv", |
| 100 | srcs = ["python_opencv.py"], |
Brian Silverman | 4fe44ea | 2020-02-02 12:56:42 -0800 | [diff] [blame] | 101 | main = "python_opencv.py", |
Philipp Schrader | dada107 | 2020-11-24 11:34:46 -0800 | [diff] [blame] | 102 | target_compatible_with = ["@platforms//os:linux"], |
Brian Silverman | 4fe44ea | 2020-02-02 12:56:42 -0800 | [diff] [blame] | 103 | deps = ["@opencv_contrib_nonfree_amd64//:python_opencv"], |
| 104 | ) |
James Kuszmaul | c91e440 | 2020-05-10 18:47:20 -0700 | [diff] [blame] | 105 | |
| 106 | py_test( |
| 107 | name = "python_jinja2", |
| 108 | srcs = ["python_jinja2.py"], |
| 109 | srcs_version = "PY2AND3", |
Philipp Schrader | dada107 | 2020-11-24 11:34:46 -0800 | [diff] [blame] | 110 | target_compatible_with = ["@platforms//os:linux"], |
James Kuszmaul | c91e440 | 2020-05-10 18:47:20 -0700 | [diff] [blame] | 111 | deps = ["@python_jinja2"], |
| 112 | ) |
Philipp Schrader | 73e5660 | 2021-12-06 21:37:30 -0800 | [diff] [blame] | 113 | |
| 114 | go_binary( |
| 115 | name = "hello_go", |
Philipp Schrader | 37fdbb6 | 2021-12-18 00:30:37 -0800 | [diff] [blame] | 116 | embed = [":build_tests_lib"], |
Philipp Schrader | 73e5660 | 2021-12-06 21:37:30 -0800 | [diff] [blame] | 117 | target_compatible_with = ["@platforms//cpu:x86_64"], |
Philipp Schrader | 37fdbb6 | 2021-12-18 00:30:37 -0800 | [diff] [blame] | 118 | visibility = ["//visibility:public"], |
| 119 | ) |
| 120 | |
| 121 | go_library( |
| 122 | name = "build_tests_lib", |
Brian Silverman | c270a4d | 2022-07-23 16:08:06 -0700 | [diff] [blame] | 123 | srcs = [ |
| 124 | "hello.go", |
| 125 | # Not sure why gazelle wants this here? |
| 126 | "hello_autocxx.h", |
| 127 | ], |
Philipp Schrader | 37fdbb6 | 2021-12-18 00:30:37 -0800 | [diff] [blame] | 128 | importpath = "github.com/frc971/971-Robot-Code/build_tests", |
| 129 | target_compatible_with = ["@platforms//cpu:x86_64"], |
| 130 | visibility = ["//visibility:private"], |
Philipp Schrader | 69082a0 | 2022-01-22 16:49:38 -0800 | [diff] [blame] | 131 | deps = ["//build_tests/go_greeter"], |
Philipp Schrader | 73e5660 | 2021-12-06 21:37:30 -0800 | [diff] [blame] | 132 | ) |
Philipp Schrader | d0e33a4 | 2022-01-22 21:55:15 -0800 | [diff] [blame] | 133 | |
| 134 | py_binary( |
| 135 | name = "dummy_http_server", |
| 136 | srcs = ["dummy_http_server.py"], |
| 137 | target_compatible_with = ["@platforms//cpu:x86_64"], |
| 138 | ) |
| 139 | |
| 140 | apache_wrapper( |
| 141 | name = "apache_https_demo", |
| 142 | binary = ":dummy_http_server", |
| 143 | target_compatible_with = ["@platforms//cpu:x86_64"], |
| 144 | ) |
Ravago Jones | 1680980 | 2021-11-18 20:40:03 -0800 | [diff] [blame] | 145 | |
| 146 | rust_library( |
| 147 | name = "hello_lib", |
| 148 | srcs = ["hello_lib.rs"], |
Brian Silverman | a8ad1af | 2022-07-23 16:05:12 -0700 | [diff] [blame] | 149 | target_compatible_with = ["//tools/platforms/rust:has_support"], |
Ravago Jones | 1680980 | 2021-11-18 20:40:03 -0800 | [diff] [blame] | 150 | ) |
| 151 | |
| 152 | rust_test( |
| 153 | name = "hello_lib_test", |
Brian Silverman | 847121b | 2022-03-09 15:48:08 -0800 | [diff] [blame] | 154 | crate = ":hello_lib", |
Brian Silverman | a8ad1af | 2022-07-23 16:05:12 -0700 | [diff] [blame] | 155 | target_compatible_with = ["//tools/platforms/rust:has_support"], |
Ravago Jones | 1680980 | 2021-11-18 20:40:03 -0800 | [diff] [blame] | 156 | ) |
| 157 | |
| 158 | rust_binary( |
| 159 | name = "rust_hello", |
| 160 | srcs = ["rust_hello.rs"], |
Brian Silverman | a8ad1af | 2022-07-23 16:05:12 -0700 | [diff] [blame] | 161 | target_compatible_with = ["//tools/platforms/rust:has_support"], |
Ravago Jones | 1680980 | 2021-11-18 20:40:03 -0800 | [diff] [blame] | 162 | deps = [":hello_lib"], |
| 163 | ) |
Philipp Schrader | 5404796 | 2022-02-16 21:05:11 -0800 | [diff] [blame] | 164 | |
| 165 | ts_library( |
| 166 | name = "build_tests_ts", |
| 167 | srcs = ["basic.ts"], |
| 168 | ) |
| 169 | |
| 170 | ts_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 | |
| 180 | karma_web_test_suite( |
| 181 | name = "karma", |
| 182 | testonly = True, |
| 183 | target_compatible_with = ["@platforms//os:linux"], |
| 184 | deps = [":ts_test"], |
| 185 | ) |
Brian Silverman | 8751d48 | 2022-05-18 23:28:44 -0700 | [diff] [blame] | 186 | |
| 187 | rust_library( |
| 188 | name = "rust_in_cc_rs", |
| 189 | srcs = ["rust_in_cc.rs"], |
Brian Silverman | a8ad1af | 2022-07-23 16:05:12 -0700 | [diff] [blame] | 190 | target_compatible_with = ["//tools/platforms/rust:has_support"], |
Brian Silverman | 8751d48 | 2022-05-18 23:28:44 -0700 | [diff] [blame] | 191 | ) |
| 192 | |
| 193 | cc_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 Silverman | c270a4d | 2022-07-23 16:08:06 -0700 | [diff] [blame] | 199 | |
| 200 | cc_library( |
| 201 | name = "hello_autocxx_cc", |
| 202 | hdrs = [ |
| 203 | "hello_autocxx.h", |
| 204 | ], |
| 205 | ) |
| 206 | |
| 207 | autocxx_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 | |
| 215 | rust_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 | ) |
Philipp Schrader | 9e1b9bd | 2021-12-28 00:15:12 -0800 | [diff] [blame] | 223 | |
| 224 | py_test( |
| 225 | name = "upstream_python_test", |
| 226 | srcs = [ |
| 227 | "upstream_python_test.py", |
| 228 | ], |
| 229 | deps = [ |
| 230 | "@pip//matplotlib", |
| 231 | "@pip//numpy", |
| 232 | "@pip//scipy", |
| 233 | ], |
| 234 | ) |
Philipp Schrader | 7520ee6 | 2022-12-10 14:04:40 -0800 | [diff] [blame^] | 235 | |
| 236 | py_binary( |
| 237 | name = "pygobject_example", |
| 238 | srcs = ["pygobject_example.py"], |
| 239 | deps = [ |
| 240 | "@pip//pygobject", |
| 241 | ], |
| 242 | ) |
| 243 | |
| 244 | py_binary( |
| 245 | name = "matplotlib_example", |
| 246 | srcs = ["matplotlib_example.py"], |
| 247 | deps = [ |
| 248 | "@pip//matplotlib", |
| 249 | "@pip//pygobject", |
| 250 | ], |
| 251 | ) |