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/y2020/control_loops/drivetrain/BUILD b/y2020/control_loops/drivetrain/BUILD
index feabb62..9bf0fab 100644
--- a/y2020/control_loops/drivetrain/BUILD
+++ b/y2020/control_loops/drivetrain/BUILD
@@ -192,8 +192,9 @@
         "//aos/testing:googletest",
         "//frc971/control_loops/drivetrain:drivetrain_lib",
         "//frc971/control_loops/drivetrain:trajectory_schema",
-        "@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",
     ],
 )
 
@@ -216,8 +217,9 @@
         "//frc971/control_loops/drivetrain:trajectory_generator",
         "//y2020:constants",
         "//y2020/control_loops/superstructure:superstructure_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/y2020/control_loops/drivetrain/drivetrain_replay.cc b/y2020/control_loops/drivetrain/drivetrain_replay.cc
index 326c184..5c5c20b 100644
--- a/y2020/control_loops/drivetrain/drivetrain_replay.cc
+++ b/y2020/control_loops/drivetrain/drivetrain_replay.cc
@@ -4,7 +4,7 @@
 // replayed, so that it can then be run through the plotting tool or analyzed
 // in some other way. The original drivetrain status data will be on the
 // /original/drivetrain channel.
-#include "gflags/gflags.h"
+#include "absl/flags/flag.h"
 
 #include "aos/configuration.h"
 #include "aos/events/logging/log_reader.h"
@@ -21,12 +21,13 @@
 #include "y2020/control_loops/drivetrain/localizer.h"
 #include "y2020/control_loops/superstructure/superstructure.h"
 
-DEFINE_string(config, "y2020/aos_config.json",
-              "Name of the config file to replay using.");
-DEFINE_string(output_folder, "/tmp/replayed",
-              "Name of the folder to write replayed logs to.");
-DEFINE_int32(team, 971, "Team number to use for logfile replay.");
-DEFINE_bool(log_all_nodes, false, "Whether to rerun the logger on every node.");
+ABSL_FLAG(std::string, config, "y2020/aos_config.json",
+          "Name of the config file to replay using.");
+ABSL_FLAG(std::string, output_folder, "/tmp/replayed",
+          "Name of the folder to write replayed logs to.");
+ABSL_FLAG(int32_t, team, 971, "Team number to use for logfile replay.");
+ABSL_FLAG(bool, log_all_nodes, false,
+          "Whether to rerun the logger on every node.");
 
 // TODO(james): Currently, this replay produces logfiles that can't be read due
 // to time estimation issues. Pending the active refactorings of the
@@ -34,10 +35,10 @@
 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));
 
   // sort logfiles
   const std::vector<aos::logger::LogFile> logfiles =
@@ -60,16 +61,17 @@
   reader.Register();
 
   std::vector<std::unique_ptr<aos::util::LoggerState>> loggers;
-  if (FLAGS_log_all_nodes) {
-    loggers = aos::util::MakeLoggersForAllNodes(reader.event_loop_factory(),
-                                                FLAGS_output_folder);
+  if (absl::GetFlag(FLAGS_log_all_nodes)) {
+    loggers = aos::util::MakeLoggersForAllNodes(
+        reader.event_loop_factory(), absl::GetFlag(FLAGS_output_folder));
   } else {
     // List of nodes to create loggers for (note: currently just roborio; this
     // code was refactored to allow easily adding new loggers to accommodate
     // debugging and potential future changes).
     const std::vector<std::string> nodes_to_log = {"roborio"};
-    loggers = aos::util::MakeLoggersForNodes(reader.event_loop_factory(),
-                                             nodes_to_log, FLAGS_output_folder);
+    loggers = aos::util::MakeLoggersForNodes(
+        reader.event_loop_factory(), nodes_to_log,
+        absl::GetFlag(FLAGS_output_folder));
   }
 
   const aos::Node *node = nullptr;
diff --git a/y2020/control_loops/drivetrain/drivetrain_replay_test.cc b/y2020/control_loops/drivetrain/drivetrain_replay_test.cc
index 8d096cd..62592c0 100644
--- a/y2020/control_loops/drivetrain/drivetrain_replay_test.cc
+++ b/y2020/control_loops/drivetrain/drivetrain_replay_test.cc
@@ -8,7 +8,7 @@
 // longer be valid.
 // TODO(james): Do something about that when the time comes--could just copy
 // the existing drivetrain config into this file and use it directly.
-#include "gflags/gflags.h"
+#include "absl/flags/flag.h"
 #include "gtest/gtest.h"
 
 #include "aos/configuration.h"
@@ -22,17 +22,18 @@
 #include "frc971/control_loops/drivetrain/trajectory_schema.h"
 #include "y2020/control_loops/drivetrain/drivetrain_base.h"
 
-DEFINE_string(logfile, "external/drivetrain_replay/",
-              "Name of the logfile to read from.");
-DEFINE_string(config, "y2020/aos_config.json",
-              "Name of the config file to replay using.");
+ABSL_FLAG(std::string, logfile, "external/drivetrain_replay/",
+          "Name of the logfile to read from.");
+ABSL_FLAG(std::string, config, "y2020/aos_config.json",
+          "Name of the config file to replay using.");
 
 namespace y2020::control_loops::drivetrain::testing {
 
 class DrivetrainReplayTest : public ::testing::Test {
  public:
   DrivetrainReplayTest()
-      : reader_(aos::logger::SortParts(aos::logger::FindLogs(FLAGS_logfile))) {
+      : reader_(aos::logger::SortParts(
+            aos::logger::FindLogs(absl::GetFlag(FLAGS_logfile)))) {
     aos::network::OverrideTeamNumber(971);
 
     // TODO(james): Actually enforce not sending on the same buses as the
diff --git a/y2020/control_loops/drivetrain/localizer.cc b/y2020/control_loops/drivetrain/localizer.cc
index 0943b28..f8518f3 100644
--- a/y2020/control_loops/drivetrain/localizer.cc
+++ b/y2020/control_loops/drivetrain/localizer.cc
@@ -1,10 +1,12 @@
 #include "y2020/control_loops/drivetrain/localizer.h"
 
+#include "absl/flags/flag.h"
+
 #include "y2020/constants.h"
 
-DEFINE_bool(send_empty_debug, false,
-            "If true, send LocalizerDebug messages on every tick, even if "
-            "they would be empty.");
+ABSL_FLAG(bool, send_empty_debug, false,
+          "If true, send LocalizerDebug messages on every tick, even if "
+          "they would be empty.");
 
 namespace y2020::control_loops::drivetrain {
 
@@ -181,7 +183,7 @@
       }
     }
   }
-  if (FLAGS_send_empty_debug || !debug_offsets.empty()) {
+  if (absl::GetFlag(FLAGS_send_empty_debug) || !debug_offsets.empty()) {
     const auto vector_offset =
         builder.fbb()->CreateVector(debug_offsets.data(), debug_offsets.size());
     const auto rejections_offset =
diff --git a/y2020/control_loops/drivetrain/localizer_test.cc b/y2020/control_loops/drivetrain/localizer_test.cc
index e509241..951a286 100644
--- a/y2020/control_loops/drivetrain/localizer_test.cc
+++ b/y2020/control_loops/drivetrain/localizer_test.cc
@@ -2,6 +2,7 @@
 
 #include <queue>
 
+#include "absl/flags/flag.h"
 #include "gtest/gtest.h"
 
 #include "aos/events/logging/log_writer.h"
@@ -14,8 +15,8 @@
 #include "y2020/control_loops/drivetrain/drivetrain_base.h"
 #include "y2020/control_loops/superstructure/superstructure_status_generated.h"
 
-DEFINE_string(output_file, "",
-              "If set, logs all channels to the provided logfile.");
+ABSL_FLAG(std::string, output_file, "",
+          "If set, logs all channels to the provided logfile.");
 
 // This file tests that the full 2020 localizer behaves sanely.
 
@@ -145,10 +146,10 @@
     set_team_id(frc971::control_loops::testing::kTeamNumber);
     set_battery_voltage(12.0);
 
-    if (!FLAGS_output_file.empty()) {
+    if (!absl::GetFlag(FLAGS_output_file).empty()) {
       logger_event_loop_ = MakeEventLoop("logger", roborio_);
       logger_ = std::make_unique<aos::logger::Logger>(logger_event_loop_.get());
-      logger_->StartLoggingOnRun(FLAGS_output_file);
+      logger_->StartLoggingOnRun(absl::GetFlag(FLAGS_output_file));
     }
 
     test_event_loop_->MakeWatcher(
diff --git a/y2020/control_loops/drivetrain/trajectory_generator_main.cc b/y2020/control_loops/drivetrain/trajectory_generator_main.cc
index 152822e..e7634b7 100644
--- a/y2020/control_loops/drivetrain/trajectory_generator_main.cc
+++ b/y2020/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, ::y2020::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 {