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/aos/init_for_rust.cc b/aos/init_for_rust.cc
index 9af4d83..1ede457 100644
--- a/aos/init_for_rust.cc
+++ b/aos/init_for_rust.cc
@@ -1,16 +1,19 @@
 #include "aos/init_for_rust.h"
 
-#include "gflags/gflags.h"
-#include "glog/logging.h"
+#include "absl/flags/flag.h"
+#include "absl/flags/reflection.h"
+#include "absl/log/check.h"
+#include "absl/log/initialize.h"
+#include "absl/log/log.h"
 
 #include "aos/init.h"
 
 namespace aos {
 
-void InitFromRust(const char *argv0) {
-  CHECK(!IsInitialized()) << "Only initialize once.";
+void InitFromRust(const char * /*argv0*/) {
+  CHECK(!aos::IsInitialized()) << "Only initialize once.";
 
-  google::InitGoogleLogging(argv0);
+  absl::InitializeLog();
 
   // TODO(Brian): Where should Rust binaries be configured to write coredumps?
 
@@ -20,16 +23,50 @@
 }
 
 std::vector<FlagInfo> GetCppFlags() {
-  std::vector<gflags::CommandLineFlagInfo> info;
-  gflags::GetAllFlags(&info);
+  absl::flat_hash_map<absl::string_view, absl::CommandLineFlag *> info =
+      absl::GetAllFlags();
   std::vector<FlagInfo> out;
   for (const auto &flag : info) {
+    std::string type;
+    if (flag.second->IsOfType<float>()) {
+      type = "float";
+    } else if (flag.second->IsOfType<double>()) {
+      type = "double";
+    } else if (flag.second->IsOfType<bool>()) {
+      type = "bool";
+    } else if (flag.second->IsOfType<uint8_t>()) {
+      type = "uint8_t";
+    } else if (flag.second->IsOfType<int8_t>()) {
+      type = "int8_t";
+    } else if (flag.second->IsOfType<uint16_t>()) {
+      type = "uint16_t";
+    } else if (flag.second->IsOfType<int16_t>()) {
+      type = "int16_t";
+    } else if (flag.second->IsOfType<uint32_t>()) {
+      type = "uint32_t";
+    } else if (flag.second->IsOfType<int32_t>()) {
+      type = "int32_t";
+    } else if (flag.second->IsOfType<uint64_t>()) {
+      type = "uint64_t";
+    } else if (flag.second->IsOfType<int64_t>()) {
+      type = "int64_t";
+    } else if (flag.second->IsOfType<std::string>()) {
+      type = "string";
+    } else if (flag.second->IsOfType<std::vector<std::string>>()) {
+      type = "vector<string>";
+    } else {
+      LOG(FATAL) << "Unknown type for flag " << flag.second->Name()
+                 << " in file " << flag.second->Filename();
+    }
+
+    LOG(INFO) << "Reporting flag " << flag.second->Name() << " " << type << " "
+              << flag.second->DefaultValue();
     FlagInfo out_flag = {
-        .name_ = flag.name,
-        .type_ = flag.type,
-        .description_ = flag.description,
-        .default_value_ = flag.default_value,
-        .filename_ = flag.filename,
+        .name_ = std::string(flag.second->Name()),
+        .type_ = type,
+        .description_ = flag.second->Help(),
+        .default_value_ = flag.second->DefaultValue(),
+        .filename_ = flag.second->Filename(),
     };
     out.push_back(out_flag);
   }
@@ -37,13 +74,21 @@
 }
 
 bool SetCommandLineOption(const char *name, const char *value) {
-  return !gflags::SetCommandLineOption(name, value).empty();
+  absl::CommandLineFlag *flag = absl::FindCommandLineFlag(name);
+  if (flag == nullptr) {
+    return false;
+  }
+
+  std::string error;
+  bool result = flag->ParseFrom(value, &error);
+  return result;
 }
 
 std::string GetCommandLineOption(const char *name) {
-  std::string out;
-  CHECK(gflags::GetCommandLineOption(name, &out)) << "Unknown flag " << name;
-  return out;
+  absl::CommandLineFlag *flag = absl::FindCommandLineFlag(name);
+  CHECK(flag != nullptr) << "Unknown flag " << name;
+
+  return flag->CurrentValue();
 }
 
 }  // namespace aos