Move over to ABSL logging and flags.
Removes gperftools too since that wants gflags.
Here come the fireworks.
Change-Id: I79cb7bcf60f1047fbfa28bfffc21a0fd692e4b1c
Signed-off-by: Austin Schuh <austin.linux@gmail.com>
diff --git a/y2019/control_loops/drivetrain/BUILD b/y2019/control_loops/drivetrain/BUILD
index 71bd0ee..9c45c1f 100644
--- a/y2019/control_loops/drivetrain/BUILD
+++ b/y2019/control_loops/drivetrain/BUILD
@@ -200,7 +200,7 @@
"//frc971/control_loops/drivetrain:splinedrivetrain",
"//frc971/control_loops/drivetrain:trajectory",
"//y2019:constants",
- "@com_github_gflags_gflags//:gflags",
+ "@com_google_absl//absl/flags:flag",
] + cpu_select({
"amd64": [
"//third_party/matplotlib-cpp",
@@ -254,7 +254,8 @@
"//aos/events/logging:log_reader",
"//aos/events/logging:log_writer",
"//frc971/control_loops/drivetrain:drivetrain_lib",
- "@com_github_gflags_gflags//:gflags",
- "@com_github_google_glog//:glog",
+ "@com_google_absl//absl/flags:flag",
+ "@com_google_absl//absl/log",
+ "@com_google_absl//absl/log:check",
],
)
diff --git a/y2019/control_loops/drivetrain/drivetrain_replay.cc b/y2019/control_loops/drivetrain/drivetrain_replay.cc
index d9d928c..fa1c589 100644
--- a/y2019/control_loops/drivetrain/drivetrain_replay.cc
+++ b/y2019/control_loops/drivetrain/drivetrain_replay.cc
@@ -1,6 +1,6 @@
#include <iostream>
-#include "gflags/gflags.h"
+#include "absl/flags/flag.h"
#include "aos/configuration.h"
#include "aos/events/logging/log_reader.h"
@@ -13,22 +13,24 @@
#include "y2019/control_loops/drivetrain/drivetrain_base.h"
#include "y2019/control_loops/drivetrain/event_loop_localizer.h"
-DEFINE_string(logfile, "/tmp/logfile.bfbs",
- "Name of the logfile to read from.");
-DEFINE_string(config, "y2019/aos_config.json",
- "Name of the config file to replay using.");
-DEFINE_string(output_file, "/tmp/replayed",
- "Name of the logfile to write replayed data to.");
-DEFINE_int32(team, 971, "Team number to use for logfile replay.");
+ABSL_FLAG(std::string, logfile, "/tmp/logfile.bfbs",
+ "Name of the logfile to read from.");
+ABSL_FLAG(std::string, config, "y2019/aos_config.json",
+ "Name of the config file to replay using.");
+ABSL_FLAG(std::string, output_file, "/tmp/replayed",
+ "Name of the logfile to write replayed data to.");
+ABSL_FLAG(int32_t, team, 971, "Team number to use for logfile replay.");
+
int main(int argc, char **argv) {
aos::InitGoogle(&argc, &argv);
- aos::network::OverrideTeamNumber(FLAGS_team);
+ aos::network::OverrideTeamNumber(absl::GetFlag(FLAGS_team));
const aos::FlatbufferDetachedBuffer<aos::Configuration> config =
- aos::configuration::ReadConfig(FLAGS_config);
+ aos::configuration::ReadConfig(absl::GetFlag(FLAGS_config));
- aos::logger::LogReader reader(FLAGS_logfile, &config.message());
+ aos::logger::LogReader reader(absl::GetFlag(FLAGS_logfile),
+ &config.message());
// TODO(james): Actually enforce not sending on the same buses as the logfile
// spews out.
reader.RemapLoggedChannel("/drivetrain",
@@ -43,7 +45,7 @@
log_writer_event_loop->SkipAosLog();
CHECK(nullptr == log_writer_event_loop->node());
aos::logger::Logger writer(log_writer_event_loop.get());
- writer.StartLoggingOnRun(FLAGS_output_file);
+ writer.StartLoggingOnRun(absl::GetFlag(FLAGS_output_file));
std::unique_ptr<aos::EventLoop> drivetrain_event_loop =
reader.event_loop_factory()->MakeEventLoop("drivetrain");
diff --git a/y2019/control_loops/drivetrain/localizer_test.cc b/y2019/control_loops/drivetrain/localizer_test.cc
index 278b958a..b92c466 100644
--- a/y2019/control_loops/drivetrain/localizer_test.cc
+++ b/y2019/control_loops/drivetrain/localizer_test.cc
@@ -3,7 +3,7 @@
#include <queue>
#include <random>
-#include "gflags/gflags.h"
+#include "absl/flags/flag.h"
#include "aos/testing/random_seed.h"
#include "aos/testing/test_shm.h"
@@ -17,7 +17,7 @@
#include "y2019/constants.h"
#include "y2019/control_loops/drivetrain/drivetrain_base.h"
-DEFINE_bool(plot, false, "If true, plot");
+ABSL_FLAG(bool, plot, false, "If true, plot");
namespace y2019::control_loops::testing {
@@ -210,7 +210,7 @@
printf("Each iteration of the simulation took on average %f seconds.\n",
avg_time_.count());
#if defined(SUPPORT_PLOT)
- if (FLAGS_plot) {
+ if (absl::GetFlag(FLAGS_plot)) {
matplotlibcpp::figure();
matplotlibcpp::plot(simulation_t_, simulation_vl_, {{"label", "Vl"}});
matplotlibcpp::plot(simulation_t_, simulation_vr_, {{"label", "Vr"}});
diff --git a/y2019/control_loops/drivetrain/replay_localizer.cc b/y2019/control_loops/drivetrain/replay_localizer.cc
index 80cf221..2e7591a 100644
--- a/y2019/control_loops/drivetrain/replay_localizer.cc
+++ b/y2019/control_loops/drivetrain/replay_localizer.cc
@@ -1,6 +1,6 @@
#include <fcntl.h>
-#include "gflags/gflags.h"
+#include "absl/flags/flag.h"
#include "aos/init.h"
#include "aos/logging/implementations.h"
@@ -17,13 +17,13 @@
#include "third_party/matplotlib-cpp/matplotlibcpp.h"
#endif
-DEFINE_string(logfile, "", "Path to the logfile to replay.");
+ABSL_FLAG(std::string, logfile, "", "Path to the logfile to replay.");
// TODO(james): Figure out how to reliably source team number from logfile.
-DEFINE_int32(team, 971, "Team number to use for logfile replay.");
-DEFINE_int32(plot_duration, 30,
- "Duration, in seconds, to plot after the start time.");
-DEFINE_int32(start_offset, 0,
- "Time, in seconds, to start replay plot after the first enable.");
+ABSL_FLAG(int32_t, team, 971, "Team number to use for logfile replay.");
+ABSL_FLAG(int32_t, plot_duration, 30,
+ "Duration, in seconds, to plot after the start time.");
+ABSL_FLAG(int32_t, start_offset, 0,
+ "Time, in seconds, to start replay plot after the first enable.");
namespace y2019::control_loops::drivetrain {
using ::y2019::constants::Field;
diff --git a/y2019/control_loops/drivetrain/trajectory_generator_main.cc b/y2019/control_loops/drivetrain/trajectory_generator_main.cc
index 8f18222..4219d8d 100644
--- a/y2019/control_loops/drivetrain/trajectory_generator_main.cc
+++ b/y2019/control_loops/drivetrain/trajectory_generator_main.cc
@@ -1,6 +1,8 @@
#include <sys/resource.h>
#include <sys/time.h>
+#include "absl/flags/flag.h"
+
#include "aos/events/shm_event_loop.h"
#include "aos/init.h"
#include "frc971/control_loops/drivetrain/trajectory_generator.h"
@@ -8,8 +10,8 @@
using ::frc971::control_loops::drivetrain::TrajectoryGenerator;
-DEFINE_bool(skip_renicing, false,
- "If true, skip renicing the trajectory generator.");
+ABSL_FLAG(bool, skip_renicing, false,
+ "If true, skip renicing the trajectory generator.");
int main(int argc, char *argv[]) {
::aos::InitGoogle(&argc, &argv);
@@ -22,7 +24,7 @@
&event_loop, ::y2019::control_loops::drivetrain::GetDrivetrainConfig());
event_loop.OnRun([]() {
- if (FLAGS_skip_renicing) {
+ if (absl::GetFlag(FLAGS_skip_renicing)) {
LOG(WARNING) << "Ignoring request to renice to -20 due to "
"--skip_renicing.";
} else {