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", |
James Kuszmaul | 2549e75 | 2024-01-20 17:42:51 -0800 | [diff] [blame] | 28 | "//y2024/control_loops/drivetrain:drivetrain_config.json", |
Niko Sohmers | b21dbdc | 2024-01-20 20:06:59 -0800 | [diff] [blame] | 29 | "common.json", |
| 30 | "//y2024/vision/maps", |
| 31 | ], |
Niko Sohmers | 3860f8a | 2024-01-12 21:05:19 -0800 | [diff] [blame] | 32 | parameters = {}, |
| 33 | visibility = ["//visibility:public"], |
| 34 | ) |
| 35 | |
| 36 | jinja2_template( |
| 37 | name = "constants.json", |
| 38 | src = "constants.jinja2.json", |
| 39 | includes = [ |
| 40 | "7971.json", |
| 41 | "971.json", |
| 42 | "9971.json", |
| 43 | "common.json", |
Niko Sohmers | b21dbdc | 2024-01-20 20:06:59 -0800 | [diff] [blame] | 44 | ":intake_pivot_common_zeroing.json", |
James Kuszmaul | 2549e75 | 2024-01-20 17:42:51 -0800 | [diff] [blame] | 45 | "//y2024/control_loops/drivetrain:drivetrain_config.json", |
Niko Sohmers | b21dbdc | 2024-01-20 20:06:59 -0800 | [diff] [blame] | 46 | "//y2024/control_loops/superstructure/intake_pivot:intake_pivot_json", |
Niko Sohmers | 3860f8a | 2024-01-12 21:05:19 -0800 | [diff] [blame] | 47 | "//y2024/vision/maps", |
| 48 | ], |
| 49 | parameters = {}, |
| 50 | visibility = ["//visibility:public"], |
| 51 | ) |
| 52 | |
Niko Sohmers | 3860f8a | 2024-01-12 21:05:19 -0800 | [diff] [blame] | 53 | static_flatbuffer( |
| 54 | name = "constants_fbs", |
| 55 | srcs = ["constants.fbs"], |
| 56 | visibility = ["//visibility:public"], |
| 57 | deps = [ |
Niko Sohmers | b21dbdc | 2024-01-20 20:06:59 -0800 | [diff] [blame] | 58 | "//frc971/control_loops:profiled_subsystem_fbs", |
James Kuszmaul | 2549e75 | 2024-01-20 17:42:51 -0800 | [diff] [blame] | 59 | "//frc971/control_loops/drivetrain:drivetrain_config_fbs", |
Niko Sohmers | 3860f8a | 2024-01-12 21:05:19 -0800 | [diff] [blame] | 60 | "//frc971/vision:target_map_fbs", |
Niko Sohmers | b21dbdc | 2024-01-20 20:06:59 -0800 | [diff] [blame] | 61 | "//frc971/zeroing:constants_fbs", |
Niko Sohmers | 3860f8a | 2024-01-12 21:05:19 -0800 | [diff] [blame] | 62 | ], |
| 63 | ) |
| 64 | |
| 65 | static_flatbuffer( |
| 66 | name = "constants_list_fbs", |
| 67 | srcs = ["constants_list.fbs"], |
| 68 | visibility = ["//visibility:public"], |
| 69 | deps = [":constants_fbs"], |
| 70 | ) |
| 71 | |
| 72 | cc_binary( |
| 73 | name = "constants_sender", |
| 74 | srcs = ["constants_sender.cc"], |
| 75 | visibility = ["//visibility:public"], |
| 76 | deps = [ |
| 77 | ":constants_fbs", |
| 78 | ":constants_list_fbs", |
| 79 | "//aos:init", |
| 80 | "//aos/events:shm_event_loop", |
| 81 | "//aos/testing:path", |
| 82 | "//frc971/constants:constants_sender_lib", |
| 83 | ], |
| 84 | ) |
Maxwell Henderson | 6a929ff | 2024-01-14 20:03:59 -0800 | [diff] [blame] | 85 | |
| 86 | cc_test( |
| 87 | name = "constants_validator_test", |
| 88 | srcs = ["constants_validator_test.cc"], |
| 89 | data = [":constants.json"], |
| 90 | visibility = ["//visibility:public"], |
| 91 | deps = [ |
| 92 | ":constants_list_fbs", |
| 93 | "//aos:json_to_flatbuffer", |
| 94 | "//aos/testing:googletest", |
| 95 | "@com_github_google_glog//:glog", |
| 96 | ], |
| 97 | ) |
Niko Sohmers | b21dbdc | 2024-01-20 20:06:59 -0800 | [diff] [blame] | 98 | |
| 99 | cc_binary( |
| 100 | name = "intake_pivot_json_codegen", |
| 101 | srcs = ["intake_pivot_json_codegen.cc"], |
| 102 | deps = [ |
| 103 | "//aos/util:file", |
| 104 | "//y2024:constants", |
| 105 | ], |
| 106 | ) |
| 107 | |
| 108 | run_binary( |
| 109 | name = "intake_pivot_codegen", |
| 110 | outs = ["intake_pivot_common_zeroing.json"], |
| 111 | args = ["$(location :intake_pivot_common_zeroing.json)"], |
| 112 | tool = ":intake_pivot_json_codegen", |
| 113 | ) |