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