Niko Sohmers | 3860f8a | 2024-01-12 21:05:19 -0800 | [diff] [blame] | 1 | load("//aos/flatbuffers:generate.bzl", "static_flatbuffer") |
Niko Sohmers | b21dbdc | 2024-01-20 20:06:59 -0800 | [diff] [blame^] | 2 | load("@aspect_bazel_lib//lib:run_binary.bzl", "run_binary") |
Niko Sohmers | 3860f8a | 2024-01-12 21:05:19 -0800 | [diff] [blame] | 3 | load("//tools/build_rules:template.bzl", "jinja2_template") |
| 4 | |
| 5 | cc_library( |
| 6 | name = "simulated_constants_sender", |
| 7 | srcs = ["simulated_constants_sender.cc"], |
| 8 | hdrs = ["simulated_constants_sender.h"], |
| 9 | data = [":test_constants.json"], |
| 10 | visibility = ["//y2024:__subpackages__"], |
| 11 | deps = [ |
| 12 | ":constants_fbs", |
| 13 | ":constants_list_fbs", |
| 14 | "//aos/events:simulated_event_loop", |
| 15 | "//aos/testing:path", |
| 16 | "//frc971/constants:constants_sender_lib", |
| 17 | ], |
| 18 | ) |
| 19 | |
| 20 | jinja2_template( |
| 21 | name = "test_constants.json", |
| 22 | src = "test_constants.jinja2.json", |
Niko Sohmers | b21dbdc | 2024-01-20 20:06:59 -0800 | [diff] [blame^] | 23 | includes = glob([ |
| 24 | "test_data/*.json", |
| 25 | ]) + [ |
| 26 | ":intake_pivot_common_zeroing.json", |
| 27 | "//y2024/control_loops/superstructure/intake_pivot:intake_pivot_json", |
| 28 | "common.json", |
| 29 | "//y2024/vision/maps", |
| 30 | ], |
Niko Sohmers | 3860f8a | 2024-01-12 21:05:19 -0800 | [diff] [blame] | 31 | parameters = {}, |
| 32 | visibility = ["//visibility:public"], |
| 33 | ) |
| 34 | |
| 35 | jinja2_template( |
| 36 | name = "constants.json", |
| 37 | src = "constants.jinja2.json", |
| 38 | includes = [ |
| 39 | "7971.json", |
| 40 | "971.json", |
| 41 | "9971.json", |
| 42 | "common.json", |
Niko Sohmers | b21dbdc | 2024-01-20 20:06:59 -0800 | [diff] [blame^] | 43 | ":intake_pivot_common_zeroing.json", |
| 44 | "//y2024/control_loops/superstructure/intake_pivot:intake_pivot_json", |
Niko Sohmers | 3860f8a | 2024-01-12 21:05:19 -0800 | [diff] [blame] | 45 | "//y2024/vision/maps", |
| 46 | ], |
| 47 | parameters = {}, |
| 48 | visibility = ["//visibility:public"], |
| 49 | ) |
| 50 | |
Niko Sohmers | 3860f8a | 2024-01-12 21:05:19 -0800 | [diff] [blame] | 51 | static_flatbuffer( |
| 52 | name = "constants_fbs", |
| 53 | srcs = ["constants.fbs"], |
| 54 | visibility = ["//visibility:public"], |
| 55 | deps = [ |
Niko Sohmers | b21dbdc | 2024-01-20 20:06:59 -0800 | [diff] [blame^] | 56 | "//frc971/control_loops:profiled_subsystem_fbs", |
Niko Sohmers | 3860f8a | 2024-01-12 21:05:19 -0800 | [diff] [blame] | 57 | "//frc971/vision:target_map_fbs", |
Niko Sohmers | b21dbdc | 2024-01-20 20:06:59 -0800 | [diff] [blame^] | 58 | "//frc971/zeroing:constants_fbs", |
Niko Sohmers | 3860f8a | 2024-01-12 21:05:19 -0800 | [diff] [blame] | 59 | ], |
| 60 | ) |
| 61 | |
| 62 | static_flatbuffer( |
| 63 | name = "constants_list_fbs", |
| 64 | srcs = ["constants_list.fbs"], |
| 65 | visibility = ["//visibility:public"], |
| 66 | deps = [":constants_fbs"], |
| 67 | ) |
| 68 | |
| 69 | cc_binary( |
| 70 | name = "constants_sender", |
| 71 | srcs = ["constants_sender.cc"], |
| 72 | visibility = ["//visibility:public"], |
| 73 | deps = [ |
| 74 | ":constants_fbs", |
| 75 | ":constants_list_fbs", |
| 76 | "//aos:init", |
| 77 | "//aos/events:shm_event_loop", |
| 78 | "//aos/testing:path", |
| 79 | "//frc971/constants:constants_sender_lib", |
| 80 | ], |
| 81 | ) |
Maxwell Henderson | 6a929ff | 2024-01-14 20:03:59 -0800 | [diff] [blame] | 82 | |
| 83 | cc_test( |
| 84 | name = "constants_validator_test", |
| 85 | srcs = ["constants_validator_test.cc"], |
| 86 | data = [":constants.json"], |
| 87 | visibility = ["//visibility:public"], |
| 88 | deps = [ |
| 89 | ":constants_list_fbs", |
| 90 | "//aos:json_to_flatbuffer", |
| 91 | "//aos/testing:googletest", |
| 92 | "@com_github_google_glog//:glog", |
| 93 | ], |
| 94 | ) |
Niko Sohmers | b21dbdc | 2024-01-20 20:06:59 -0800 | [diff] [blame^] | 95 | |
| 96 | cc_binary( |
| 97 | name = "intake_pivot_json_codegen", |
| 98 | srcs = ["intake_pivot_json_codegen.cc"], |
| 99 | deps = [ |
| 100 | "//aos/util:file", |
| 101 | "//y2024:constants", |
| 102 | ], |
| 103 | ) |
| 104 | |
| 105 | run_binary( |
| 106 | name = "intake_pivot_codegen", |
| 107 | outs = ["intake_pivot_common_zeroing.json"], |
| 108 | args = ["$(location :intake_pivot_common_zeroing.json)"], |
| 109 | tool = ":intake_pivot_json_codegen", |
| 110 | ) |