blob: ae707f3153a0b87c0a4cc87926ac243fbdf7635c [file] [log] [blame]
Yash Maheshwarie0b25c52024-05-22 20:23:36 -07001load("//aos/flatbuffers:generate.bzl", "static_flatbuffer")
2load("//tools/build_rules:template.bzl", "jinja2_template")
3load("//y2024_swerve/constants:validator.bzl", "constants_json")
4
5cc_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_swerve:__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
20jinja2_template(
21 name = "test_constants_unvalidated.json",
22 src = "test_constants.jinja2.json",
23 includes = glob([
24 "test_data/*.json",
25 ]) + [
26 "common.jinja2",
27 "common.json",
28 "//y2024_swerve/constants/calib_files",
James Kuszmaulbfdd2562024-07-06 14:18:53 -070029 "//y2024_swerve/control_loops/drivetrain:rotation_json",
Yash Maheshwarie0b25c52024-05-22 20:23:36 -070030 "//y2024_swerve/vision/maps",
31 ],
32 parameters = {},
33 visibility = ["//visibility:public"],
34)
35
36jinja2_template(
37 name = "constants_unvalidated.json",
38 src = "constants.jinja2.json",
39 includes = [
Yash Maheshwarie0b25c52024-05-22 20:23:36 -070040 "7971.json",
James Kuszmaul8078c952024-07-06 12:27:59 -070041 "9971.json",
Yash Maheshwarie0b25c52024-05-22 20:23:36 -070042 "common.jinja2",
43 "common.json",
44 "//y2024_swerve/constants/calib_files",
James Kuszmaulbfdd2562024-07-06 14:18:53 -070045 "//y2024_swerve/control_loops/drivetrain:rotation_json",
Yash Maheshwarie0b25c52024-05-22 20:23:36 -070046 "//y2024_swerve/vision/maps",
47 ],
48 parameters = {},
49 visibility = ["//visibility:public"],
50)
51
52static_flatbuffer(
53 name = "constants_fbs",
54 srcs = ["constants.fbs"],
55 visibility = ["//visibility:public"],
56 deps = [
57 "//frc971/control_loops:profiled_subsystem_fbs",
58 "//frc971/control_loops/drivetrain:drivetrain_config_fbs",
James Kuszmauldf6b1682024-07-06 13:53:10 -070059 "//frc971/control_loops/swerve:swerve_zeroing_fbs",
Yash Maheshwarie0b25c52024-05-22 20:23:36 -070060 "//frc971/vision:calibration_fbs",
61 "//frc971/vision:target_map_fbs",
Nikolai Sohmersce9ee6e2024-07-06 17:16:20 -070062 "//frc971/wpilib/swerve:swerve_constants_fbs",
Yash Maheshwarie0b25c52024-05-22 20:23:36 -070063 "//frc971/zeroing:constants_fbs",
64 ],
65)
66
67static_flatbuffer(
68 name = "constants_list_fbs",
69 srcs = ["constants_list.fbs"],
70 visibility = ["//visibility:public"],
71 deps = [":constants_fbs"],
72)
73
74cc_binary(
75 name = "constants_sender",
76 srcs = ["constants_sender.cc"],
77 visibility = ["//visibility:public"],
78 deps = [
79 ":constants_fbs",
80 ":constants_list_fbs",
81 "//aos:init",
82 "//aos/events:shm_event_loop",
83 "//aos/testing:path",
84 "//frc971/constants:constants_sender_lib",
85 ],
86)
87
88cc_binary(
89 name = "constants_formatter",
90 srcs = ["constants_formatter.cc"],
91 data = [":constants_unvalidated.json"],
92 visibility = ["//visibility:public"],
93 deps = [
94 ":constants_list_fbs",
95 "//aos:init",
96 "//aos:json_to_flatbuffer",
Austin Schuh99f7c6a2024-06-25 22:07:44 -070097 "@com_google_absl//absl/log",
98 "@com_google_absl//absl/log:check",
Yash Maheshwarie0b25c52024-05-22 20:23:36 -070099 ],
100)
101
102constants_json(
103 name = "constants_json",
104 src = ":constants_unvalidated.json",
105 out = "constants.json",
106)
107
108constants_json(
109 name = "test_constants_json",
110 src = ":test_constants_unvalidated.json",
111 out = "test_constants.json",
112)