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/frc971/analysis/pdp_values.cc b/frc971/analysis/pdp_values.cc
index b314cc6..15b29b2 100644
--- a/frc971/analysis/pdp_values.cc
+++ b/frc971/analysis/pdp_values.cc
@@ -1,14 +1,15 @@
 #include <fstream>
 
-#include "gflags/gflags.h"
-#include "glog/logging.h"
+#include "absl/flags/flag.h"
+#include "absl/log/check.h"
+#include "absl/log/log.h"
 
 #include "aos/events/logging/log_reader.h"
 #include "aos/events/simulated_event_loop.h"
 #include "aos/init.h"
 #include "frc971/wpilib/pdp_values_generated.h"
 
-DEFINE_string(output_path, "/tmp/pdp_values.csv", "");
+ABSL_FLAG(std::string, output_path, "/tmp/pdp_values.csv", "");
 
 int main(int argc, char **argv) {
   aos::InitGoogle(&argc, &argv);
@@ -27,7 +28,7 @@
       event_loop_factory.MakeEventLoop("roborio", roborio);
 
   std::ofstream file_stream;
-  file_stream.open(FLAGS_output_path);
+  file_stream.open(absl::GetFlag(FLAGS_output_path));
   file_stream << "timestamp,currents,voltage\n";
 
   event_loop->SkipAosLog();
diff --git a/frc971/analysis/trim_log_to_enabled.cc b/frc971/analysis/trim_log_to_enabled.cc
index fb6b0c6..a92d74e 100644
--- a/frc971/analysis/trim_log_to_enabled.cc
+++ b/frc971/analysis/trim_log_to_enabled.cc
@@ -1,31 +1,34 @@
 #include <optional>
 
-#include "gflags/gflags.h"
+#include "absl/flags/flag.h"
+#include "absl/flags/usage.h"
+#include "absl/log/check.h"
+#include "absl/log/log.h"
 
 #include "aos/events/logging/log_reader.h"
 #include "aos/init.h"
 #include "aos/util/simulation_logger.h"
 #include "frc971/input/joystick_state_generated.h"
 
-DEFINE_string(output_folder, "/tmp/trimmed/",
-              "Name of the folder to write the trimmed log to.");
-DEFINE_string(node, "roborio", "");
-DEFINE_bool(auto, false, "If set, trim the log to just the auto mode.");
-DEFINE_double(pre_enable_time_sec, 10.0,
-              "Amount of time to leave in the new log before the first enable "
-              "signal happens.");
-DEFINE_double(post_enable_time_sec, 1.0,
-              "Amount of time to leave in the new log after the final enable "
-              "signal ends.");
-DEFINE_double(force_start_monotonic, -1.0,
-              "If set, time, in seconds, at which to forcibly trim the start "
-              "of the log.");
-DEFINE_double(
-    force_end_monotonic, -1.0,
+ABSL_FLAG(std::string, output_folder, "/tmp/trimmed/",
+          "Name of the folder to write the trimmed log to.");
+ABSL_FLAG(std::string, node, "roborio", "");
+ABSL_FLAG(bool, auto, false, "If set, trim the log to just the auto mode.");
+ABSL_FLAG(double, pre_enable_time_sec, 10.0,
+          "Amount of time to leave in the new log before the first enable "
+          "signal happens.");
+ABSL_FLAG(double, post_enable_time_sec, 1.0,
+          "Amount of time to leave in the new log after the final enable "
+          "signal ends.");
+ABSL_FLAG(double, force_start_monotonic, -1.0,
+          "If set, time, in seconds, at which to forcibly trim the start "
+          "of the log.");
+ABSL_FLAG(
+    double, force_end_monotonic, -1.0,
     "If set, time, in seconds, at which to forcibly trim the end of the log.");
 
 int main(int argc, char *argv[]) {
-  gflags::SetUsageMessage(
+  absl::SetProgramUsageMessage(
       "Trims the sections at the start/end of a log where the robot is "
       "disabled.");
   aos::InitGoogle(&argc, &argv);
@@ -34,35 +37,35 @@
   std::optional<aos::monotonic_clock::time_point> start_time;
   std::optional<aos::monotonic_clock::time_point> end_time;
   bool printed_match = false;
-  bool force_time_range = FLAGS_force_start_monotonic > 0;
+  bool force_time_range = absl::GetFlag(FLAGS_force_start_monotonic) > 0;
   // We need to do two passes through the logfile; one to figure out when the
   // start/end times are, one to actually do the trimming.
   if (!force_time_range) {
     aos::logger::LogReader reader(logfiles);
-    const aos::Node *roborio =
-        aos::configuration::GetNode(reader.configuration(), FLAGS_node);
+    const aos::Node *roborio = aos::configuration::GetNode(
+        reader.configuration(), absl::GetFlag(FLAGS_node));
     reader.Register();
     std::unique_ptr<aos::EventLoop> event_loop =
-        reader.event_loop_factory()->MakeEventLoop(FLAGS_node, roborio);
-    event_loop->MakeWatcher(
-        "/aos", [&start_time, &end_time, &printed_match,
-                 &event_loop](const aos::JoystickState &msg) {
-          if (!printed_match && msg.match_type() != aos::MatchType::kNone) {
-            LOG(INFO) << "Match Type: "
-                      << aos::EnumNameMatchType(msg.match_type());
-            LOG(INFO) << "Match #: " << msg.match_number();
-            printed_match = true;
-          }
+        reader.event_loop_factory()->MakeEventLoop(absl::GetFlag(FLAGS_node),
+                                                   roborio);
+    event_loop->MakeWatcher("/aos", [&start_time, &end_time, &printed_match,
+                                     &event_loop](
+                                        const aos::JoystickState &msg) {
+      if (!printed_match && msg.match_type() != aos::MatchType::kNone) {
+        LOG(INFO) << "Match Type: " << aos::EnumNameMatchType(msg.match_type());
+        LOG(INFO) << "Match #: " << msg.match_number();
+        printed_match = true;
+      }
 
-          if (msg.enabled() && (!FLAGS_auto || msg.autonomous())) {
-            // Note that time is monotonic, so we don't need to e.g. do min's or
-            // max's on the start/end time.
-            if (!start_time.has_value()) {
-              start_time = event_loop->context().monotonic_event_time;
-            }
-            end_time = event_loop->context().monotonic_event_time;
-          }
-        });
+      if (msg.enabled() && (!absl::GetFlag(FLAGS_auto) || msg.autonomous())) {
+        // Note that time is monotonic, so we don't need to e.g. do min's or
+        // max's on the start/end time.
+        if (!start_time.has_value()) {
+          start_time = event_loop->context().monotonic_event_time;
+        }
+        end_time = event_loop->context().monotonic_event_time;
+      }
+    });
 
     reader.event_loop_factory()->Run();
 
@@ -76,26 +79,32 @@
     LOG(INFO) << "First enable at " << start_time.value();
     LOG(INFO) << "Final enable at " << end_time.value();
     start_time.value() -= std::chrono::duration_cast<std::chrono::nanoseconds>(
-        std::chrono::duration<double>(FLAGS_pre_enable_time_sec));
+        std::chrono::duration<double>(
+            absl::GetFlag(FLAGS_pre_enable_time_sec)));
     end_time.value() += std::chrono::duration_cast<std::chrono::nanoseconds>(
-        std::chrono::duration<double>(FLAGS_post_enable_time_sec));
+        std::chrono::duration<double>(
+            absl::GetFlag(FLAGS_post_enable_time_sec)));
   } else {
-    CHECK_LT(FLAGS_force_start_monotonic, FLAGS_force_end_monotonic);
+    CHECK_LT(absl::GetFlag(FLAGS_force_start_monotonic),
+             absl::GetFlag(FLAGS_force_end_monotonic));
     start_time = aos::monotonic_clock::time_point(
         std::chrono::duration_cast<std::chrono::nanoseconds>(
-            std::chrono::duration<double>(FLAGS_force_start_monotonic)));
+            std::chrono::duration<double>(
+                absl::GetFlag(FLAGS_force_start_monotonic))));
     end_time = aos::monotonic_clock::time_point(
         std::chrono::duration_cast<std::chrono::nanoseconds>(
-            std::chrono::duration<double>(FLAGS_force_end_monotonic)));
+            std::chrono::duration<double>(
+                absl::GetFlag(FLAGS_force_end_monotonic))));
   }
 
   {
     aos::logger::LogReader reader(logfiles);
-    const aos::Node *roborio =
-        aos::configuration::GetNode(reader.configuration(), FLAGS_node);
+    const aos::Node *roborio = aos::configuration::GetNode(
+        reader.configuration(), absl::GetFlag(FLAGS_node));
     reader.Register();
     std::unique_ptr<aos::EventLoop> event_loop =
-        reader.event_loop_factory()->MakeEventLoop(FLAGS_node, roborio);
+        reader.event_loop_factory()->MakeEventLoop(absl::GetFlag(FLAGS_node),
+                                                   roborio);
     auto exit_timer = event_loop->AddTimer(
         [&reader]() { reader.event_loop_factory()->Exit(); });
     exit_timer->Schedule(start_time.value());
@@ -107,13 +116,13 @@
     // easily auto-detect which node to replay as when consuming the input logs.
     auto loggers = aos::util::MakeLoggersForNodes(
         reader.event_loop_factory(), {logger_nodes.begin(), logger_nodes.end()},
-        FLAGS_output_folder);
+        absl::GetFlag(FLAGS_output_folder));
     exit_timer->Schedule(end_time.value());
 
     reader.event_loop_factory()->Run();
   }
 
-  LOG(INFO) << "Trimmed logs written to " << FLAGS_output_folder;
+  LOG(INFO) << "Trimmed logs written to " << absl::GetFlag(FLAGS_output_folder);
 
   return EXIT_SUCCESS;
 }